flac: use bool instead of int
This commit is contained in:
parent
8307dd3e87
commit
15435b09af
@ -39,7 +39,7 @@ flac_data_init(struct flac_data *data, struct decoder * decoder,
|
|||||||
data->tag = NULL;
|
data->tag = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static bool
|
||||||
flac_find_float_comment(const FLAC__StreamMetadata *block,
|
flac_find_float_comment(const FLAC__StreamMetadata *block,
|
||||||
const char *cmnt, float *fl)
|
const char *cmnt, float *fl)
|
||||||
{
|
{
|
||||||
@ -59,11 +59,11 @@ flac_find_float_comment(const FLAC__StreamMetadata *block,
|
|||||||
*fl = (float)atof((char *)p);
|
*fl = (float)atof((char *)p);
|
||||||
p[len] = tmp;
|
p[len] = tmp;
|
||||||
|
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* replaygain stuff by AliasMrJones */
|
/* replaygain stuff by AliasMrJones */
|
||||||
@ -71,21 +71,21 @@ static void
|
|||||||
flac_parse_replay_gain(const FLAC__StreamMetadata *block,
|
flac_parse_replay_gain(const FLAC__StreamMetadata *block,
|
||||||
struct flac_data *data)
|
struct flac_data *data)
|
||||||
{
|
{
|
||||||
int found = 0;
|
bool found;
|
||||||
|
|
||||||
if (data->replay_gain_info)
|
if (data->replay_gain_info)
|
||||||
replay_gain_info_free(data->replay_gain_info);
|
replay_gain_info_free(data->replay_gain_info);
|
||||||
|
|
||||||
data->replay_gain_info = replay_gain_info_new();
|
data->replay_gain_info = replay_gain_info_new();
|
||||||
|
|
||||||
found |= flac_find_float_comment(block, "replaygain_album_gain",
|
found = flac_find_float_comment(block, "replaygain_album_gain",
|
||||||
&data->replay_gain_info->tuples[REPLAY_GAIN_ALBUM].gain);
|
&data->replay_gain_info->tuples[REPLAY_GAIN_ALBUM].gain) ||
|
||||||
found |= flac_find_float_comment(block, "replaygain_album_peak",
|
flac_find_float_comment(block, "replaygain_album_peak",
|
||||||
&data->replay_gain_info->tuples[REPLAY_GAIN_ALBUM].peak);
|
&data->replay_gain_info->tuples[REPLAY_GAIN_ALBUM].peak) ||
|
||||||
found |= flac_find_float_comment(block, "replaygain_track_gain",
|
flac_find_float_comment(block, "replaygain_track_gain",
|
||||||
&data->replay_gain_info->tuples[REPLAY_GAIN_TRACK].gain);
|
&data->replay_gain_info->tuples[REPLAY_GAIN_TRACK].gain) ||
|
||||||
found |= flac_find_float_comment(block, "replaygain_track_peak",
|
flac_find_float_comment(block, "replaygain_track_peak",
|
||||||
&data->replay_gain_info->tuples[REPLAY_GAIN_TRACK].peak);
|
&data->replay_gain_info->tuples[REPLAY_GAIN_TRACK].peak);
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
replay_gain_info_free(data->replay_gain_info);
|
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_TRACK_KEY = "tracknumber";
|
||||||
static const char *VORBIS_COMMENT_DISC_KEY = "discnumber";
|
static const char *VORBIS_COMMENT_DISC_KEY = "discnumber";
|
||||||
|
|
||||||
static unsigned int
|
static bool
|
||||||
flac_copy_vorbis_comment(const
|
flac_copy_vorbis_comment(const
|
||||||
FLAC__StreamMetadata_VorbisComment_Entry * entry,
|
FLAC__StreamMetadata_VorbisComment_Entry * entry,
|
||||||
enum tag_type type,
|
enum tag_type type,
|
||||||
@ -129,10 +129,10 @@ flac_copy_vorbis_comment(const
|
|||||||
tag_add_item_n(*tag, type,
|
tag_add_item_n(*tag, type,
|
||||||
(char *)(entry->entry + slen + 1), vlen);
|
(char *)(entry->entry + slen + 1), vlen);
|
||||||
|
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tag *
|
struct tag *
|
||||||
|
@ -136,34 +136,29 @@ static void flacPrintErroredState(FLAC__SeekableStreamDecoderState state)
|
|||||||
g_warning("%s\n", str);
|
g_warning("%s\n", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int flac_init(FLAC__SeekableStreamDecoder *dec,
|
static bool
|
||||||
FLAC__SeekableStreamDecoderReadCallback read_cb,
|
flac_init(FLAC__SeekableStreamDecoder *dec,
|
||||||
FLAC__SeekableStreamDecoderSeekCallback seek_cb,
|
FLAC__SeekableStreamDecoderReadCallback read_cb,
|
||||||
FLAC__SeekableStreamDecoderTellCallback tell_cb,
|
FLAC__SeekableStreamDecoderSeekCallback seek_cb,
|
||||||
FLAC__SeekableStreamDecoderLengthCallback length_cb,
|
FLAC__SeekableStreamDecoderTellCallback tell_cb,
|
||||||
FLAC__SeekableStreamDecoderEofCallback eof_cb,
|
FLAC__SeekableStreamDecoderLengthCallback length_cb,
|
||||||
FLAC__SeekableStreamDecoderWriteCallback write_cb,
|
FLAC__SeekableStreamDecoderEofCallback eof_cb,
|
||||||
FLAC__SeekableStreamDecoderMetadataCallback metadata_cb,
|
FLAC__SeekableStreamDecoderWriteCallback write_cb,
|
||||||
FLAC__SeekableStreamDecoderErrorCallback error_cb,
|
FLAC__SeekableStreamDecoderMetadataCallback metadata_cb,
|
||||||
void *data)
|
FLAC__SeekableStreamDecoderErrorCallback error_cb,
|
||||||
|
void *data)
|
||||||
{
|
{
|
||||||
int s = 1;
|
return FLAC__seekable_stream_decoder_set_read_callback(dec, read_cb) &&
|
||||||
s &= FLAC__seekable_stream_decoder_set_read_callback(dec, read_cb);
|
FLAC__seekable_stream_decoder_set_seek_callback(dec, seek_cb) &&
|
||||||
s &= FLAC__seekable_stream_decoder_set_seek_callback(dec, seek_cb);
|
FLAC__seekable_stream_decoder_set_tell_callback(dec, tell_cb) &&
|
||||||
s &= FLAC__seekable_stream_decoder_set_tell_callback(dec, tell_cb);
|
FLAC__seekable_stream_decoder_set_length_callback(dec, length_cb) &&
|
||||||
s &= FLAC__seekable_stream_decoder_set_length_callback(dec, length_cb);
|
FLAC__seekable_stream_decoder_set_eof_callback(dec, eof_cb) &&
|
||||||
s &= FLAC__seekable_stream_decoder_set_eof_callback(dec, eof_cb);
|
FLAC__seekable_stream_decoder_set_write_callback(dec, write_cb) &&
|
||||||
s &= FLAC__seekable_stream_decoder_set_write_callback(dec, write_cb);
|
FLAC__seekable_stream_decoder_set_metadata_callback(dec, metadata_cb) &&
|
||||||
s &= FLAC__seekable_stream_decoder_set_metadata_callback(dec,
|
FLAC__seekable_stream_decoder_set_metadata_respond(dec, FLAC__METADATA_TYPE_VORBIS_COMMENT) &&
|
||||||
metadata_cb);
|
FLAC__seekable_stream_decoder_set_error_callback(dec, error_cb) &&
|
||||||
s &= FLAC__seekable_stream_decoder_set_metadata_respond(dec,
|
FLAC__seekable_stream_decoder_set_client_data(dec, data) &&
|
||||||
FLAC__METADATA_TYPE_VORBIS_COMMENT);
|
FLAC__seekable_stream_decoder_init(dec) == FLAC__SEEKABLE_STREAM_DECODER_OK;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
#else /* FLAC_API_VERSION_CURRENT >= 7 */
|
#else /* FLAC_API_VERSION_CURRENT >= 7 */
|
||||||
static void flacPrintErroredState(FLAC__StreamDecoderState state)
|
static void flacPrintErroredState(FLAC__StreamDecoderState state)
|
||||||
|
Loading…
Reference in New Issue
Block a user