[alsa-devel] a11y: howto reduce latency with alsa's dmix plugin?
Hello, Is there a way to reduce latency on audiocard if the dmix plugin is in use? I am asking because there is a strange problem with asistive technologies which are outputing through alsa. E. G. speech-dispatcher takes almost a half sec to stop the speech-synthesizer. If the user navigates quickly through menus, there are simultane outputs at a time. (tested with an usb logitech headset, snd-intel8x0 based card, snd-hda-intel). The same problem can be reproduced by running mplayer with alsa output driver and pressing quickly left/right arrow. You should hear several samples at a time.
Using an sblive card which doesn't use dmix doesn't have such problems.
Using the dmix plugin should audio much faster to avoid this problem.
Please help!!! Regards Halim
On So, Aug 23, 2009 at 09:55:18 +0000, Halim Sahin wrote:
Hello, Is there a way to reduce latency on audiocard if the dmix plugin is in use? I am asking because there is a strange problem with asistive technologies which are outputing through alsa. E. G. speech-dispatcher takes almost a half sec to stop the speech-synthesizer. If the user navigates quickly through menus, there are simultane outputs at a time. (tested with an usb logitech headset, snd-intel8x0 based card, snd-hda-intel). The same problem can be reproduced by running mplayer with alsa output driver and pressing quickly left/right arrow. You should hear several samples at a time.
Using an sblive card which doesn't use dmix doesn't have such problems.
Using the dmix plugin should audio much faster to avoid this problem.
Please help!!! Regards Halim
At Sun, 23 Aug 2009 09:55:18 +0000 (UTC), Halim Sahin wrote:
Hello, Is there a way to reduce latency on audiocard if the dmix plugin is in use? I am asking because there is a strange problem with asistive technologies which are outputing through alsa. E. G. speech-dispatcher takes almost a half sec to stop the speech-synthesizer. If the user navigates quickly through menus, there are simultane outputs at a time. (tested with an usb logitech headset, snd-intel8x0 based card, snd-hda-intel). The same problem can be reproduced by running mplayer with alsa output driver and pressing quickly left/right arrow. You should hear several samples at a time.
Using an sblive card which doesn't use dmix doesn't have such problems.
Using the dmix plugin should audio much faster to avoid this problem.
It's a bit hard to guess. This could be the difference of PCM drain implementation between hw and dmix, but a half second is still too long.
Could you prepare a small test case to reproduce the buggy behavior?
thanks,
Takashi
On Mo, Aug 31 2009, Takashi Iwai wrote:
At Sun, 23 Aug 2009 09:55:18 +0000 (UTC), Halim Sahin wrote:
Hello, Is there a way to reduce latency on audiocard if the dmix plugin is in use? I am asking because there is a strange problem with asistive technologies which are outputing through alsa. E. G. speech-dispatcher takes almost a half sec to stop the speech-synthesizer. If the user navigates quickly through menus, there are simultane outputs at a time. (tested with an usb logitech headset, snd-intel8x0 based card, snd-hda-intel). The same problem can be reproduced by running mplayer with alsa output driver and pressing quickly left/right arrow. You should hear several samples at a time.
Using an sblive card which doesn't use dmix doesn't have such problems.
Using the dmix plugin should audio much faster to avoid this problem.
It's a bit hard to guess. This could be the difference of PCM drain implementation between hw and dmix, but a half second is still too long.
Could you prepare a small test case to reproduce the buggy behavior?
Yes that's easy: The following should be tested with active dmix. 1. login to a textconsole 2. mplayer -ao alsa your_favourite_file 3. Press space during playback.
Result: it takes about an half sec to stop the playback.
The second test would be: 1. login to a console 2. mplayer -ao alsa:device=hw=0,0 your_file 3. press space during playback Result: The playback stops without delay
Hope you can help. Thanks for your response Kind regards Halim
thanks,
Takashi
At Tue, 01 Sep 2009 12:32:27 +0200, Halim Sahin wrote:
On Mo, Aug 31 2009, Takashi Iwai wrote:
At Sun, 23 Aug 2009 09:55:18 +0000 (UTC), Halim Sahin wrote:
Hello, Is there a way to reduce latency on audiocard if the dmix plugin is in use? I am asking because there is a strange problem with asistive technologies which are outputing through alsa. E. G. speech-dispatcher takes almost a half sec to stop the speech-synthesizer. If the user navigates quickly through menus, there are simultane outputs at a time. (tested with an usb logitech headset, snd-intel8x0 based card, snd-hda-intel). The same problem can be reproduced by running mplayer with alsa output driver and pressing quickly left/right arrow. You should hear several samples at a time.
Using an sblive card which doesn't use dmix doesn't have such problems.
Using the dmix plugin should audio much faster to avoid this problem.
It's a bit hard to guess. This could be the difference of PCM drain implementation between hw and dmix, but a half second is still too long.
Could you prepare a small test case to reproduce the buggy behavior?
Yes that's easy: The following should be tested with active dmix.
- login to a textconsole
- mplayer -ao alsa your_favourite_file
- Press space during playback.
Result: it takes about an half sec to stop the playback.
This isn't a test case to analyze. If the app you mentioned is using libao as the backend, then yes, it's the same issue. If not, it just appears same, but you don't know whether it's the same.
At best, we need a small C code that reproduces the behavior.
The second test would be:
- login to a console
- mplayer -ao alsa:device=hw=0,0 your_file
- press space during playback
Result: The playback stops without delay
This could be also the difference whether the device supports pause or not, too.
Takashi
On Di, Sep 01 2009, Takashi Iwai wrote:
At best, we need a small C code that reproduces the behavior.
Ok here is a small example. It's a modified version of pcm_min.c. Simply press ctrl+c to reproduce the problematic behaviour. on my machine it takes about an half sek to stop with an usb head which uses dmix. Using an sblive card (without dmix) stopps immediately.
Hope you can help. Kind regards Halim
At Wed, 02 Sep 2009 10:56:17 +0200, Halim Sahin wrote:
On Di, Sep 01 2009, Takashi Iwai wrote:
At best, we need a small C code that reproduces the behavior.
Ok here is a small example. It's a modified version of pcm_min.c. Simply press ctrl+c to reproduce the problematic behaviour. on my machine it takes about an half sek to stop with an usb head which uses dmix.
Hmm, I cannot reproduce the problem, at least, dmix + HD-audio. After removing sleep(1), it quits immediately.
Doesn't this problem happen if you use usb-audio with "hw" PCM?
It's possible that the behavior of snd_pcm_drop() of usb-audio is different from others because of URB handling.
Takashi
On Fr, Sep 04 2009, Takashi Iwai wrote:
At Wed, 02 Sep 2009 10:56:17 +0200, Halim Sahin wrote:
On Di, Sep 01 2009, Takashi Iwai wrote:
At best, we need a small C code that reproduces the behavior.
Ok here is a small example. It's a modified version of pcm_min.c. Simply press ctrl+c to reproduce the problematic behaviour. on my machine it takes about an half sek to stop with an usb head which uses dmix.
Hmm, I cannot reproduce the problem, at least, dmix + HD-audio. After removing sleep(1), it quits immediately.
Yes you can't, because the program doesn't run. The sleep shouldn't be removed to see the problem. When speech-dispatcher is running and someone tries to stop the output, the programm doesn't exit. Think about it like a pause key :-).
The sblive stopps emmidiately with inserted sleep the usb headset doesn't.
Doesn't this problem happen if you use usb-audio with "hw" PCM?
The pcm_min example of alsalib doesn't run this way. --8<---------------cut here---------------start------------->8---
ALSA lib pcm.c:7125:(snd_pcm_set_params) Sample format not available for PLAYBAC K: Invalid argument Playback open error: Invalid argument --8<---------------cut here---------------end--------------->8---
Can you tell me which sampleformat works with this device???
It's possible that the behavior of snd_pcm_drop() of usb-audio is different from others because of URB handling.
The stop problem also happends on my laptop with hd audio and ad1981 chip.
with kind regards Halim
At Fri, 04 Sep 2009 11:09:17 +0200, Halim Sahin wrote:
On Fr, Sep 04 2009, Takashi Iwai wrote:
At Wed, 02 Sep 2009 10:56:17 +0200, Halim Sahin wrote:
On Di, Sep 01 2009, Takashi Iwai wrote:
At best, we need a small C code that reproduces the behavior.
Ok here is a small example. It's a modified version of pcm_min.c. Simply press ctrl+c to reproduce the problematic behaviour. on my machine it takes about an half sek to stop with an usb head which uses dmix.
Hmm, I cannot reproduce the problem, at least, dmix + HD-audio. After removing sleep(1), it quits immediately.
Yes you can't, because the program doesn't run. The sleep shouldn't be removed to see the problem.
I don't understand here. So, how is the problem exactly? In which point is the delay expected and where not expected?
You catch a signal and add a delay there -- so the program works, no? If you are checking whether snd_pcm_drop() is executed immediately or not, you should put a printf() after snd_pcm_drop() to indicate when the function call finishes.
When speech-dispatcher is running and someone tries to stop the output, the programm doesn't exit.
So, "doesn't exit" is the intended behavior?
Think about it like a pause key :-).
The sblive stopps emmidiately with inserted sleep the usb headset doesn't.
In that sense, HD-audio + dmix works as well. There is no 0.5 sec delay in snd_pcm_drop() itself but the code to sleep immediately.
Doesn't this problem happen if you use usb-audio with "hw" PCM?
The pcm_min example of alsalib doesn't run this way. --8<---------------cut here---------------start------------->8---
ALSA lib pcm.c:7125:(snd_pcm_set_params) Sample format not available for PLAYBAC K: Invalid argument Playback open error: Invalid argument --8<---------------cut here---------------end--------------->8---
Can you tell me which sampleformat works with this device???
Use plughw instead.
It's possible that the behavior of snd_pcm_drop() of usb-audio is different from others because of URB handling.
The stop problem also happends on my laptop with hd audio and ad1981 chip.
Works fine on my machine. There shouldn't be any difference with the codec chip regarding this, and very unlikely due to the difference of controller chip, too. So, the hardware shouldn't be a problem as long as you use the relatively new version of alsa-driver.
The question might be the alsa-lib version. I've tested only with the latest one, alsa-lib-1.0.21.
Takashi
participants (2)
-
Halim Sahin
-
Takashi Iwai