0

My question may be similar to this: Why might my AudioQueueOutputCallback not be called?

It seems that person was able to fix by running audio stuff on main thread. I cannot do that.

I enqueue buffers to prime audio Q, then start audio Q. Shouldn't those buffers complete immediately once I start my queue?

I am setting the data size correctly.

As a hack I just re-use buffers without waiting for them to be reported by cabllback as done. If I do this, I run for a couple of seconds like this, then the buffer callback starts working from them on.

Community
  • 1
  • 1
Ted P
  • 95
  • 1
  • 10

1 Answers1

0

definitely not a good idea to hack your way around with core audio.. while it may be a quick fix, it will definitely hurt you in ambiguous ways in the long run.

your problem isn't the same as the link you posted, their problem was assigning the callback on the wrong thread.. in your case, your callback is in the right thread, it's just that the audio buffers you are feeding it initially are either empty, too small or contains data not fit for audio playback

keep in mind that the purpose of the callback is to fire after each audio buffer supplied to the audio queue has been played (ie consumed).. the fact that after you start the queue the callback isn't being fired.. it means that there is nothing in the audio buffers for it to consume.. or too little meaningful information for it to consume..

when you do it manually you see a lag b/c the audio queue is trying to process the empty/erroneous buffers you supplied it.. then you resupply the same buffers with valid data that the queue eventually plays and then fires the callback

solution: compare the data you put in the buffers before starting the queue with the data you are supplying manually.. i'm sure there is a difference.. if that doesn't work please show your code for further analysis

abbood
  • 23,101
  • 16
  • 132
  • 246
  • Thank you much, I will take a close look. I am streaming audio from a shoutcast connection. I found a bug. Now the first number of buffers complete, but then it gets "stuck" later on. Strange because at that point I have parsed through all the headers and such and should just be receiving compressed audio. – Ted P Oct 02 '12 at 18:36
  • If you can show your code then I can probably find a more specific cause for your prolem – abbood Oct 02 '12 at 19:52
  • Appreciate that. I will see if I can make a simplified version. It's basically a C++ "port" of Matt Gallagher's AudioStreamer. – Ted P Oct 02 '12 at 22:44
  • I got it working. Playing out through the speakers just fine. One thing is I had to change my run loop mode from common to default. Next step is I am going to decode the audio myself on the fly. I am toying with offline render. Getting the same problem, it makes it so my buffers do not complete. I am using the offline rendering example from Apple, but that example is reading from a file, so maybe I need to make the offline calls at different times? – Ted P Oct 11 '12 at 21:17
  • you see that's what i mean.. i can't help you unless i see the code.. (i couldn't have guessed u weren't using default run loop).. if you show me what you're working on I can probably offer more help – abbood Oct 12 '12 at 04:57
  • It's the AudioStreamer.m file from [link](https://github.com/mattgallagher/AudioStreamer)Matt Gallagher's streaming example. To change it to offline rendering there are only 3 steps but I cannot figure out where to put them. I would think I could just set offline render format after I create my Q, call offline render requesting 0 frames after calling AudioQStart(), and then happily call offlineRender() as the buffers are filled by the internet audio stream, but this last part is not triggering done callback for audio buffers. – Ted P Oct 12 '12 at 22:23