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 9022183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:26:29+00:00 2026-06-16T05:26:29+00:00

Here is some code that sets the Audio Capture Buffer Size (in secs) union

  • 0

Here is some code that sets the Audio Capture Buffer Size (in secs)

union 
{
    OSStatus propertyResult;
    char a[4];
} u;

union
{
    UInt32 UI32sessionCat;
    char a[4];
} usc;

UInt32 UI32sessionCatSize = 4;
Float32 F32realIOBufferDuration = 0.0;
Float32 F32requestedIOBufferDuration = 0.5;
UInt32 F32datasize = 4;

u.propertyResult = AudioSessionGetProperty (  kAudioSessionProperty_PreferredHardwareIOBufferDuration , &F32datasize, &F32realIOBufferDuration );
NSLog(@"Error Get IO Duration Time %ld %lx %c%c%c%c",u.propertyResult,u.propertyResult,u.a[3],u.a[2],u.a[1],u.a[0]);
NSLog(@"IO Buffer Duration is %f",F32realIOBufferDuration);

u.propertyResult = AudioSessionSetProperty (  kAudioSessionProperty_PreferredHardwareIOBufferDuration ,sizeof(F32requestedIOBufferDuration) , &F32requestedIOBufferDuration );
NSLog(@"Error Set IO Duration Time %ld %lx %c%c%c%c",u.propertyResult,u.propertyResult,u.a[3],u.a[2],u.a[1],u.a[0]);

u.propertyResult = AudioSessionGetProperty (  kAudioSessionProperty_PreferredHardwareIOBufferDuration , &F32datasize, &F32realIOBufferDuration );
NSLog(@"Error Get IO Duration Time %ld %lx %c%c%c%c",u.propertyResult,u.propertyResult,u.a[3],u.a[2],u.a[1],u.a[0]);
NSLog(@"IO Buffer Duration is %f",F32realIOBufferDuration);

u.propertyResult = AudioSessionGetProperty (  kAudioSessionProperty_AudioCategory, &UI32sessionCatSize, &usc.UI32sessionCat );
NSLog(@"Error Get Property %ld %lx %c%c%c%c",u.propertyResult,u.propertyResult,u.a[3],u.a[2],u.a[1],u.a[0]);
NSLog(@"Category %ld %lx %c%c%c%c",usc.UI32sessionCat,usc.UI32sessionCat,usc.a[3],usc.a[2],usc.a[1],usc.a[0]);

Which seems to be working / setting the duration…

2012-01-25 12:28:01.275 recordonlytest[1623:707] Error Get IO Duration Time 0 0 
2012-01-25 12:28:01.276 recordonlytest[1623:707] IO Buffer Duration is 0.023000
2012-01-25 12:28:01.278 recordonlytest[1623:707] Error Set IO Duration Time 0 0 
2012-01-25 12:28:01.280 recordonlytest[1623:707] Error Get IO Duration Time 0 0 
2012-01-25 12:28:01.281 recordonlytest[1623:707] IO Buffer Duration is 0.500000
2012-01-25 12:28:01.283 recordonlytest[1623:707] Error Get Property 0 0 
2012-01-25 12:28:01.284 recordonlytest[1623:707] Category 1919247201 72656361 reca

You can see the get properties is indeed returning 0.50000

But the callbacks are still happening at the .023000 speed

2012-01-25 12:28:04.035 recordonlytest[1623:707] In Capture Output
2012-01-25 12:28:04.058 recordonlytest[1623:707] In Capture Output
2012-01-25 12:28:04.081 recordonlytest[1623:707] In Capture Output
2012-01-25 12:28:04.104 recordonlytest[1623:707] In Capture Output
2012-01-25 12:28:04.128 recordonlytest[1623:707] In Capture Output
2012-01-25 12:28:04.151 recordonlytest[1623:707] In Capture Output
2012-01-25 12:28:04.174 recordonlytest[1623:707] In Capture Output
2012-01-25 12:28:04.197 recordonlytest[1623:707] In Capture Output
2012-01-25 12:28:04.220 recordonlytest[1623:707] In Capture Output
2012-01-25 12:28:04.244 recordonlytest[1623:707] In Capture Output

This is getting set

 [self getRequestedSampleRate];  // routine to set the duration

 NSError* activationError = nil;

 [[AVAudioSession sharedInstance] setActive: YES error: &activationError];

 audioCaptureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio]; 
 captureSession = [[AVCaptureSession alloc] init];

So is there a different sequence, etc that needs to be done, or is IOS just ignoring this request?

  • 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-16T05:26:30+00:00Added an answer on June 16, 2026 at 5:26 am

    From here:

    While it is safe to set Audio Session properties such as audio category (kAudioSessionProperty_AudioCategory) or the property listener regardless of the sessions activation state, it is generally better to make preference requests such as preferred hardware buffer duration (kAudioSessionProperty_PreferredHardwareIOBufferDuration) or preferred hardware sample rate (kAudioSessionProperty_PreferredHardwareSampleRate) when the Audio Session is NOT active.

    You may be missing the:

    // * Activate the Audio Session before asking for the “Current” properties *
    AudioSessionSetActive(true);

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

Sidebar

Related Questions

I have some code in Python that sets a char(80) value in an sqlite
I have some code here that uses bitsets to store many 1 bit values
I've got some code here that works great on IPv4 machines, but on our
I have some code that is using SyncEnumerator. As you can see here ,
So I have some PHP code that looks like: $message = 'Here is the
Here's some example code: class Obj attr :c, true def == that p '=='
Just some example code here, but I have lists of strings that I want
I have some problems with this code? Here is my code that creates text
I have some code here that is supposed change display: none to display: block
I have some JavaScript code that creates some div elements and it sets their

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.