input_stream: no CamelCase

Renamed all functions and variables.
This commit is contained in:
Max Kellermann 2008-10-26 20:34:47 +01:00
parent 97a9c7a8e0
commit dbc7e9ba2f
17 changed files with 156 additions and 158 deletions

View File

@ -31,12 +31,12 @@ ogg_stream_type ogg_stream_type_detect(struct input_stream *inStream)
unsigned char buf[41];
size_t r;
seekInputStream(inStream, 0, SEEK_SET);
input_stream_seek(inStream, 0, SEEK_SET);
r = decoder_read(NULL, inStream, buf, sizeof(buf));
if (r > 0)
seekInputStream(inStream, 0, SEEK_SET);
input_stream_seek(inStream, 0, SEEK_SET);
if (r >= 32 && memcmp(buf, "OggS", 4) == 0 && (
(memcmp(buf+29, "FLAC", 4) == 0

View File

@ -67,7 +67,7 @@ static void fillAacBuffer(AacBuffer * b)
bread = decoder_read(b->decoder, b->inStream,
(void *)(b->buffer + b->bytesIntoBuffer),
rest);
if (bread == 0 && inputStreamAtEOF(b->inStream))
if (bread == 0 && input_stream_eof(b->inStream))
b->atEof = 1;
b->bytesIntoBuffer += bread;
}
@ -215,7 +215,7 @@ static void aac_parse_header(AacBuffer * b, float *length)
if (b->bytesIntoBuffer >= 2 &&
(b->buffer[0] == 0xFF) && ((b->buffer[1] & 0xF6) == 0xF0)) {
adtsParse(b, length);
seekInputStream(b->inStream, tagsize, SEEK_SET);
input_stream_seek(b->inStream, tagsize, SEEK_SET);
b->bytesIntoBuffer = 0;
b->bytesConsumed = 0;
@ -257,7 +257,7 @@ static float getAacFloatTotalTime(char *file)
struct input_stream inStream;
long bread;
if (openInputStream(&inStream, file) < 0)
if (input_stream_open(&inStream, file) < 0)
return -1;
initAacBuffer(&b, NULL, &inStream);
@ -285,7 +285,7 @@ static float getAacFloatTotalTime(char *file)
if (b.buffer)
free(b.buffer);
closeInputStream(&inStream);
input_stream_close(&inStream);
return length;
}
@ -461,7 +461,7 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
if ((totalTime = getAacFloatTotalTime(path)) < 0)
return -1;
if (openInputStream(&inStream, path) < 0)
if (input_stream_open(&inStream, path) < 0)
return -1;
initAacBuffer(&b, mpd_decoder, &inStream);

View File

@ -85,10 +85,10 @@ static int mpdurl_read(URLContext *h, unsigned char *buf, int size)
int ret;
FopsHelper *base = (FopsHelper *) h->priv_data;
while (1) {
ret = readFromInputStream(base->input, (void *)buf, size);
ret = input_stream_read(base->input, (void *)buf, size);
if (ret == 0) {
DEBUG("ret 0\n");
if (inputStreamAtEOF(base->input) ||
if (input_stream_eof(base->input) ||
(base->decoder &&
decoder_get_command(base->decoder) != DECODE_COMMAND_NONE)) {
DEBUG("eof stream\n");
@ -107,7 +107,7 @@ static int64_t mpdurl_seek(URLContext *h, int64_t pos, int whence)
{
FopsHelper *base = (FopsHelper *) h->priv_data;
if (whence != AVSEEK_SIZE) { //only ftell
(void) seekInputStream(base->input, pos, whence);
(void) input_stream_seek(base->input, pos, whence);
}
return base->input->offset;
}
@ -116,7 +116,7 @@ static int mpdurl_close(URLContext *h)
{
FopsHelper *base = (FopsHelper *) h->priv_data;
if (base && base->input->seekable) {
(void) seekInputStream(base->input, 0, SEEK_SET);
(void) input_stream_seek(base->input, 0, SEEK_SET);
}
h->priv_data = 0;
return 0;
@ -360,7 +360,7 @@ static struct tag *ffmpeg_tag(char *file)
int ret;
struct tag *tag = NULL;
if (openInputStream(&input, file) < 0) {
if (input_stream_open(&input, file) < 0) {
ERROR("failed to open %s\n", file);
return NULL;
}
@ -375,7 +375,7 @@ static struct tag *ffmpeg_tag(char *file)
tag = NULL;
}
closeInputStream(&input);
input_stream_close(&input);
return tag;
}

View File

@ -37,7 +37,7 @@ static flac_read_status flacRead(mpd_unused const flac_decoder * flacDec,
if (r == 0) {
if (decoder_get_command(data->decoder) != DECODE_COMMAND_NONE ||
inputStreamAtEOF(data->inStream))
input_stream_eof(data->inStream))
return flac_read_status_eof;
else
return flac_read_status_abort;
@ -52,7 +52,7 @@ static flac_seek_status flacSeek(mpd_unused const flac_decoder * flacDec,
{
FlacData *data = (FlacData *) fdata;
if (seekInputStream(data->inStream, offset, SEEK_SET) < 0) {
if (input_stream_seek(data->inStream, offset, SEEK_SET) < 0) {
return flac_seek_status_error;
}
@ -87,7 +87,7 @@ static FLAC__bool flacEOF(mpd_unused const flac_decoder * flacDec, void *fdata)
return (decoder_get_command(data->decoder) != DECODE_COMMAND_NONE &&
decoder_get_command(data->decoder) != DECODE_COMMAND_SEEK) ||
inputStreamAtEOF(data->inStream);
input_stream_eof(data->inStream);
}
static void flacError(mpd_unused const flac_decoder *dec,

View File

@ -158,7 +158,7 @@ static void initMp3DecodeData(mp3DecodeData * data, struct decoder *decoder,
static int seekMp3InputBuffer(mp3DecodeData * data, long offset)
{
if (seekInputStream(data->inStream, offset, SEEK_SET) < 0) {
if (input_stream_seek(data->inStream, offset, SEEK_SET) < 0) {
return -1;
}
@ -757,7 +757,7 @@ static int getMp3TotalTime(char *file)
mp3DecodeData data;
int ret;
if (openInputStream(&inStream, file) < 0)
if (input_stream_open(&inStream, file) < 0)
return -1;
initMp3DecodeData(&data, NULL, &inStream);
if (decodeFirstFrame(&data, NULL, NULL) < 0)
@ -765,7 +765,7 @@ static int getMp3TotalTime(char *file)
else
ret = data.totalTime + 0.5;
mp3DecodeDataFinalize(&data);
closeInputStream(&inStream);
input_stream_close(&inStream);
return ret;
}
@ -854,16 +854,16 @@ mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
return DECODE_BREAK;
}
if (data->inStream->metaTitle) {
if (data->inStream->meta_title) {
struct tag *tag = tag_new();
if (data->inStream->metaName) {
if (data->inStream->meta_name) {
tag_add_item(tag, TAG_ITEM_NAME,
data->inStream->metaName);
data->inStream->meta_name);
}
tag_add_item(tag, TAG_ITEM_TITLE,
data->inStream->metaTitle);
free(data->inStream->metaTitle);
data->inStream->metaTitle = NULL;
data->inStream->meta_title);
free(data->inStream->meta_title);
data->inStream->meta_title = NULL;
tag_free(tag);
}
@ -1009,27 +1009,27 @@ mp3_decode(struct decoder * decoder, struct input_stream *inStream)
initAudioFormatFromMp3DecodeData(&data, &audio_format);
if (inStream->metaTitle) {
if (inStream->meta_title) {
if (tag)
tag_free(tag);
tag = tag_new();
tag_add_item(tag, TAG_ITEM_TITLE, inStream->metaTitle);
free(inStream->metaTitle);
inStream->metaTitle = NULL;
if (inStream->metaName) {
tag_add_item(tag, TAG_ITEM_NAME, inStream->metaName);
tag_add_item(tag, TAG_ITEM_TITLE, inStream->meta_title);
free(inStream->meta_title);
inStream->meta_title = NULL;
if (inStream->meta_name) {
tag_add_item(tag, TAG_ITEM_NAME, inStream->meta_name);
}
tag_free(tag);
} else if (tag) {
if (inStream->metaName) {
if (inStream->meta_name) {
tag_clear_items_by_type(tag, TAG_ITEM_NAME);
tag_add_item(tag, TAG_ITEM_NAME, inStream->metaName);
tag_add_item(tag, TAG_ITEM_NAME, inStream->meta_name);
}
tag_free(tag);
} else if (inStream->metaName) {
} else if (inStream->meta_name) {
tag = tag_new();
if (inStream->metaName) {
tag_add_item(tag, TAG_ITEM_NAME, inStream->metaName);
if (inStream->meta_name) {
tag_add_item(tag, TAG_ITEM_NAME, inStream->meta_name);
}
tag_free(tag);
}

View File

@ -68,13 +68,13 @@ static int mp4_getAACTrack(mp4ff_t * infile)
static uint32_t mp4_inputStreamReadCallback(void *inStream, void *buffer,
uint32_t length)
{
return readFromInputStream((struct input_stream *) inStream,
return input_stream_read((struct input_stream *) inStream,
buffer, length);
}
static uint32_t mp4_inputStreamSeekCallback(void *inStream, uint64_t position)
{
return seekInputStream((struct input_stream *) inStream,
return input_stream_seek((struct input_stream *) inStream,
position, SEEK_SET);
}
@ -317,7 +317,7 @@ static struct tag *mp4DataDup(char *file, int *mp4MetadataFound)
*mp4MetadataFound = 0;
if (openInputStream(&inStream, file) < 0) {
if (input_stream_open(&inStream, file) < 0) {
DEBUG("mp4DataDup: Failed to open file: %s\n", file);
return NULL;
}
@ -330,14 +330,14 @@ static struct tag *mp4DataDup(char *file, int *mp4MetadataFound)
mp4fh = mp4ff_open_read(callback);
if (!mp4fh) {
free(callback);
closeInputStream(&inStream);
input_stream_close(&inStream);
return NULL;
}
track = mp4_getAACTrack(mp4fh);
if (track < 0) {
mp4ff_close(mp4fh);
closeInputStream(&inStream);
input_stream_close(&inStream);
free(callback);
return NULL;
}
@ -347,7 +347,7 @@ static struct tag *mp4DataDup(char *file, int *mp4MetadataFound)
scale = mp4ff_time_scale(mp4fh, track);
if (scale < 0) {
mp4ff_close(mp4fh);
closeInputStream(&inStream);
input_stream_close(&inStream);
free(callback);
tag_free(ret);
return NULL;
@ -388,7 +388,7 @@ static struct tag *mp4DataDup(char *file, int *mp4MetadataFound)
}
mp4ff_close(mp4fh);
closeInputStream(&inStream);
input_stream_close(&inStream);
return ret;
}

View File

@ -38,7 +38,7 @@ static mpc_bool_t mpc_seek_cb(void *vdata, mpc_int32_t offset)
{
MpcCallbackData *data = (MpcCallbackData *) vdata;
return seekInputStream(data->inStream, offset, SEEK_SET) < 0 ? 0 : 1;
return input_stream_seek(data->inStream, offset, SEEK_SET) < 0 ? 0 : 1;
}
static mpc_int32_t mpc_tell_cb(void *vdata)
@ -260,19 +260,19 @@ static float mpcGetTime(char *file)
mpc_streaminfo_init(&info);
if (openInputStream(&inStream, file) < 0) {
if (input_stream_open(&inStream, file) < 0) {
DEBUG("mpcGetTime: Failed to open file: %s\n", file);
return -1;
}
if (mpc_streaminfo_read(&info, &reader) != ERROR_CODE_OK) {
closeInputStream(&inStream);
input_stream_close(&inStream);
return -1;
}
total_time = mpc_streaminfo_get_length(&info);
closeInputStream(&inStream);
input_stream_close(&inStream);
return total_time;
}

View File

@ -49,7 +49,7 @@ static OggFLAC__SeekableStreamDecoderReadStatus of_read_cb(mpd_unused const
r = decoder_read(data->decoder, data->inStream, (void *)buf, *bytes);
*bytes = r;
if (r == 0 && !inputStreamAtEOF(data->inStream) &&
if (r == 0 && !input_stream_eof(data->inStream) &&
decoder_get_command(data->decoder) == DECODE_COMMAND_NONE)
return OggFLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR;
@ -64,7 +64,7 @@ static OggFLAC__SeekableStreamDecoderSeekStatus of_seek_cb(mpd_unused const
{
FlacData *data = (FlacData *) fdata;
if (seekInputStream(data->inStream, offset, SEEK_SET) < 0) {
if (input_stream_seek(data->inStream, offset, SEEK_SET) < 0) {
return OggFLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR;
}
@ -105,7 +105,7 @@ static FLAC__bool of_EOF_cb(mpd_unused const OggFLAC__SeekableStreamDecoder * de
return (decoder_get_command(data->decoder) != DECODE_COMMAND_NONE &&
decoder_get_command(data->decoder) != DECODE_COMMAND_SEEK) ||
inputStreamAtEOF(data->inStream);
input_stream_eof(data->inStream);
}
static void of_error_cb(mpd_unused const OggFLAC__SeekableStreamDecoder * decoder,
@ -261,10 +261,10 @@ static struct tag *oggflac_TagDup(char *file)
OggFLAC__SeekableStreamDecoder *decoder;
FlacData data;
if (openInputStream(&inStream, file) < 0)
if (input_stream_open(&inStream, file) < 0)
return NULL;
if (ogg_stream_type_detect(&inStream) != FLAC) {
closeInputStream(&inStream);
input_stream_close(&inStream);
return NULL;
}
@ -275,7 +275,7 @@ static struct tag *oggflac_TagDup(char *file)
decoder = full_decoder_init_and_read_metadata(&data, 1);
oggflac_cleanup(&data, decoder);
closeInputStream(&inStream);
input_stream_close(&inStream);
return data.tag;
}

View File

@ -66,7 +66,7 @@ static int ogg_seek_cb(void *vdata, ogg_int64_t offset, int whence)
const OggCallbackData *data = (const OggCallbackData *) vdata;
if(decoder_get_command(data->decoder) == DECODE_COMMAND_STOP)
return -1;
return seekInputStream(data->inStream, offset, whence);
return input_stream_seek(data->inStream, offset, whence);
}
/* TODO: check Ogg libraries API and see if we can just not have this func */
@ -284,7 +284,7 @@ oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream)
initialized = 1;
}
comments = ov_comment(&vf, -1)->user_comments;
putOggCommentsIntoOutputBuffer(inStream->metaName,
putOggCommentsIntoOutputBuffer(inStream->meta_name,
comments);
ogg_getReplayGainInfo(comments, &replayGainInfo);
}

View File

@ -366,12 +366,12 @@ static uint32_t get_pos(void *id)
static int set_pos_abs(void *id, uint32_t pos)
{
return seekInputStream(((InputStreamPlus *)id)->is, pos, SEEK_SET);
return input_stream_seek(((InputStreamPlus *)id)->is, pos, SEEK_SET);
}
static int set_pos_rel(void *id, int32_t delta, int mode)
{
return seekInputStream(((InputStreamPlus *)id)->is, delta, mode);
return input_stream_seek(((InputStreamPlus *)id)->is, delta, mode);
}
static int push_back_byte(void *id, int c)
@ -427,7 +427,7 @@ static bool wavpack_trydecode(struct input_stream *is)
WavpackCloseFile(wpc);
/* Seek it back in order to play from the first byte. */
seekInputStream(is, 0, SEEK_SET);
input_stream_seek(is, 0, SEEK_SET);
return true;
}
@ -461,7 +461,7 @@ static int wavpack_open_wvc(struct decoder *decoder,
wvc_url[len] = 'c';
wvc_url[len + 1] = '\0';
ret = openInputStream(is_wvc, wvc_url);
ret = input_stream_open(is_wvc, wvc_url);
free(wvc_url);
if (ret)
@ -472,21 +472,21 @@ static int wavpack_open_wvc(struct decoder *decoder,
* about a possible 404 error.
*/
for (;;) {
if (inputStreamAtEOF(is_wvc)) {
if (input_stream_eof(is_wvc)) {
/*
* EOF is reached even without
* a single byte is read...
* So, this is not good :/
*/
closeInputStream(is_wvc);
input_stream_close(is_wvc);
return 0;
}
if (bufferInputStream(is_wvc) >= 0)
if (input_stream_buffer(is_wvc) >= 0)
return 1;
if (decoder_get_command(decoder) != DECODE_COMMAND_NONE) {
closeInputStream(is_wvc);
input_stream_close(is_wvc);
return 0;
}
@ -525,8 +525,8 @@ wavpack_streamdecode(struct decoder * decoder, struct input_stream *is)
WavpackCloseFile(wpc);
if (open_flags & OPEN_WVC)
closeInputStream(&is_wvc);
closeInputStream(is);
input_stream_close(&is_wvc);
input_stream_close(is);
return 0;
}

View File

@ -115,8 +115,8 @@ size_t decoder_read(struct decoder *decoder,
dc.command != DECODE_COMMAND_NONE)
return 0;
nbytes = readFromInputStream(inStream, buffer, length);
if (nbytes > 0 || inputStreamAtEOF(inStream))
nbytes = input_stream_read(inStream, buffer, length);
if (nbytes > 0 || input_stream_eof(inStream))
return nbytes;
/* sleep for a fraction of a second! */
@ -145,7 +145,7 @@ need_chunks(struct decoder *decoder,
}
if (!inStream ||
bufferInputStream(inStream) <= 0) {
input_stream_buffer(inStream) <= 0) {
notify_wait(&dc.notify);
notify_signal(&pc.notify);
}

View File

@ -43,7 +43,7 @@ static void decodeStart(void)
song_get_url(song, path_max_fs);
dc.current_song = dc.next_song; /* NEED LOCK */
if (openInputStream(&inStream, path_max_fs) < 0) {
if (input_stream_open(&inStream, path_max_fs) < 0) {
dc.error = DECODE_ERROR_FILE;
goto stop_no_close;
}
@ -61,12 +61,12 @@ static void decodeStart(void)
if (dc.command != DECODE_COMMAND_NONE)
goto stop;
ret = bufferInputStream(&inStream);
ret = input_stream_buffer(&inStream);
if (ret < 0)
goto stop;
}
/* for http streams, seekable is determined in bufferInputStream */
/* for http streams, seekable is determined in input_stream_buffer */
dc.seekable = inStream.seekable;
if (dc.command == DECODE_COMMAND_STOP)
@ -132,7 +132,7 @@ static void decodeStart(void)
continue;
if (plugin->file_decode != NULL) {
closeInputStream(&inStream);
input_stream_close(&inStream);
close_instream = false;
decoder.plugin = plugin;
ret = plugin->file_decode(&decoder,
@ -156,7 +156,7 @@ static void decodeStart(void)
stop:
if (close_instream)
closeInputStream(&inStream);
input_stream_close(&inStream);
stop_no_close:
dc.state = DECODE_STATE_STOP;
dc.command = DECODE_COMMAND_NONE;

View File

@ -22,59 +22,60 @@
#include "os_compat.h"
static int
inputStream_fileSeek(struct input_stream *is, long offset, int whence);
input_file_seek(struct input_stream *is, long offset, int whence);
static size_t
inputStream_fileRead(struct input_stream *is, void *ptr, size_t size);
input_file_read(struct input_stream *is, void *ptr, size_t size);
static int
inputStream_fileClose(struct input_stream *is);
input_file_close(struct input_stream *is);
static int
inputStream_fileAtEOF(struct input_stream *is);
input_file_eof(struct input_stream *is);
static int
inputStream_fileBuffer(struct input_stream *is);
input_file_buffer(struct input_stream *is);
int inputStream_fileOpen(struct input_stream *inStream, char *filename)
int
input_file_open(struct input_stream *is, char *filename)
{
FILE *fp;
fp = fopen(filename, "r");
if (!fp) {
inStream->error = errno;
is->error = errno;
return -1;
}
inStream->seekable = 1;
is->seekable = 1;
fseek(fp, 0, SEEK_END);
inStream->size = ftell(fp);
is->size = ftell(fp);
fseek(fp, 0, SEEK_SET);
#ifdef POSIX_FADV_SEQUENTIAL
posix_fadvise(fileno(fp), (off_t)0, inStream->size, POSIX_FADV_SEQUENTIAL);
posix_fadvise(fileno(fp), (off_t)0, is->size, POSIX_FADV_SEQUENTIAL);
#endif
inStream->data = fp;
inStream->seekFunc = inputStream_fileSeek;
inStream->closeFunc = inputStream_fileClose;
inStream->readFunc = inputStream_fileRead;
inStream->atEOFFunc = inputStream_fileAtEOF;
inStream->bufferFunc = inputStream_fileBuffer;
is->data = fp;
is->seekFunc = input_file_seek;
is->closeFunc = input_file_close;
is->readFunc = input_file_read;
is->atEOFFunc = input_file_eof;
is->bufferFunc = input_file_buffer;
inStream->ready = 1;
is->ready = 1;
return 0;
}
static int
inputStream_fileSeek(struct input_stream *inStream, long offset, int whence)
input_file_seek(struct input_stream *is, long offset, int whence)
{
if (fseek((FILE *) inStream->data, offset, whence) == 0) {
inStream->offset = ftell((FILE *) inStream->data);
if (fseek((FILE *) is->data, offset, whence) == 0) {
is->offset = ftell((FILE *) is->data);
} else {
inStream->error = errno;
is->error = errno;
return -1;
}
@ -82,27 +83,27 @@ inputStream_fileSeek(struct input_stream *inStream, long offset, int whence)
}
static size_t
inputStream_fileRead(struct input_stream *inStream, void *ptr, size_t size)
input_file_read(struct input_stream *is, void *ptr, size_t size)
{
size_t readSize;
readSize = fread(ptr, 1, size, (FILE *) inStream->data);
if (readSize <= 0 && ferror((FILE *) inStream->data)) {
inStream->error = errno;
DEBUG("inputStream_fileRead: error reading: %s\n",
strerror(inStream->error));
readSize = fread(ptr, 1, size, (FILE *) is->data);
if (readSize <= 0 && ferror((FILE *) is->data)) {
is->error = errno;
DEBUG("input_file_read: error reading: %s\n",
strerror(is->error));
}
inStream->offset = ftell((FILE *) inStream->data);
is->offset = ftell((FILE *) is->data);
return readSize;
}
static int
inputStream_fileClose(struct input_stream *inStream)
input_file_close(struct input_stream *is)
{
if (fclose((FILE *) inStream->data) < 0) {
inStream->error = errno;
if (fclose((FILE *) is->data) < 0) {
is->error = errno;
return -1;
}
@ -110,12 +111,12 @@ inputStream_fileClose(struct input_stream *inStream)
}
static int
inputStream_fileAtEOF(struct input_stream *inStream)
input_file_eof(struct input_stream *is)
{
if (feof((FILE *) inStream->data))
if (feof((FILE *) is->data))
return 1;
if (ferror((FILE *) inStream->data) && inStream->error != EINTR) {
if (ferror((FILE *) is->data) && is->error != EINTR) {
return 1;
}
@ -123,7 +124,7 @@ inputStream_fileAtEOF(struct input_stream *inStream)
}
static int
inputStream_fileBuffer(mpd_unused struct input_stream *inStream)
input_file_buffer(mpd_unused struct input_stream *is)
{
return 0;
}

View File

@ -21,6 +21,7 @@
#include "input_stream.h"
int inputStream_fileOpen(struct input_stream *inStream, char *filename);
int
input_file_open(struct input_stream *is, char *filename);
#endif

View File

@ -27,7 +27,7 @@
#include <stdlib.h>
void initInputStream(void)
void input_stream_global_init(void)
{
#ifdef HAVE_CURL
input_curl_global_init();
@ -41,57 +41,57 @@ void input_stream_global_finish(void)
#endif
}
int openInputStream(struct input_stream *inStream, char *url)
int input_stream_open(struct input_stream *is, char *url)
{
inStream->ready = 0;
inStream->offset = 0;
inStream->size = 0;
inStream->error = 0;
inStream->mime = NULL;
inStream->seekable = 0;
inStream->metaName = NULL;
inStream->metaTitle = NULL;
is->ready = 0;
is->offset = 0;
is->size = 0;
is->error = 0;
is->mime = NULL;
is->seekable = 0;
is->meta_name = NULL;
is->meta_title = NULL;
if (inputStream_fileOpen(inStream, url) == 0)
if (input_file_open(is, url) == 0)
return 0;
#ifdef HAVE_CURL
if (input_curl_open(inStream, url))
if (input_curl_open(is, url))
return 0;
#endif
return -1;
}
int seekInputStream(struct input_stream *inStream, long offset, int whence)
int input_stream_seek(struct input_stream *is, long offset, int whence)
{
return inStream->seekFunc(inStream, offset, whence);
return is->seekFunc(is, offset, whence);
}
size_t readFromInputStream(struct input_stream *inStream,
void *ptr, size_t size)
size_t
input_stream_read(struct input_stream *is, void *ptr, size_t size)
{
return inStream->readFunc(inStream, ptr, size);
return is->readFunc(is, ptr, size);
}
int closeInputStream(struct input_stream *inStream)
int input_stream_close(struct input_stream *is)
{
if (inStream->mime)
free(inStream->mime);
if (inStream->metaName)
free(inStream->metaName);
if (inStream->metaTitle)
free(inStream->metaTitle);
if (is->mime)
free(is->mime);
if (is->meta_name)
free(is->meta_name);
if (is->meta_title)
free(is->meta_title);
return inStream->closeFunc(inStream);
return is->closeFunc(is);
}
int inputStreamAtEOF(struct input_stream *inStream)
int input_stream_eof(struct input_stream *is)
{
return inStream->atEOFFunc(inStream);
return is->atEOFFunc(is);
}
int bufferInputStream(struct input_stream *inStream)
int input_stream_buffer(struct input_stream *is)
{
return inStream->bufferFunc(inStream);
return is->bufferFunc(is);
}

View File

@ -30,37 +30,33 @@ struct input_stream {
char *mime;
int seekable;
int (*seekFunc)(struct input_stream *inStream, long offset,
int whence);
size_t (*readFunc)(struct input_stream *inStream, void *ptr,
size_t size);
int (*closeFunc)(struct input_stream *inStream);
int (*atEOFFunc)(struct input_stream *inStream);
int (*bufferFunc)(struct input_stream *inStream);
int (*seekFunc)(struct input_stream *is, long offset, int whence);
size_t (*readFunc)(struct input_stream *is, void *ptr, size_t size);
int (*closeFunc)(struct input_stream *is);
int (*atEOFFunc)(struct input_stream *is);
int (*bufferFunc)(struct input_stream *is);
void *data;
char *metaName;
char *metaTitle;
char *meta_name;
char *meta_title;
};
void initInputStream(void);
void input_stream_global_init(void);
void input_stream_global_finish(void);
int isUrlSaneForInputStream(char *url);
/* if an error occurs for these 3 functions, then -1 is returned and errno
for the input stream is set */
int openInputStream(struct input_stream *inStream, char *url);
int seekInputStream(struct input_stream *inStream, long offset, int whence);
int closeInputStream(struct input_stream *inStream);
int inputStreamAtEOF(struct input_stream *inStream);
int input_stream_open(struct input_stream *is, char *url);
int input_stream_seek(struct input_stream *is, long offset, int whence);
int input_stream_close(struct input_stream *is);
int input_stream_eof(struct input_stream *is);
/* return value: -1 is error, 1 inidicates stuff was buffered, 0 means nothing
was buffered */
int bufferInputStream(struct input_stream *inStream);
int input_stream_buffer(struct input_stream *is);
size_t readFromInputStream(struct input_stream *inStream,
void *ptr, size_t size);
size_t
input_stream_read(struct input_stream *is, void *ptr, size_t size);
#endif

View File

@ -431,7 +431,7 @@ int main(int argc, char *argv[])
client_manager_init();
initReplayGainState();
initNormalization();
initInputStream();
input_stream_global_init();
daemonize(&options);