SDL audio playback speed changes randomly!

Hi everybody,

I’ve beed trying to get SMPEG + SDL audio to play mp3 stream correctly
in debian linux (sarge) with no luck…

Currently I’m decoding the whole the mp3 to memory as fixed 16bit 44100
mono sound (yes, this actually what I want to do). I then just memcpy
the data from sound buffer to SDL buffer in audio callback.

Everything works almost as expected. Only problem is that when playing
the sound with 44100 samples/second it seems to be playing a bit too
fast (not double speed), even though it was decoded from mp3 stream as
44100. What’s even more mysterious is that the playback speed seems to
be varying randomly during playback!

Has anyone ever had similiar problems? I have really run out of ideas
here ;(

I’m pretty sure that the sound data in buffer is ok. I have also tried
to change the SDL audio output devices (with environment variables), but
the same problem occurs with all of them. BTW, I’m using alsa drivers
for via82xx sound card. I got no problems with players like XMMS.

  • Mikko

Hi everybody,

I’ve beed trying to get SMPEG + SDL audio to play mp3 stream correctly
in debian linux (sarge) with no luck…

Currently I’m decoding the whole the mp3 to memory as fixed 16bit 44100
mono sound (yes, this actually what I want to do). I then just memcpy
the data from sound buffer to SDL buffer in audio callback.

Everything works almost as expected. Only problem is that when playing
the sound with 44100 samples/second it seems to be playing a bit too
fast (not double speed), even though it was decoded from mp3 stream as
44100. What’s even more mysterious is that the playback speed seems to
be varying randomly during playback!

Has anyone ever had similiar problems? I have really run out of ideas
here ;(

I’m pretty sure that the sound data in buffer is ok. I have also tried
to change the SDL audio output devices (with environment variables), but
the same problem occurs with all of them. BTW, I’m using alsa drivers
for via82xx sound card. I got no problems with players like XMMS.

Hi,

Try the following :
export SDL_DSP_NOSELECT=1

It seems that the via82xx driver is buggy, and SDL doesn’t detect it (anyone has an idea how we could find this and automate this workaround ?).

Stephane

Stephane Marchesin wrote:

Hi everybody,

I’ve beed trying to get SMPEG + SDL audio to play mp3 stream correctly
in debian linux (sarge) with no luck…

Currently I’m decoding the whole the mp3 to memory as fixed 16bit 44100
mono sound (yes, this actually what I want to do). I then just memcpy
the data from sound buffer to SDL buffer in audio callback.

Everything works almost as expected. Only problem is that when playing
the sound with 44100 samples/second it seems to be playing a bit too
fast (not double speed), even though it was decoded from mp3 stream as
44100. What’s even more mysterious is that the playback speed seems to
be varying randomly during playback!

Has anyone ever had similiar problems? I have really run out of ideas
here ;(

I’m pretty sure that the sound data in buffer is ok. I have also tried
to change the SDL audio output devices (with environment variables), but
the same problem occurs with all of them. BTW, I’m using alsa drivers
for via82xx sound card. I got no problems with players like XMMS.

Hi,

Try the following :
export SDL_DSP_NOSELECT=1

It seems that the via82xx driver is buggy, and SDL doesn’t detect it (anyone has an idea how we could find this and automate this workaround ?).

Stephane

Thanks a lot! That solved my problem.

  • Mikko