trident (Hoontech 4d Wave NX) dropouts with small buffersize.
Hello,
I use snd-trident with OSS emulation to access my soundcard. Music plays nicely, xmms and the like, but after alsa-0.90 or so the linux games began sounding distorted (like tuxracer, frozen-bubbles, mirrormagic, all SDL-games that my step-son likes...). Now I done some more tests to find out where it comes from:
The games use /dev/dsp, and /proc/asound/card0/pcm0p/sub0/hw_params says:
access: RW_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 22050 (22050/1)period_size: 512buffer_size: 1024tick_time: 10000
well, you hear drop outs, or even bits of sound repeated, sounds weird ( this doesn't happen with the standard OSS trident driver, BTW) I guess the game people want the buffer size small for low latency... Seems it is loosing some interrupts or so...
With xmms, buffer_size is 16384, and all is well...
Well, maybe anyone here on this list has an idea what has happened in the alsa drivers after 0.90 to trigger this bug.
I'm running debian testing,
alsa-source-1.0.5a-3
kernel 2.4.26
on a dual celeron 300.
Well, maybe this report can be helpful in further development of ALSA...
best regards,
Oliver Freyd
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
At Tue, 5 Oct 2004 22:13:52 +0200,
Quoted 24 lines · Oliver Freyd
Hello,
I use snd-trident with OSS emulation to access my soundcard. Music plays nicely, xmms and the like, but after alsa-0.90 or so the linux games began sounding distorted (like tuxracer, frozen-bubbles, mirrormagic, all SDL-games that my step-son likes...). Now I done some more tests to find out where it comes from:
The games use
/dev/dsp, and/proc/asound/card0/pcm0p/sub0/hw_paramssays:
access:RW_INTERLEAVED
format:S16_LE
subformat: STD
channels: 2
rate: 22050 (22050/1)period_size: 512buffer_size: 1024tick_time: 10000well, you hear drop outs, or even bits of sound repeated, sounds weird ( this doesn't happen with the standard OSS trident driver, BTW) I guess the game people want the buffer size small for low latency... Seems it is loosing some interrupts or so...
Quoted 4 lines
With xmms,
buffer_sizeis 16384, and all is well...Well, maybe anyone here on this list has an idea what has happened in the alsa drivers after 0.90 to trigger this bug.
No idea yet, but could you check whether this happens with ALSA native apps? For example, you can run aplay with --buffer-size and --period-size options. Pass above values to these options and see whether the playback works.
Quoted 2 lines
I'm running debian testing,
alsa-source-1.0.5a-3
It's old :)
Takashi
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
Hello Takashi,
thanks for your reply!
Quoted 5 lines · Takashi Iwai
No idea yet, but could you check whether this happens with ALSA native apps? For example, you can run aplay with --buffer-size and --period-size options. Pass above values to these options and see whether the playback works.
Yes, I've tried that now, if play some sound with aplay, without --buffer-size, it works normal. If I use --period-size 512 and buffer-size 1024, I get that broken sound. Also with period-size 1024 and buffer-size 2048, I think. Only if I use a buffer-size > 2* period-size if works ok.
Quoted 6 lines
Quoted 3 lines
I'm running debian testing,
alsa-source-1.0.5a-3It's old :)
This weekend I'll try to compile the newest alsa-sources :-)
Thanks for your help,
Oliver
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
At Fri, 8 Oct 2004 09:15:06 +0200,
Quoted 13 lines · Oliver Freyd
Hello Takashi,
thanks for your reply!
Quoted 5 lines · Takashi Iwai
No idea yet, but could you check whether this happens with ALSA native apps? For example, you can run aplay with --buffer-size and --period-size options. Pass above values to these options and see whether the playback works.
Quoted 5 lines
Yes, I've tried that now, if play some sound with aplay, without --buffer-size, it works normal. If I use --period-size 512 and buffer-size 1024, I get that broken sound. Also with period-size 1024 and buffer-size 2048, I think. Only if I use a buffer-size > 2* period-size if works ok.
Hmm, how about the bigger period & buffer sizes? Try both periods=2 and other cases.
The trident driver handles differently when period_size = buffer_size/2. If period_size != buffer_size/2, it allocates an extra voice for the interrupt source. So, if the bug occurs only with periods = 2, it narrows the buggy part.
Takashi
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
Quoted 8 lines · Takashi Iwai
Hmm, how about the bigger period & buffer sizes? Try both periods=2 and other cases.
The trident driver handles differently when
period_size= buffer_size/2. Ifperiod_size!= buffer_size/2, it allocates an extra voice for the interrupt source. So, if the bug occurs only with periods = 2, it narrows the buggy part.
Hello,
I've tried that, I think your idea is right.
The bug occurs when period_size = buffer_size/2 , also for bigger periods like 2048 or 4096. Then you can hear that some buffers are repeated, the soundcard plays them again. If you decrease period_size (even only by 1) it works nicely. If you increase, you get buffer underruns (aplay detects them).
So it seems you have an idea of where the bug could be :-)
If you tell me what else I could do to narrow down the problem, I'm happy to help you!
best regards,
Oliver
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
At Sat, 9 Oct 2004 20:41:35 +0200,
Quoted 20 lines · Oliver Freyd
Quoted 8 lines · Takashi Iwai
Hmm, how about the bigger period & buffer sizes? Try both periods=2 and other cases.
The trident driver handles differently when
period_size= buffer_size/2. Ifperiod_size!= buffer_size/2, it allocates an extra voice for the interrupt source. So, if the bug occurs only with periods = 2, it narrows the buggy part.Hello,
I've tried that, I think your idea is right.
The bug occurs whenperiod_size= buffer_size/2 , also for bigger periods like 2048 or 4096. Then you can hear that some buffers are repeated, the soundcard plays them again. If you decreaseperiod_size(even only by 1) it works nicely. If you increase, you get buffer underruns (aplay detects them).
Quoted 4 lines
So it seems you have an idea of where the bug could be :-)
If you tell me what else I could do to narrow down the problem, I'm happy to help you!
Ok, to be sure, please try the attached patch.
This will make the driver ignoring the check of 2 periods and always allocatint an extra voice.
Takashi
Index: alsa-kernel/pci/trident/trident_main.c
===================================================================
RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/trident/trident_main.c,v retrieving revision 1.59
pci/trident/trident_main.c +1 -1
@@ -814,7 +814,7 @@/* voice management */ -if (params_buffer_size (hw_params) /2 !=params_period_size (hw_params)) { +if (1 /*params_buffer_size(hw_params) / 2 != params_period_size(hw_params)*/ ) {if (evoice ==NULL ) { evoice =snd_trident_alloc_voice (trident,SNDRV_TRIDENT_VOICE_TYPE_PCM ,0 ,0 );if (evoice ==NULL )
Quoted 6 lines · Takashi Iwai
Ok, to be sure, please try the attached patch.
This will make the driver ignoring the check of 2 periods and always allocatint an extra voice.Takashi
Hello Takashi,
I've applied your patch. It works great, no more missed buffers and dropouts when buffer_size=2*period (tried with aplay).
The games sound nicely, too!!
So your idea was correct. Only thing I don't quite understand is why is there an extra voice to generate interrupts in the first place, and why not in that special case. But you'll know why anyway...
well, that's it for now,
best regards, Oliver
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl