diff options
author | Max Kellermann <max@duempel.org> | 2010-01-05 21:46:12 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2010-01-06 09:50:34 +0100 |
commit | 550c9319e9f6e68a7f7cc72054de657e6e921072 (patch) | |
tree | 017e991cf5065ef62e08fbf2ecde05b774e78602 /src/decoder/_flac_common.c | |
parent | ae9c02b3a854cd8520eee696cdd68d0b0c32923f (diff) | |
download | mpd-550c9319e9f6e68a7f7cc72054de657e6e921072.tar.gz mpd-550c9319e9f6e68a7f7cc72054de657e6e921072.tar.xz mpd-550c9319e9f6e68a7f7cc72054de657e6e921072.zip |
decoder/flac: moved decoder initialization to _flac_common.c
Invoke decoder_initialized() in the libFLAC metadata callback. This
merges code from the FLAC and the OggFLAC decoder plugin into the
common library.
Diffstat (limited to '')
-rw-r--r-- | src/decoder/_flac_common.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/src/decoder/_flac_common.c b/src/decoder/_flac_common.c index 477a4ba10..2081f7b09 100644 --- a/src/decoder/_flac_common.c +++ b/src/decoder/_flac_common.c @@ -38,7 +38,8 @@ flac_data_init(struct flac_data *data, struct decoder * decoder, pcm_buffer_init(&data->buffer); data->unsupported = false; - data->have_stream_info = false; + data->initialized = false; + data->total_frames = 0; data->first_frame = 0; data->next_frame = 0; @@ -78,27 +79,11 @@ flac_sample_format(const FLAC__StreamMetadata_StreamInfo *si) } } -bool -flac_data_get_audio_format(struct flac_data *data, - struct audio_format *audio_format) -{ - if (data->unsupported) - return false; - - if (!data->have_stream_info) { - g_warning("no STREAMINFO packet found"); - return false; - } - - *audio_format = data->audio_format; - return true; -} - static void flac_got_stream_info(struct flac_data *data, const FLAC__StreamMetadata_StreamInfo *stream_info) { - if (data->have_stream_info || data->unsupported) + if (data->initialized || data->unsupported) return; GError *error = NULL; @@ -114,8 +99,15 @@ flac_got_stream_info(struct flac_data *data, data->frame_size = audio_format_frame_size(&data->audio_format); - data->total_frames = stream_info->total_samples; - data->have_stream_info = true; + if (data->total_frames == 0) + data->total_frames = stream_info->total_samples; + + decoder_initialized(data->decoder, &data->audio_format, + data->input_stream->seekable, + (float)data->total_frames / + (float)data->audio_format.sample_rate); + + data->initialized = true; } void flac_metadata_common_cb(const FLAC__StreamMetadata * block, |