alsa-lib pcm_share.c snd_pcm_share_open() bug ?
Hi,
I was looking at snd_pcm_share_open() in alsa-lib-1.0.22, and stumbled on the following line:
pcm->monotonic = pcm->monotonic;
what is that supposed to do ? There is clearly something wrong there.
Thanks,
Mathieu
Signature · 4 lines
Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com
At Fri, 9 Apr 2010 11:03:03 -0400,
Quoted 9 lines · Mathieu Desnoyers
Hi,
I was looking at
snd_pcm_share_open()in alsa-lib-1.0.22, and stumbled on the following line:pcm->monotonic = pcm->monotonic;what is that supposed to do ? There is clearly something wrong there.
Yeah, very fishy here.
I suppose this plugin can't handle monotonic time as is. Jaroslav, could you fix that?
thanks,
Takashi
Quoted 8 lines · Takashi Iwai
At Fri, 9 Apr 2010 11:03:03 -0400,
Quoted 6 lines · Mathieu Desnoyers
Hi,
I was looking at
snd_pcm_share_open()in alsa-lib-1.0.22, and stumbled on the following line:
Quoted 8 lines
Quoted 3 lines
pcm->monotonic = pcm->monotonic;what is that supposed to do ? There is clearly something wrong there.
Yeah, very fishy here.
I suppose this plugin can't handle monotonic time as is. Jaroslav, could you fix that?
The plugin can handle the monotonic clock as well. The correct line should be:
pcm->monotonic = slave->pcm->monotonic;
Mathieu - thanks for notice.
Jaroslav
-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
At Tue, 13 Apr 2010 10:10:02 +0200 (CEST),
Quoted 17 lines · Jaroslav Kysela
Quoted 14 lines · Takashi Iwai
At Fri, 9 Apr 2010 11:03:03 -0400,
Quoted 9 lines · Mathieu Desnoyers
Hi,
I was looking at
snd_pcm_share_open()in alsa-lib-1.0.22, and stumbled on the following line:pcm->monotonic = pcm->monotonic;what is that supposed to do ? There is clearly something wrong there.
Yeah, very fishy here.
Quoted 7 lines
Quoted 2 lines
I suppose this plugin can't handle monotonic time as is. Jaroslav, could you fix that?
The plugin can handle the monotonic clock as well. The correct line should be:
pcm->monotonic=slave->pcm->monotonic;
Ah indeed. It's a so complex code that is barely used ;)
thanks,
Takashi
Quoted 22 lines · * Takashi Iwai ([email protected]) wrote:
At Tue, 13 Apr 2010 10:10:02 +0200 (CEST),
Quoted 20 lines · Jaroslav Kysela
Quoted 16 lines · Takashi Iwai
At Fri, 9 Apr 2010 11:03:03 -0400,
Quoted 9 lines · Mathieu Desnoyers
Hi,
I was looking at
snd_pcm_share_open()in alsa-lib-1.0.22, and stumbled on the following line:pcm->monotonic = pcm->monotonic;what is that supposed to do ? There is clearly something wrong there.
Yeah, very fishy here.
I suppose this plugin can't handle monotonic time as is. Jaroslav, could you fix that?
Quoted 7 lines
Quoted 4 lines
The plugin can handle the monotonic clock as well. The correct line should be:
pcm->monotonic=slave->pcm->monotonic;Ah indeed. It's a so complex code that is barely used ;)
Actually, I ran into this code because I was grepping for "monotonic" field modifications. It's indeed not run on my setup. However, what I experience is the following problem:
I instrumented the xrun() handler from aplay/aplay.c so I could study buffer underruns with the kernel trace with LTTng. Was I noticed is that the underrun error message returns a bogus underrun duration value because aplay is in "monotonic" time mode, but alsa-lib returned to non-monotonic mode (but it detects the monotonic clock upon initial setup).
Quick test code (that also forces the gettimestamp "monotonic" to 1 (locally)).
Finding out where the value is brought back to 0 might involve poking in the lib code with printf (sorry, I don't currently have the time required to do it myself).
Thanks,
Mathieu
src/pcm/pcm_hw.c +1 -0
@@ -1208,6 +1208,7 @@ pcm->poll_fd = fd; pcm->poll_events = info.stream ==SND_PCM_STREAM_PLAYBACK ?POLLOUT :POLLIN ; pcm->monotonic = monotonic; +printf ("test is mono %d\n" , monotonic); ret =snd_pcm_hw_mmap_status (pcm);if (ret <0 ) {
src/pcm/pcm_local.h +2 -0
@@ -952,6 +952,8 @@static inline void gettimestamp (snd_htimestamp_t *tstamp,int monotonic) {#if defined(HAVE_CLOCK_GETTIME ) && defined(CLOCK_MONOTONIC ) +printf ("ismonotonic %d\n" , monotonic); + monotonic =1 ;if (monotonic) {clock_gettime (CLOCK_MONOTONIC , tstamp); }else {
src/pcm/pcm_file.c +1 -0
@@ -785,6 +785,7 @@#else pcm->monotonic =0 ;#endif +snd_pcm_link_hw_ptr (pcm, slave);snd_pcm_link_appl_ptr (pcm, slave); *pcmp = pcm;
Quoted 4 lines
thanks,
Takashi
Signature · 4 lines
Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com