[hatari-devel] Slow sound buffer

npomarede at corp.free.fr npomarede at corp.free.fr
Mon May 10 22:35:06 CEST 2010


On Mon, 10 May 2010, David Savinkoff wrote:

> Hi,
> 
> I was using TOS206us.IMG (60 Hz)

Hello,
I understand better why we had such differences :)

> the results below are for
> TOS206uk.IMG (50 Hz) "desiredAudioSpec.samples = 0"
> ALSA is used on my system.

I also made some tests with samples = 0 and I get more different results 
than yours.

For example, at 44100, I get :
SoundBufferSize 940 SAMPLES_PER_FRAME 882 nGeneratedSamples 1822 , ActiveSndBufIdx 3409
-> same than when I use desiredAudioSpec.samples=1024

but for 32000 Hz, I get :
SoundBufferSize 2048 SAMPLES_PER_FRAME 640 nGeneratedSamples 2688 , ActiveSndBufIdx 13961
-> less data to send than 44100, but bigger SoundBufferSize ?!

I have the feeling that if the sound card has native support for the 
required freq, then it computes an optimized values, else you get a power 
of 2 buffer size.


> 44100 Hz
> SoundBufferSize 2048 SAMPLES_PER_FRAME 882 nGeneratedSamples 2930 , ActiveSndBufIdx 7026
SoundBufferSize 940 SAMPLES_PER_FRAME 882 nGeneratedSamples 1822 , ActiveSndBufIdx 3409

> 32000 Hz
> SoundBufferSize 2048 SAMPLES_PER_FRAME 640 nGeneratedSamples 2688 , ActiveSndBufIdx 8832
SoundBufferSize 2048 SAMPLES_PER_FRAME 640 nGeneratedSamples 2688 , ActiveSndBufIdx 13961

> 
> 25033 Hz
> SoundBufferSize 2048 SAMPLES_PER_FRAME 501 nGeneratedSamples 2549 , ActiveSndBufIdx 501
SoundBufferSize 801 SAMPLES_PER_FRAME 501 nGeneratedSamples 1302 , ActiveSndBufIdx 14367

> 
> 22050 Hz
> SoundBufferSize 1024 SAMPLES_PER_FRAME 441 nGeneratedSamples 1465 , ActiveSndBufIdx 11705
SoundBufferSize 705 SAMPLES_PER_FRAME 441 nGeneratedSamples 1146 , ActiveSndBufIdx 10626

> 
> 16000 Hz
> SoundBufferSize 1024 SAMPLES_PER_FRAME 320 nGeneratedSamples 1344 , ActiveSndBufIdx 11584
SoundBufferSize 1024 SAMPLES_PER_FRAME 320 nGeneratedSamples 1344 , ActiveSndBufIdx 6351

> 
> SDL works as advertised, but SoundBufferSize is too big.

By "advertised", do you mean you don't have delay at 11025 Hz when setting 
"desiredAudioSpec.samples = 0" ?

> Maybe hatari can calculate SoundBufferSize

I had a look at SDL's audio part. The size returned by SDL_OpenAudio is 
directly computed by the alsa subsytem, which in turn gets its values by 
calling the corresponding functions of the driver for the audio card.

In your case, the computed values are much bigger than what I get.

What do you see as a card/chip when you run alsamixer in a terminal ?
(mine is Shuttle SN25P / VIA Technologies VIA1617A )

I was thinking about integrating SDL's code into hatari to compute 
desiredAudioSpec.samples for a 46 ms delay, but I need to be sure it's not 
overriden by the alsa driver.
If you set desiredAudioSpec.samples to 508 (=46 ms at 11 kHz) and then run 
hatari at freq 11025, what output do you get in stderr ?

Also, could you try to install sdl 1.2.14 to see if things change ?

Thanks


Nicolas




More information about the hatari-devel mailing list