• 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: William Stewart <email@hidden>
  • Date: Mon, 24 Mar 2008 14:47:13 -0700


On Mar 22, 2008, at 5:10 PM, Jens Alfke wrote:
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.

Yes - in fact its not even "its empty now" - we don't change the contents of the buffer, so they are the same as what they were when you enqueued it. Can be useful if you are looping small segments.




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 =)

Nope - that was the response :)



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.

Yes - the queue will try to just add them to the last buffers it had played (which is the default behaviour that you mostly want).


Bill

_______________________________________________
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


References: 
 >AudioQueue and buffer underflows (From: Jens Alfke <email@hidden>)
 >Re: AudioQueue and buffer underflows (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: Getting audiofile to recognize third-party codecs
  • Next by Date: Re: [FAQ?] re>x-code template project for AU with cocoa view
  • Previous by thread: Re: AudioQueue and buffer underflows
  • Next by thread: App hanging in AudioQueueStop
  • Index(es):
    • Date
    • Thread