[alsa-devel] Timer instability

Takashi Iwai tiwai at suse.de
Wed Feb 25 17:59:48 CET 2009


At Wed, 25 Feb 2009 16:56:47 +0000,
Clive Messer wrote:
> 
> On Wednesday 25 Feb 2009 16:39:28 you wrote:
> > At Wed, 25 Feb 2009 16:24:18 +0000,
> >
> > Clive Messer wrote:
> > > On Wednesday 25 Feb 2009 15:51:33 you wrote:
> > > > At Wed, 25 Feb 2009 15:11:44 +0000,
> > > >
> > > > Clive Messer wrote:
> > > > > 36192	36191	100068	3	0	0	1	2
> > > > > 36195	36194	100090	2	0	0	1	2
> > > > > 36198	36198	100113	1	0	0	1	2
> > > > > 36207	36206	63854	2816	1600	0	1	3
> > > > > 36212	36211	63854	2815	1601	4	1	3
> > > > > 36216	36216	63854	2814	1602	4	1	3
> > > > > 36221	36220	63854	2813	1603	4	1	3
> > > > > 36225	36225	101224	4460	-44	4	1	3
> > > >
> > > > This is pretty weird.  Is this behavior always reproducible?
> > >
> > > Nope. I get different results every time I run it.
> > >
> > > > What shows with the patch below to alsa-lib?
> > >
> > > Here's one (attached) I just did with the new patch that shows the crazy
> > > high numbers again.
> > > hwsync: 2080(0), 6496(0)
> > > 70758	70758	47142	0	4416	0	0	3
> > > hwsync: 1472(0), 6496(0)
> > > 70763	70762	104573379136040	4971973988617026976	-4971973988617022560	4	1	
> > >3
> >
> > The problem is that hwptr goes backward here.  But it didn't happen in
> > this hwsync call but sometime before that.
> >
> > Could you try the patch below instead?  This will track all sync_ptr calls.
> >
> >
> > Takashi
> >
> > ---
> > diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
> > index e9ce092..ad8d4a5 100644
> > --- a/src/pcm/pcm_hw.c
> > +++ b/src/pcm/pcm_hw.c
> > @@ -131,6 +131,10 @@ struct timespec snd_pcm_hw_fast_tstamp(snd_pcm_t *pcm)
> >  static int sync_ptr1(snd_pcm_hw_t *hw, unsigned int flags)
> >  {
> >  	int err;
> > +	long old_hwptr, new_hwptr;
> > +	long old_applptr, new_applptr;
> > +	old_hwptr = *pcm->hw.ptr;
> > +	old_applptr = *pcm->appl.ptr;
> >  	hw->sync_ptr->flags = flags;
> >  	err = ioctl((hw)->fd, SNDRV_PCM_IOCTL_SYNC_PTR, (hw)->sync_ptr);
> >  	if (err < 0) {
> > @@ -138,6 +142,11 @@ static int sync_ptr1(snd_pcm_hw_t *hw, unsigned int
> > flags) SYSMSG("SNDRV_PCM_IOCTL_SYNC_PTR failed");
> >  		return err;
> >  	}
> > +	new_hwptr = *pcm->hw.ptr;
> > +	new_applptr = *pcm->appl.ptr;
> > +	printf("sync_ptr1: %ld(%ld), %ld(%ld)\n",
> > +	       new_hwptr, new_hwptr - old_hwptr,
> > +	       new_applptr, new_applptr - old_applptr);
> >  	return 0;
> >  }
> 
> Sorry Takashi,
> 
> I'm not a coder so I only know that it wont compile because there isn't a pcm 
> variable passed into that function - it's snd_pcm_hw_t *hw.

Oops, sorry, pasted a wrong version.
Here it is.


thanks,

Takashi
---
diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
index e9ce092..5211d1c 100644
--- a/src/pcm/pcm_hw.c
+++ b/src/pcm/pcm_hw.c
@@ -131,6 +131,10 @@ struct timespec snd_pcm_hw_fast_tstamp(snd_pcm_t *pcm)
 static int sync_ptr1(snd_pcm_hw_t *hw, unsigned int flags)
 {
 	int err;
+	long old_hwptr, new_hwptr;
+	long old_applptr, new_applptr;
+	old_hwptr = hw->sync_ptr->s.status.hw_ptr;
+	old_applptr = hw->sync_ptr->c.control.appl_ptr;
 	hw->sync_ptr->flags = flags;
 	err = ioctl((hw)->fd, SNDRV_PCM_IOCTL_SYNC_PTR, (hw)->sync_ptr);
 	if (err < 0) {
@@ -138,6 +142,11 @@ static int sync_ptr1(snd_pcm_hw_t *hw, unsigned int flags)
 		SYSMSG("SNDRV_PCM_IOCTL_SYNC_PTR failed");
 		return err;
 	}
+	new_hwptr = hw->sync_ptr->s.status.hw_ptr;
+	new_applptr = hw->sync_ptr->c.control.appl_ptr;
+	printf("sync_ptr1: %ld(%ld), %ld(%ld)\n",
+	       new_hwptr, new_hwptr - old_hwptr,
+	       new_applptr, new_applptr - old_applptr);
 	return 0;
 }
 


More information about the Alsa-devel mailing list