• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: AudioQueue and buffer underflows
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AudioQueue and buffer underflows


  • Subject: Re: AudioQueue and buffer underflows
  • From: Jens Alfke <email@hidden>
  • Date: Sat, 22 Mar 2008 17:10:01 -0700

I didn't get any replies to my questions, but yesterday I figured out the answers on my own. What I hadn't realized is that the AudioQueueOutputCallback really just tells the client "here, I'm done with this buffer, it's empty now". The client doesn't _have_ to respond by re-enqueuing that buffer during the callback; it can enqueue another free buffer, or wait till one's available, and it can enqueue a buffer at any time.

Once I grasped that, everything made sense. Now I keep my own list of free buffers. When my callback is invoked, I add that buffer to the free list. When my data stream gives me new data (usually received over a socket), I copy it into one or more currently-free buffers and enqueue them.

If any of this is bogus, please interrupt and correct me =)

1. What's the best way to detect that the queue's stopped playing because of an underrun? Just counting the number of buffers I fail to enqueue doesn't seem reliable.

Answer: when my free-buffer list fills up (i.e. its size equals the number of buffers I allocated.)


2. After an underrun, once I can catch up and buffer some data, how do I get the queue going again? Do I need to stop, prime and start it?

Answer: The queue's still running, and as soon as I enqueue new buffers, it'll start playing them.


My next challenge is to deal with synchronization. If I underrun, I shouldn't just start playing from where I left off, I need to seek ahead and catch up with where the audio should be at that time. And I think I'll need to start tagging the enqueued buffers with timestamps, so they get played at the right instant.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: AudioQueue and buffer underflows
      • From: William Stewart <email@hidden>
References: 
 >AudioQueue and buffer underflows (From: Jens Alfke <email@hidden>)

  • Prev by Date: Nonsensical values from kAudioFilePropertyBitRate
  • Next by Date: Re: AU Question: Host Tempo Callback
  • Previous by thread: AudioQueue and buffer underflows
  • Next by thread: Re: AudioQueue and buffer underflows
  • Index(es):
    • Date
    • Thread