input_stream: use "bool" instead of "int"

For boolean values and success flags, use bool instead of integer (1/0
for true/false, 0/-1 for success/failure).
This commit is contained in:
Max Kellermann
2008-10-26 20:56:46 +01:00
parent 464b611772
commit 5c19776f2f
14 changed files with 55 additions and 49 deletions

View File

@@ -257,7 +257,7 @@ static float getAacFloatTotalTime(char *file)
struct input_stream inStream;
long bread;
if (input_stream_open(&inStream, file) < 0)
if (!input_stream_open(&inStream, file))
return -1;
initAacBuffer(&b, NULL, &inStream);
@@ -461,7 +461,7 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
if ((totalTime = getAacFloatTotalTime(path)) < 0)
return -1;
if (input_stream_open(&inStream, path) < 0)
if (!input_stream_open(&inStream, path))
return -1;
initAacBuffer(&b, mpd_decoder, &inStream);

View File

@@ -360,7 +360,7 @@ static struct tag *ffmpeg_tag(char *file)
int ret;
struct tag *tag = NULL;
if (input_stream_open(&input, file) < 0) {
if (!input_stream_open(&input, file)) {
ERROR("failed to open %s\n", file);
return NULL;
}

View File

@@ -52,9 +52,8 @@ static flac_seek_status flacSeek(mpd_unused const flac_decoder * flacDec,
{
FlacData *data = (FlacData *) fdata;
if (input_stream_seek(data->inStream, offset, SEEK_SET) < 0) {
if (!input_stream_seek(data->inStream, offset, SEEK_SET))
return flac_seek_status_error;
}
return flac_seek_status_ok;
}

View File

@@ -158,9 +158,8 @@ static void initMp3DecodeData(mp3DecodeData * data, struct decoder *decoder,
static int seekMp3InputBuffer(mp3DecodeData * data, long offset)
{
if (input_stream_seek(data->inStream, offset, SEEK_SET) < 0) {
if (!input_stream_seek(data->inStream, offset, SEEK_SET))
return -1;
}
mad_stream_buffer(&data->stream, data->readBuffer, 0);
(data->stream).error = 0;
@@ -757,7 +756,7 @@ static int getMp3TotalTime(char *file)
mp3DecodeData data;
int ret;
if (input_stream_open(&inStream, file) < 0)
if (!input_stream_open(&inStream, file))
return -1;
initMp3DecodeData(&data, NULL, &inStream);
if (decodeFirstFrame(&data, NULL, NULL) < 0)

View File

@@ -75,7 +75,8 @@ static uint32_t mp4_inputStreamReadCallback(void *inStream, void *buffer,
static uint32_t mp4_inputStreamSeekCallback(void *inStream, uint64_t position)
{
return input_stream_seek((struct input_stream *) inStream,
position, SEEK_SET);
position, SEEK_SET)
? 0 : -1;
}
static int
@@ -317,7 +318,7 @@ static struct tag *mp4DataDup(char *file, int *mp4MetadataFound)
*mp4MetadataFound = 0;
if (input_stream_open(&inStream, file) < 0) {
if (!input_stream_open(&inStream, file)) {
DEBUG("mp4DataDup: Failed to open file: %s\n", file);
return NULL;
}

View File

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

View File

@@ -64,9 +64,8 @@ static OggFLAC__SeekableStreamDecoderSeekStatus of_seek_cb(mpd_unused const
{
FlacData *data = (FlacData *) fdata;
if (input_stream_seek(data->inStream, offset, SEEK_SET) < 0) {
if (!input_stream_seek(data->inStream, offset, SEEK_SET))
return OggFLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR;
}
return OggFLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK;
}
@@ -261,7 +260,7 @@ static struct tag *oggflac_TagDup(char *file)
OggFLAC__SeekableStreamDecoder *decoder;
FlacData data;
if (input_stream_open(&inStream, file) < 0)
if (!input_stream_open(&inStream, file))
return NULL;
if (ogg_stream_type_detect(&inStream) != FLAC) {
input_stream_close(&inStream);

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 input_stream_seek(data->inStream, offset, whence);
return input_stream_seek(data->inStream, offset, whence) ? 0 : -1;
}
/* TODO: check Ogg libraries API and see if we can just not have this func */

View File

@@ -366,12 +366,14 @@ static uint32_t get_pos(void *id)
static int set_pos_abs(void *id, uint32_t pos)
{
return input_stream_seek(((InputStreamPlus *)id)->is, pos, SEEK_SET);
return input_stream_seek(((InputStreamPlus *)id)->is, pos, SEEK_SET)
? 0 : -1;
}
static int set_pos_rel(void *id, int32_t delta, int mode)
{
return input_stream_seek(((InputStreamPlus *)id)->is, delta, mode);
return input_stream_seek(((InputStreamPlus *)id)->is, delta, mode)
? 0 : -1;
}
static int push_back_byte(void *id, int c)
@@ -439,7 +441,7 @@ static int wavpack_open_wvc(struct decoder *decoder,
const char *utf8url;
size_t len;
char *wvc_url = NULL;
int ret;
bool ret;
/*
* As we use dc->utf8url, this function will be bad for
@@ -464,7 +466,7 @@ static int wavpack_open_wvc(struct decoder *decoder,
ret = input_stream_open(is_wvc, wvc_url);
free(wvc_url);
if (ret)
if (!ret)
return 0;
/*