Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Steve deRosier <derosier@pianodisc.com>
To: Clemens Ladisch <clemens@ladisch.de>
Cc: Alsa-Devel <alsa-devel@lists.sourceforge.net>
Subject: Re: usage of snd_seq_queue_status_get_real_time()
Date: Tue, 12 Apr 2005 12:15:32 -0700	[thread overview]
Message-ID: <425C1E54.1040705@pianodisc.com> (raw)
In-Reply-To: <Pine.HPX.4.33n.0504111044370.22583-100000@studcom.urz.uni-halle.de>

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

  reply	other threads:[~2005-04-12 19:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2005-04-13  8:10         ` Clemens Ladisch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=425C1E54.1040705@pianodisc.com \
    --to=derosier@pianodisc.com \
    --cc=alsa-devel@lists.sourceforge.net \
    --cc=clemens@ladisch.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox