[MPlayer-dev-eng] Possible bug when sample rate changes mid-stream

Paul Kelly paul at stjohnspoint.co.uk
Mon Oct 7 22:53:33 CEST 2013


Hello mplayer developers,
I am experiencing a problem with mplayer when playing MP3 audio in which 
the sample rate changes during playback. The problem shows itself in 
particular with some internet radio stations which change from 22050 Hz to 
44100 Hz mid-stream without any interruption - mplayer will play such a 
stream at half speed after the change.

I have traced the problem to the setup_format() function in 
libmpcodecs/ad_ffmpeg.c: the FFmpeg/libavcodec MP3 decoder correctly 
detects the change in sample rate, but setup_format() then overwrites
this changed value with an old value. This means that the change isn't 
detected, and the audio ends up being played at the wrong speed.

The patch below fixes the problem for me, but I'm not sure what the intent 
of the line of code I've removed is, so I would appreciate somebody 
verifying if this is a good way of fixing the problem, or whether I 
should be looking somewhere else.

Thanks in advance for your consideration,
Best regards,

Paul Kelly


--- libmpcodecs/ad_ffmpeg.c~	2013-10-07 21:30:40.914974196 +0200
+++ libmpcodecs/ad_ffmpeg.c	2013-10-07 22:32:30.325368173 +0200
@@ -68,8 +68,7 @@
          if (lavc_context->codec_id == AV_CODEC_ID_AAC &&
              samplerate == 2*sh_audio->wf->nSamplesPerSec) {
              broken_srate = 1;
-        } else if (sh_audio->wf->nSamplesPerSec)
-            samplerate=sh_audio->wf->nSamplesPerSec;
+        }
      }
      if (lavc_context->channels != sh_audio->channels ||
          samplerate != sh_audio->samplerate ||


More information about the MPlayer-dev-eng mailing list