On Wed, Dec 05, 2012 at 16:51:54 -0500, Ben Boeckel wrote:
> @@ -524,31 +532,7 @@ decoder_replay_gain(struct decoder *decoder,
>       float return_db = 0;
>       assert(decoder != NULL);
>  
> -     if (replay_gain_info != NULL) {
> -             static unsigned serial;
> -             if (++serial == 0)
> -                     serial = 1;
> -
> -             if (REPLAY_GAIN_OFF != replay_gain_mode) {
> -                     return_db = 20.0 * log10f(
> -                             replay_gain_tuple_scale(
> -                                     
> &replay_gain_info->tuples[replay_gain_get_real_mode()],
> -                                     replay_gain_preamp, 
> replay_gain_missing_preamp,
> -                                     replay_gain_limit));
> -             }
> -
> -             decoder->replay_gain_info = *replay_gain_info;
> -             decoder->replay_gain_serial = serial;
> -
> -             if (decoder->chunk != NULL) {
> -                     /* flush the current chunk because the new
> -                        replay gain values affect the following
> -                        samples */
> -                     decoder_flush_chunk(decoder);

So this line here was the issue. This flushes the chunk into the stream
with just the tag and no data on it. Combined with this code right
before the chunk leaves for the sources:

static bool
play_chunk(player_control &pc,
           Song *song, struct music_chunk *chunk,
           MusicBuffer &buffer,
           const AudioFormat format,
           Error &error)
{
        assert(chunk->CheckFormat(format));

        if (chunk->tag != nullptr)
                update_song_tag(song, *chunk->tag);

        if (chunk->length == 0) {
                buffer.Return(chunk);
                return true;
        }

        pc.Lock();
        pc.bit_rate = chunk->bit_rate;
        pc.Unlock();

        /* send the chunk to the audio outputs */

        if (!audio_output_all_play(chunk, error))
                return false;

        pc.total_play_time += (double)chunk->length /
                format.GetTimeToSize();
        return true;
}

the tag chunk is dropped because chunk->length is 0 for it. A patch
which fixes the issue is attached.

> -                     g_cond_signal(decoder->dc->client_cond);
> -             }
> -     } else
> -             decoder->replay_gain_serial = 0;
> +     replay_gain_state_set_info(decoder->replay_gain, replay_gain_info);

--Ben
>From 9f7690767838052661160de5a30d28acc6ef3473 Mon Sep 17 00:00:00 2001
From: Ben Boeckel <maths...@gmail.com>
Date: Thu, 10 Oct 2013 23:00:52 -0400
Subject: [PATCH] PlayerThread: Only drop 0 length packets without tags

Fixes a regression from 752dfb3d95482c562e5d24c6ea839c4815de9a6d which
caused the current chunk to be flushed as soon as new replaygain
information was found. If this occurs on a tag chunk, it has no data
(length 0) and is then skipped before pushing it to all of the outputs.

This change allows 0-length chunks through if they contain a tag and
they are now appearing in mplayer and mpv properly.
---
 src/PlayerThread.cxx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/PlayerThread.cxx b/src/PlayerThread.cxx
index 9ad37ea..534a24e 100644
--- a/src/PlayerThread.cxx
+++ b/src/PlayerThread.cxx
@@ -726,7 +726,7 @@ play_chunk(player_control &pc,
        if (chunk->tag != nullptr)
                update_song_tag(song, *chunk->tag);
 
-       if (chunk->length == 0) {
+       if (chunk->length == 0 && chunk->tag == nullptr) {
                buffer.Return(chunk);
                return true;
        }
-- 
1.8.3.1

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
_______________________________________________
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team

Reply via email to