diff options
author | Max Kellermann <max@duempel.org> | 2009-01-15 19:57:57 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-01-15 19:57:57 +0100 |
commit | 15435b09affcd362cc047c54f6a3b052aa965889 (patch) | |
tree | bd38be4a2311c4f75ba2067abf677bb82db7d9c5 | |
parent | 8307dd3e873e7ed7c72ae26ee7d2a8ea505c3336 (diff) | |
download | mpd-15435b09affcd362cc047c54f6a3b052aa965889.tar.gz mpd-15435b09affcd362cc047c54f6a3b052aa965889.tar.xz mpd-15435b09affcd362cc047c54f6a3b052aa965889.zip |
flac: use bool instead of int
Diffstat (limited to '')
-rw-r--r-- | src/decoder/_flac_common.c | 30 | ||||
-rw-r--r-- | src/decoder/flac_plugin.c | 49 |
2 files changed, 37 insertions, 42 deletions
diff --git a/src/decoder/_flac_common.c b/src/decoder/_flac_common.c index 459c4606d..ddce994de 100644 --- a/src/decoder/_flac_common.c +++ b/src/decoder/_flac_common.c @@ -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 * diff --git a/src/decoder/flac_plugin.c b/src/decoder/flac_plugin.c index a13042cf3..edf268331 100644 --- a/src/decoder/flac_plugin.c +++ b/src/decoder/flac_plugin.c @@ -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) |