diff options
author | Max Kellermann <max@duempel.org> | 2009-03-01 14:07:23 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-03-01 14:07:23 +0100 |
commit | ba3a8474b6b3ef1355cf7173de2622adc34fce2e (patch) | |
tree | 5b01875ef08e4f529783e9e24bf5ee9844a14f4e /src/decoder/flac_plugin.c | |
parent | 92db09fdf8d672fa6c78e726102ad66145d076f4 (diff) | |
download | mpd-ba3a8474b6b3ef1355cf7173de2622adc34fce2e.tar.gz mpd-ba3a8474b6b3ef1355cf7173de2622adc34fce2e.tar.xz mpd-ba3a8474b6b3ef1355cf7173de2622adc34fce2e.zip |
flac: parse stream tags
Parse the vorbis comments in libflac's metadata_callback and pass them
as tag struct to the decoder API.
Diffstat (limited to 'src/decoder/flac_plugin.c')
-rw-r--r-- | src/decoder/flac_plugin.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/decoder/flac_plugin.c b/src/decoder/flac_plugin.c index ce056d298..ec9495fda 100644 --- a/src/decoder/flac_plugin.c +++ b/src/decoder/flac_plugin.c @@ -292,6 +292,7 @@ flac_decode_internal(struct decoder * decoder, { flac_decoder *flac_dec; struct flac_data data; + enum decoder_command cmd; const char *err = NULL; if (!(flac_dec = flac_new())) @@ -326,6 +327,8 @@ flac_decode_internal(struct decoder * decoder, } } + data.tag = tag_new(); + if (!flac_process_metadata(flac_dec)) { err = "problem reading metadata"; goto fail; @@ -343,9 +346,17 @@ flac_decode_internal(struct decoder * decoder, input_stream->seekable, data.total_time); while (true) { + if (!tag_is_empty(data.tag)) { + cmd = decoder_tag(decoder, input_stream, data.tag); + tag_free(data.tag); + data.tag = tag_new(); + } else + cmd = decoder_get_command(decoder); + if (!flac_process_single(flac_dec)) break; - if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) { + + if (cmd == DECODE_COMMAND_SEEK) { FLAC__uint64 seek_sample = decoder_seek_where(decoder) * data.audio_format.sample_rate + 0.5; if (flac_seek_absolute(flac_dec, seek_sample)) { @@ -358,7 +369,7 @@ flac_decode_internal(struct decoder * decoder, } else if (flac_get_state(flac_dec) == flac_decoder_eof) break; } - if (decoder_get_command(decoder) != DECODE_COMMAND_STOP) { + if (cmd != DECODE_COMMAND_STOP) { flacPrintErroredState(flac_get_state(flac_dec)); flac_finish(flac_dec); } @@ -367,6 +378,8 @@ fail: if (data.replay_gain_info) replay_gain_info_free(data.replay_gain_info); + tag_free(data.tag); + if (flac_dec) flac_delete(flac_dec); |