Commit a0d43dd8 authored by Max Kellermann's avatar Max Kellermann

decoder/opus: submit output_gain even if there is no OpusTags packet

parent 1db533c8
ver 0.22.1 (not yet released) ver 0.22.1 (not yet released)
* decoder
- opus: apply the OpusHead output gain even if there is no EBU R128 tag
* output * output
- alsa: don't deadlock when the ALSA driver is buggy - alsa: don't deadlock when the ALSA driver is buggy
- jack, pulse: reduce the delay when stopping or pausing playback - jack, pulse: reduce the delay when stopping or pausing playback
......
...@@ -123,6 +123,14 @@ class MPDOpusDecoder final : public OggDecoder { ...@@ -123,6 +123,14 @@ class MPDOpusDecoder final : public OggDecoder {
*/ */
ogg_int64_t granulepos; ogg_int64_t granulepos;
/**
* Was DecoderClient::SubmitReplayGain() called? We need to
* keep track of this, because it will usually be called by
* HandleTags(), but if there is no OpusTags packet, we need
* to submit our #output_gain value from the OpusHead.
*/
bool submitted_replay_gain = false;
public: public:
explicit MPDOpusDecoder(DecoderReader &reader) explicit MPDOpusDecoder(DecoderReader &reader)
:OggDecoder(reader) {} :OggDecoder(reader) {}
...@@ -269,6 +277,7 @@ MPDOpusDecoder::HandleTags(const ogg_packet &packet) ...@@ -269,6 +277,7 @@ MPDOpusDecoder::HandleTags(const ogg_packet &packet)
return; return;
client.SubmitReplayGain(&rgi); client.SubmitReplayGain(&rgi);
submitted_replay_gain = true;
if (!tag_builder.empty()) { if (!tag_builder.empty()) {
Tag tag = tag_builder.Commit(); Tag tag = tag_builder.Commit();
...@@ -283,6 +292,18 @@ MPDOpusDecoder::HandleAudio(const ogg_packet &packet) ...@@ -283,6 +292,18 @@ MPDOpusDecoder::HandleAudio(const ogg_packet &packet)
{ {
assert(opus_decoder != nullptr); assert(opus_decoder != nullptr);
if (!submitted_replay_gain) {
/* if we didn't see an OpusTags packet with EBU R128
values, we still need to apply the output gain
value from the OpusHead packet; submit it as "track
gain" value */
ReplayGainInfo rgi;
rgi.Clear();
rgi.track.gain = EbuR128ToReplayGain(output_gain);
client.SubmitReplayGain(&rgi);
submitted_replay_gain = true;
}
int nframes = opus_decode(opus_decoder, int nframes = opus_decode(opus_decoder,
(const unsigned char*)packet.packet, (const unsigned char*)packet.packet,
packet.bytes, packet.bytes,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment