flac: use bool instead of int

This commit is contained in:
Max Kellermann 2009-01-15 19:57:57 +01:00
parent 8307dd3e87
commit 15435b09af
2 changed files with 37 additions and 42 deletions

View File

@ -39,7 +39,7 @@ flac_data_init(struct flac_data *data, struct decoder * decoder,
data->tag = NULL;
}
static int
static bool
flac_find_float_comment(const FLAC__StreamMetadata *block,
const char *cmnt, float *fl)
{
@ -59,11 +59,11 @@ flac_find_float_comment(const FLAC__StreamMetadata *block,
*fl = (float)atof((char *)p);
p[len] = tmp;
return 1;
return true;
}
}
return 0;
return false;
}
/* replaygain stuff by AliasMrJones */
@ -71,21 +71,21 @@ static void
flac_parse_replay_gain(const FLAC__StreamMetadata *block,
struct flac_data *data)
{
int found = 0;
bool found;
if (data->replay_gain_info)
replay_gain_info_free(data->replay_gain_info);
data->replay_gain_info = replay_gain_info_new();
found |= flac_find_float_comment(block, "replaygain_album_gain",
&data->replay_gain_info->tuples[REPLAY_GAIN_ALBUM].gain);
found |= flac_find_float_comment(block, "replaygain_album_peak",
&data->replay_gain_info->tuples[REPLAY_GAIN_ALBUM].peak);
found |= flac_find_float_comment(block, "replaygain_track_gain",
&data->replay_gain_info->tuples[REPLAY_GAIN_TRACK].gain);
found |= flac_find_float_comment(block, "replaygain_track_peak",
&data->replay_gain_info->tuples[REPLAY_GAIN_TRACK].peak);
found = flac_find_float_comment(block, "replaygain_album_gain",
&data->replay_gain_info->tuples[REPLAY_GAIN_ALBUM].gain) ||
flac_find_float_comment(block, "replaygain_album_peak",
&data->replay_gain_info->tuples[REPLAY_GAIN_ALBUM].peak) ||
flac_find_float_comment(block, "replaygain_track_gain",
&data->replay_gain_info->tuples[REPLAY_GAIN_TRACK].gain) ||
flac_find_float_comment(block, "replaygain_track_peak",
&data->replay_gain_info->tuples[REPLAY_GAIN_TRACK].peak);
if (!found) {
replay_gain_info_free(data->replay_gain_info);
@ -98,7 +98,7 @@ flac_parse_replay_gain(const FLAC__StreamMetadata *block,
static const char *VORBIS_COMMENT_TRACK_KEY = "tracknumber";
static const char *VORBIS_COMMENT_DISC_KEY = "discnumber";
static unsigned int
static bool
flac_copy_vorbis_comment(const
FLAC__StreamMetadata_VorbisComment_Entry * entry,
enum tag_type type,
@ -129,10 +129,10 @@ flac_copy_vorbis_comment(const
tag_add_item_n(*tag, type,
(char *)(entry->entry + slen + 1), vlen);
return 1;
return true;
}
return 0;
return false;
}
struct tag *

View File

@ -136,34 +136,29 @@ static void flacPrintErroredState(FLAC__SeekableStreamDecoderState state)
g_warning("%s\n", str);
}
static int flac_init(FLAC__SeekableStreamDecoder *dec,
FLAC__SeekableStreamDecoderReadCallback read_cb,
FLAC__SeekableStreamDecoderSeekCallback seek_cb,
FLAC__SeekableStreamDecoderTellCallback tell_cb,
FLAC__SeekableStreamDecoderLengthCallback length_cb,
FLAC__SeekableStreamDecoderEofCallback eof_cb,
FLAC__SeekableStreamDecoderWriteCallback write_cb,
FLAC__SeekableStreamDecoderMetadataCallback metadata_cb,
FLAC__SeekableStreamDecoderErrorCallback error_cb,
void *data)
static bool
flac_init(FLAC__SeekableStreamDecoder *dec,
FLAC__SeekableStreamDecoderReadCallback read_cb,
FLAC__SeekableStreamDecoderSeekCallback seek_cb,
FLAC__SeekableStreamDecoderTellCallback tell_cb,
FLAC__SeekableStreamDecoderLengthCallback length_cb,
FLAC__SeekableStreamDecoderEofCallback eof_cb,
FLAC__SeekableStreamDecoderWriteCallback write_cb,
FLAC__SeekableStreamDecoderMetadataCallback metadata_cb,
FLAC__SeekableStreamDecoderErrorCallback error_cb,
void *data)
{
int s = 1;
s &= FLAC__seekable_stream_decoder_set_read_callback(dec, read_cb);
s &= FLAC__seekable_stream_decoder_set_seek_callback(dec, seek_cb);
s &= FLAC__seekable_stream_decoder_set_tell_callback(dec, tell_cb);
s &= FLAC__seekable_stream_decoder_set_length_callback(dec, length_cb);
s &= FLAC__seekable_stream_decoder_set_eof_callback(dec, eof_cb);
s &= FLAC__seekable_stream_decoder_set_write_callback(dec, write_cb);
s &= FLAC__seekable_stream_decoder_set_metadata_callback(dec,
metadata_cb);
s &= FLAC__seekable_stream_decoder_set_metadata_respond(dec,
FLAC__METADATA_TYPE_VORBIS_COMMENT);
s &= FLAC__seekable_stream_decoder_set_error_callback(dec, error_cb);
s &= FLAC__seekable_stream_decoder_set_client_data(dec, data);
if (!s || (FLAC__seekable_stream_decoder_init(dec) !=
FLAC__SEEKABLE_STREAM_DECODER_OK))
return 0;
return 1;
return FLAC__seekable_stream_decoder_set_read_callback(dec, read_cb) &&
FLAC__seekable_stream_decoder_set_seek_callback(dec, seek_cb) &&
FLAC__seekable_stream_decoder_set_tell_callback(dec, tell_cb) &&
FLAC__seekable_stream_decoder_set_length_callback(dec, length_cb) &&
FLAC__seekable_stream_decoder_set_eof_callback(dec, eof_cb) &&
FLAC__seekable_stream_decoder_set_write_callback(dec, write_cb) &&
FLAC__seekable_stream_decoder_set_metadata_callback(dec, metadata_cb) &&
FLAC__seekable_stream_decoder_set_metadata_respond(dec, FLAC__METADATA_TYPE_VORBIS_COMMENT) &&
FLAC__seekable_stream_decoder_set_error_callback(dec, error_cb) &&
FLAC__seekable_stream_decoder_set_client_data(dec, data) &&
FLAC__seekable_stream_decoder_init(dec) == FLAC__SEEKABLE_STREAM_DECODER_OK;
}
#else /* FLAC_API_VERSION_CURRENT >= 7 */
static void flacPrintErroredState(FLAC__StreamDecoderState state)