* a11y: howto reduce latency with alsa's dmix plugin? @ 2009-08-23 9:55 Halim Sahin 2009-08-30 16:13 ` really no idea? " Halim Sahin 2009-08-31 15:12 ` Takashi Iwai 0 siblings, 2 replies; 9+ messages in thread From: Halim Sahin @ 2009-08-23 9:55 UTC (permalink / raw) To: alsa-devel 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* really no idea? Re: a11y: howto reduce latency with alsa's dmix plugin? 2009-08-23 9:55 a11y: howto reduce latency with alsa's dmix plugin? Halim Sahin @ 2009-08-30 16:13 ` Halim Sahin 2009-08-31 15:12 ` Takashi Iwai 1 sibling, 0 replies; 9+ messages in thread From: Halim Sahin @ 2009-08-30 16:13 UTC (permalink / raw) To: alsa-devel 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 -- Halim Sahin E-Mail: halim.sahin (at) t-online.de ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: a11y: howto reduce latency with alsa's dmix plugin? 2009-08-23 9:55 a11y: howto reduce latency with alsa's dmix plugin? Halim Sahin 2009-08-30 16:13 ` really no idea? " Halim Sahin @ 2009-08-31 15:12 ` Takashi Iwai 2009-09-01 10:32 ` Halim Sahin 1 sibling, 1 reply; 9+ messages in thread From: Takashi Iwai @ 2009-08-31 15:12 UTC (permalink / raw) To: Halim Sahin; +Cc: alsa-devel 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: a11y: howto reduce latency with alsa's dmix plugin? 2009-08-31 15:12 ` Takashi Iwai @ 2009-09-01 10:32 ` Halim Sahin 2009-09-01 10:40 ` Takashi Iwai 0 siblings, 1 reply; 9+ messages in thread From: Halim Sahin @ 2009-09-01 10:32 UTC (permalink / raw) To: alsa-devel 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 -- Halim Sahin E-Mail: halim.sahin (at) t-online.de ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: a11y: howto reduce latency with alsa's dmix plugin? 2009-09-01 10:32 ` Halim Sahin @ 2009-09-01 10:40 ` Takashi Iwai 2009-09-02 8:56 ` Halim Sahin 0 siblings, 1 reply; 9+ messages in thread From: Takashi Iwai @ 2009-09-01 10:40 UTC (permalink / raw) To: Halim Sahin; +Cc: alsa-devel 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. > 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. 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: > 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 This could be also the difference whether the device supports pause or not, too. Takashi ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: a11y: howto reduce latency with alsa's dmix plugin? 2009-09-01 10:40 ` Takashi Iwai @ 2009-09-02 8:56 ` Halim Sahin 2009-09-03 22:07 ` Takashi Iwai 0 siblings, 1 reply; 9+ messages in thread From: Halim Sahin @ 2009-09-02 8:56 UTC (permalink / raw) To: alsa-devel [-- Attachment #1: Type: text/plain, Size: 370 bytes --] 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. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: pcm_min.c --] [-- Type: text/x-csrc, Size: 1703 bytes --] /* * This extra small demo sends a random samples to your speakers. */ #include <alsa/asoundlib.h> #include <signal.h> #include <unistd.h> static char *device = "default"; snd_output_t *output = NULL; unsigned char buffer[16 * 1024]; /* some random data */ snd_pcm_t *handle; void suspend (int signum) { int err; printf ("trying to stop\n"); if ((err = snd_pcm_drop (handle)) < 0) printf ("cannot pause\n"); sleep (1); snd_pcm_close (handle); exit (1); } int main (void) { int err; unsigned int i; snd_pcm_sframes_t frames; signal (SIGINT, suspend); for (i = 0; i < sizeof (buffer); i++) buffer[i] = random () & 0xff; if ((err = snd_pcm_open (&handle, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) { printf ("Playback open error: %s\n", snd_strerror (err)); exit (EXIT_FAILURE); } if ((err = snd_pcm_set_params (handle, SND_PCM_FORMAT_U8, SND_PCM_ACCESS_RW_INTERLEAVED, 1, 48000, 1, 500000)) < 0) { /* 0.5sec */ printf ("Playback open error: %s\n", snd_strerror (err)); exit (EXIT_FAILURE); } for (i = 0; i < 16; i++) { frames = snd_pcm_writei (handle, buffer, sizeof (buffer)); if (frames < 0) frames = snd_pcm_recover (handle, frames, 0); if (frames < 0) { printf ("snd_pcm_writei failed: %s\n", snd_strerror (err)); break; } if (frames > 0 && frames < (long) sizeof (buffer)) printf ("Short write (expected %li, wrote %li)\n", (long) sizeof (buffer), frames); } snd_pcm_close (handle); return 0; } [-- Attachment #3: Type: text/plain, Size: 38 bytes --] Hope you can help. Kind regards Halim [-- Attachment #4: Type: text/plain, Size: 160 bytes --] _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: a11y: howto reduce latency with alsa's dmix plugin? 2009-09-02 8:56 ` Halim Sahin @ 2009-09-03 22:07 ` Takashi Iwai 2009-09-04 9:09 ` Halim Sahin 0 siblings, 1 reply; 9+ messages in thread From: Takashi Iwai @ 2009-09-03 22:07 UTC (permalink / raw) To: Halim Sahin; +Cc: alsa-devel 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: a11y: howto reduce latency with alsa's dmix plugin? 2009-09-03 22:07 ` Takashi Iwai @ 2009-09-04 9:09 ` Halim Sahin 2009-09-04 9:32 ` Takashi Iwai 0 siblings, 1 reply; 9+ messages in thread From: Halim Sahin @ 2009-09-04 9:09 UTC (permalink / raw) To: alsa-devel 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: a11y: howto reduce latency with alsa's dmix plugin? 2009-09-04 9:09 ` Halim Sahin @ 2009-09-04 9:32 ` Takashi Iwai 0 siblings, 0 replies; 9+ messages in thread From: Takashi Iwai @ 2009-09-04 9:32 UTC (permalink / raw) To: Halim Sahin; +Cc: alsa-devel 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-09-04 9:32 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2009-08-23 9:55 a11y: howto reduce latency with alsa's dmix plugin? Halim Sahin 2009-08-30 16:13 ` really no idea? " Halim Sahin 2009-08-31 15:12 ` Takashi Iwai 2009-09-01 10:32 ` Halim Sahin 2009-09-01 10:40 ` Takashi Iwai 2009-09-02 8:56 ` Halim Sahin 2009-09-03 22:07 ` Takashi Iwai 2009-09-04 9:09 ` Halim Sahin 2009-09-04 9:32 ` Takashi Iwai
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.