All of lore.kernel.org
 help / color / mirror / Atom feed
* usage of snd_seq_queue_status_get_real_time()
@ 2005-04-08  0:51 Steve deRosier
  2005-04-08  6:54 ` Clemens Ladisch
  0 siblings, 1 reply; 6+ messages in thread
From: Steve deRosier @ 2005-04-08  0:51 UTC (permalink / raw)
  To: Alsa-Devel

All,

I'm trying to use the snd_seq_queue_status_get_real_time() call to retrieve the current time on the queue so I can compare it to the events I'm pushing into the queue (in order to track down a possible synchronization bug).  But every call I do ends up outputting the same data.

Here's the relevant code snippets:

const snd_seq_real_time_t * CMIDIPort::GetRealQueueTime( void )
{
  snd_seq_queue_status_t * qs;

  snd_seq_queue_status_alloca( &qs );
  snd_seq_get_queue_status( hSeq, mQueue, qs );
  return snd_seq_queue_status_get_real_time( qs );
}

Caller:
// snip
  const snd_seq_real_time_t * CurTime = mMIDIPort.GetRealQueueTime();
  Debugger->DebugMsg( this, "MIDI clock time %d.%d", (int) CurTime->tv_sec, (int) CurTime->tv_nsec );
// snip


and the output:
...
[CAlsaSender | 15:19:22] MIDI clock time 28.-1086326380
[CAlsaSender | 15:19:22] MIDI clock time 28.-1086326380
[CAlsaSender | 15:19:22] MIDI clock time 28.-1086326380
[CAlsaSender | 15:19:35] MIDI clock time 28.-1086326380
[CAlsaSender | 15:19:35] MIDI clock time 28.-1086326380
[CAlsaSender | 15:19:35] MIDI clock time 28.-1086326380
...

I'm sure it's obvious, but I just don't see what the problem is.
/proc/asound/seq/queues shows me the time is continually incrementing.

Thanks,
- Steve



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: usage of snd_seq_queue_status_get_real_time()
  2005-04-08  0:51 usage of snd_seq_queue_status_get_real_time() Steve deRosier
@ 2005-04-08  6:54 ` Clemens Ladisch
  2005-04-08 15:47   ` Steve deRosier
  0 siblings, 1 reply; 6+ messages in thread
From: Clemens Ladisch @ 2005-04-08  6:54 UTC (permalink / raw)
  To: Steve deRosier; +Cc: Alsa-Devel

Steve deRosier wrote:
> const snd_seq_real_time_t * CMIDIPort::GetRealQueueTime( void )
> {
>   snd_seq_queue_status_t * qs;
>
>   snd_seq_queue_status_alloca( &qs );
>   snd_seq_get_queue_status( hSeq, mQueue, qs );
>   return snd_seq_queue_status_get_real_time( qs );
> }

This function returns a pointer to a local variable.

(And it should check for errors.)


HTH
Clemens



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: usage of snd_seq_queue_status_get_real_time()
  2005-04-08  6:54 ` Clemens Ladisch
@ 2005-04-08 15:47   ` Steve deRosier
  2005-04-11  8:47     ` Clemens Ladisch
  0 siblings, 1 reply; 6+ messages in thread
From: Steve deRosier @ 2005-04-08 15:47 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: Alsa-Devel

Good point, I should check ..._get_queue_status() for an error return.  The docs don't specify any error return for ..._get_real_time() however.

I figured that it returns a pointer to a local var considering the const in the return type, but that still doesn't explain why the data never changes.

- Steve

Clemens Ladisch wrote:
> Steve deRosier wrote:
> 
>>const snd_seq_real_time_t * CMIDIPort::GetRealQueueTime( void )
>>{
>>  snd_seq_queue_status_t * qs;
>>
>>  snd_seq_queue_status_alloca( &qs );
>>  snd_seq_get_queue_status( hSeq, mQueue, qs );
>>  return snd_seq_queue_status_get_real_time( qs );
>>}
> 
> 
> This function returns a pointer to a local variable.
> 
> (And it should check for errors.)
> 
> 
> HTH
> Clemens
> 


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: usage of snd_seq_queue_status_get_real_time()
  2005-04-08 15:47   ` Steve deRosier
@ 2005-04-11  8:47     ` Clemens Ladisch
  2005-04-12 19:15       ` Steve deRosier
  0 siblings, 1 reply; 6+ messages in thread
From: Clemens Ladisch @ 2005-04-11  8:47 UTC (permalink / raw)
  To: Steve deRosier; +Cc: Alsa-Devel

Steve deRosier wrote:
> I figured that it returns a pointer to a local var considering the
> const in the return type, but that still doesn't explain why the
> data never changes.

Local variables cease to exist when the function returns.  The data on
the stack will be overwritten by the calling function (which explains
why you see a constant, meaningless value).

You should return the snd_seq_real_time_t by value.


HTH
Clemens



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: usage of snd_seq_queue_status_get_real_time()
  2005-04-11  8:47     ` Clemens Ladisch
@ 2005-04-12 19:15       ` Steve deRosier
  2005-04-13  8:10         ` Clemens Ladisch
  0 siblings, 1 reply; 6+ messages in thread
From: Steve deRosier @ 2005-04-12 19:15 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: Alsa-Devel

Ah, good point, color me dumb.  ;)  I've fixed that.  Thanks.

Note however it doesn't seem to fix the issue.  What did make it work for me was using
snd_seq_queue_status_malloc() and snd_seq_queue_status_free() instead of using the snd_seq_queue_status_alloca() macro.  Not sure why the macro didn't work for me, but the full fledged functions seem to make everything work.

My final working function (in case anyone cares):
snd_seq_real_time_t CMIDIPort::GetRealQueueTime( void )
{
  snd_seq_queue_status_t * qs;
  snd_seq_real_time_t rt;
  rt.tv_sec = 0;
  rt.tv_nsec = 0;

  if( snd_seq_queue_status_malloc( &qs ) )
    return rt;
  if( snd_seq_get_queue_status( hSeq, mQueue, qs ) == 0 )
    rt = *snd_seq_queue_status_get_real_time( qs );
  snd_seq_queue_status_free( qs );

  return rt;
}
 
An interesting note... On repeated calls, it will return the same time value for a few calls in a row.  Does the status information only get updated every so often?  Like maybe the driver only transfers a chunk at a time and so the time info in the status only gets updated each time the buffer is full or empty?

Thanks for you help,
- Steve


Clemens Ladisch wrote:
> Steve deRosier wrote:
> 
>>I figured that it returns a pointer to a local var considering the
>>const in the return type, but that still doesn't explain why the
>>data never changes.
> 
> 
> Local variables cease to exist when the function returns.  The data on
> the stack will be overwritten by the calling function (which explains
> why you see a constant, meaningless value).
> 
> You should return the snd_seq_real_time_t by value.
> 
> 
> HTH
> Clemens
> 


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: usage of snd_seq_queue_status_get_real_time()
  2005-04-12 19:15       ` Steve deRosier
@ 2005-04-13  8:10         ` Clemens Ladisch
  0 siblings, 0 replies; 6+ messages in thread
From: Clemens Ladisch @ 2005-04-13  8:10 UTC (permalink / raw)
  To: Steve deRosier; +Cc: Alsa-Devel

Steve deRosier wrote:
> On repeated calls, it will return the same time value for a few
> calls in a row.  Does the status information only get updated
> every so often?

Yes, it's updated on every timer tick.

If you didn't change it, the default timer is the system timer which
runs at 100 Hz in Linux 2.4.x and at 1000 Hz in Linux 2.6.x.


HTH
Clemens



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-04-13  8:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-08  0:51 usage of snd_seq_queue_status_get_real_time() Steve deRosier
2005-04-08  6:54 ` Clemens Ladisch
2005-04-08 15:47   ` Steve deRosier
2005-04-11  8:47     ` Clemens Ladisch
2005-04-12 19:15       ` Steve deRosier
2005-04-13  8:10         ` Clemens Ladisch

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.