From 1aa7cdd602ad7e7e2b2fe04a829a0d59c6c07f9a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 16 Mar 2019 13:55:19 +0100 Subject: [PATCH] decoder/opus: fix replay gain when there are no other tags The `tag_builder.empty()` check was wrong for the SubmitReplayGain() call. Closes https://github.com/MusicPlayerDaemon/MPD/issues/497 --- NEWS | 2 ++ src/decoder/plugins/OpusDecoderPlugin.cxx | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 41f9169a9..de0802376 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,8 @@ ver 0.21.6 (not yet released) - fix "list" with filter expression * input - cdio_paranoia: fix build failure due to missing #include +* decoder + - opus: fix replay gain when there are no other tags * playlist - flac: fix use-after-free bug * support abstract sockets on Linux diff --git a/src/decoder/plugins/OpusDecoderPlugin.cxx b/src/decoder/plugins/OpusDecoderPlugin.cxx index 542f71540..3b3c312af 100644 --- a/src/decoder/plugins/OpusDecoderPlugin.cxx +++ b/src/decoder/plugins/OpusDecoderPlugin.cxx @@ -208,10 +208,12 @@ MPDOpusDecoder::HandleTags(const ogg_packet &packet) TagBuilder tag_builder; AddTagHandler h(tag_builder); - if (ScanOpusTags(packet.packet, packet.bytes, &rgi, h) && - !tag_builder.empty()) { - client.SubmitReplayGain(&rgi); + if (!ScanOpusTags(packet.packet, packet.bytes, &rgi, h)) + return; + client.SubmitReplayGain(&rgi); + + if (!tag_builder.empty()) { Tag tag = tag_builder.Commit(); auto cmd = client.SubmitTag(input_stream, std::move(tag)); if (cmd != DecoderCommand::NONE)