Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7795639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:07:39+00:00 2026-06-01T23:07:39+00:00

When I start an audio output process with AudioQueueStart(out.queue, nil) , the output callback

  • 0

When I start an audio output process with AudioQueueStart(out.queue, nil), the output callback only fires 3 times (which is the number of allocated buffers).

Here is my Output callback code:

static void AQOutputCallback(void* aqr,
                             AudioQueueRef outQ,
                             AudioQueueBufferRef outQB)
{
  AQCallbackStruct *aqc = (AQCallbackStruct *) aqr;

  NSLog(@"Out");

  // Check if AudioQueue is stopped
  if (!aqc->run) {
    NSLog(@"Stopped");
    return;
  }

  // Processing data

  // Check enqueue error
  int err = AudioQueueEnqueueBuffer(outQ, outQB, 0, NULL);
  if (err != noErr) NSLog(@"OutputCallback AudioQueueEnqueueBuffer() %d ", err);
  NSLog(@"Enqueued");
}

I think it’s due to the lack of buffers, but my output is:

Out
Enqueued
Out
Enqueued
Out
Enqueued

So the first buffer is enqueued before the AudioQueue starts to fill the third one, it should not run out of buffers.

What happens here ?

Edit: Setup code

#define AUDIO_BUFFERS 3

typedef struct AQCallbackStruct {
  AudioStreamBasicDescription mDataFormat;
  AudioQueueRef queue;
  AudioQueueBufferRef mBuffers[AUDIO_BUFFERS];
  unsigned long frameSize;
  BOOL *run;
} AQCallbackStruct;

// In some method
AQCallbackStruct out;

out.mDataFormat
out.mDataFormat.mFormatID = kAudioFormatLinearPCM;
out.mDataFormat.mSampleRate = 44100.0;
out.mDataFormat.mChannelsPerFrame = 2;
out.mDataFormat.mBitsPerChannel = 16;
out.mDataFormat.mBytesPerPacket =
  out.mDataFormat.mBytesPerFrame =
    out.mDataFormat.mChannelsPerFrame * sizeof(short int);
out.mDataFormat.mFramesPerPacket = 1;
out.mDataFormat.mFormatFlags =
    kLinearPCMFormatFlagIsBigEndian
  | kLinearPCMFormatFlagIsSignedInteger
  | kLinearPCMFormatFlagIsPacked;

out.frameSize = 735;

int err;
err = AudioQueueNewOutput(&out.mDataFormat,
                          AQOutputCallback,
                          &out,
                          CFRunLoopGetCurrent(),
                          kCFRunLoopCommonModes,
                          0,
                          &out.queue);

if (err != noErr) NSLog(@"AudioQueueNewOutput() error: %d", err);


for (int i=0; i<AUDIO_BUFFERS; i++) {         
  err = AudioQueueAllocateBuffer(out.queue, out.frameSize, &out.mBuffers[i]);
  if (err != noErr) NSLog(@"Output AudioQueueAllocateBuffer() error: %d", err);
  out.mBuffers[i]->mAudioDataByteSize = out.frameSize;

  err = AudioQueueEnqueueBuffer(out.queue, out.mBuffers[i], 0, NULL);
  if (err != noErr) NSLog(@"Output AudioQueueEnqueueBuffer() error: %d", err);
}

AudioQueueStart(out.queue, nil);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:07:40+00:00Added an answer on June 1, 2026 at 11:07 pm

    I finally found out where the problem was: AudioQueue callback in simulator but not on device

    However, the output callback was properly fired in simulator but not on my device, and I still don’t know exactly why there are differences in the AudioSession settings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I start a process in c# like this: Process p= new Process(); p.StartInfo.FileName =
I can't convert a simple audio-only .flv to AAC format. The audio stream is
I am interested in finding out if there exists a program or library which
I have a very simple Activity to record audio using MediaRecorder . Basic start/stop
Possible Duplicate: Windows Vista/7: How to sample output audio mix? How to record what-you-hear
I would like to know how to start creating an Audio Streaming Player to
I'm working with Apple's MixerHost sample project, which sets up an audio unit processing
I usually use midentify, which spits out a nicely formatted string, that is easy
I've got 2 methods. One method starts playing an audio file (.mp3), the other
Start with a series of MS Office extensions built in C++ as COM objects.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.