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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:57:16+00:00 2026-06-16T23:57:16+00:00

I am trying to get microphone input from Core Audio (the Remote I/O audio

  • 0

I am trying to get microphone input from Core Audio (the Remote I/O audio unit) with the following code:

- (void)audioAU
{
    enum : AudioUnitElement {
        kOutputElement = 0,
        kInputElement = 1
    };
    const UInt32 disableFlag = 0;
    const UInt32 enableFlag = 1;

    OSStatus err = noErr;
    NSError *error = nil;


    // Configure & activate audio session

    AVAudioSession *session = [AVAudioSession sharedInstance];

    if (![session setCategory:AVAudioSessionCategoryRecord error:&error]) NSLog(@"Error configuring session category: %@", error);
    if (![session setMode:AVAudioSessionModeMeasurement error:&error]) NSLog(@"Error configuring session mode: %@", error);
    if (![session setActive:YES error:&error]) NSLog(@"Error activating audio session: %@", error);

    NSLog(@"Session activated. sample rate %f", session.sampleRate);
    NSLog(@"Number of channels %d", session.inputNumberOfChannels);


    // Set up Remote I/O audio unit for audio capture

    AudioComponent component = AudioComponentFindNext(NULL, &(const AudioComponentDescription){
        .componentType = kAudioUnitType_Output,
        .componentSubType = kAudioUnitSubType_RemoteIO,
        .componentManufacturer = kAudioUnitManufacturer_Apple,
        .componentFlags = 0,
        .componentFlagsMask = 0
    });

    AudioComponentInstance unit;

    // Create audio component
    err = AudioComponentInstanceNew(component, &unit);
    if (err != noErr) NSLog(@"Error instantiating audio unit: %ld", err);

    // Enable input
    err = AudioUnitSetProperty(unit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, kInputElement, &enableFlag, sizeof(enableFlag));
    if (err != noErr) NSLog(@"Error enabling input for audio unit: %ld", err);

    AudioStreamBasicDescription streamDesc = {
        .mSampleRate = session.sampleRate,
        .mFormatID = kAudioFormatLinearPCM,
        .mFormatFlags = kAudioFormatFlagsAudioUnitCanonical /*matches AudioUnitSampleType*/ | kAudioFormatFlagIsNonInterleaved,
        .mBytesPerPacket = sizeof(AudioUnitSampleType),
        .mFramesPerPacket = 1,
        .mBytesPerFrame = sizeof(AudioUnitSampleType) * session.inputNumberOfChannels,
        .mChannelsPerFrame = session.inputNumberOfChannels,
        .mBitsPerChannel = 8 * sizeof(AudioUnitSampleType),
        .mReserved = 0,
    };
    err = AudioUnitSetProperty(unit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, kOutputElement, &streamDesc, sizeof(streamDesc));
    if (err != noErr) NSLog(@"Error configuring input stream format for audio unit: %ld", err);

    AURenderCallbackStruct callbacks = {
        .inputProc = renderCallback,
        .inputProcRefCon = unit
    };
    err = AudioUnitSetProperty(unit, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Input, kOutputElement, &callbacks, sizeof(callbacks));
    if (err != noErr) NSLog(@"Error configuring input callbacks for audio unit: %ld", err);

    err = AudioUnitInitialize(unit);
    if (err != noErr) NSLog(@"Error initializing audio unit: %ld", err);

    err = AudioOutputUnitStart(unit);
    if (err != noErr) NSLog(@"Error starting audio unit: %ld", err);

//  err = AudioComponentInstanceDispose(unit);
//  if (err != noErr) NSLog(@"Error disposing audio unit: %ld", err);
}

It works (or at least doesn’t crash) in the simulator, but I get this output when running on an iPhone 5:

Session activated. sample rate 44100.000000
Number of channels 1
15:48:45.170 <com.apple.main-thread> shm_open failed: "AppleAURemoteIO.o.262da" (23) flags=0x2 errno=2
15:48:45.172 <com.apple.main-thread> AURemoteIO::ChangeHardwareFormats: error 3
15:48:45.333 <com.apple.main-thread> shm_open failed: "AppleAURemoteIO.o.262da" (23) flags=0x2 errno=2
15:48:45.336 <com.apple.main-thread> AURemoteIO::ChangeHardwareFormats: error 3
15:48:45.497 <com.apple.main-thread> shm_open failed: "AppleAURemoteIO.o.262da" (23) flags=0x2 errno=2
15:48:45.499 <com.apple.main-thread> AURemoteIO::ChangeHardwareFormats: error 3
15:48:45.669 <com.apple.main-thread> shm_open failed: "AppleAURemoteIO.o.262da" (23) flags=0x2 errno=2
15:48:45.671 <com.apple.main-thread> AURemoteIO::ChangeHardwareFormats: error 3
15:48:45.839 <com.apple.main-thread> shm_open failed: "AppleAURemoteIO.o.262da" (23) flags=0x2 errno=2
15:48:45.841 <com.apple.main-thread> AURemoteIO::ChangeHardwareFormats: error 3
Error initializing audio unit: 3
  • 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-16T23:57:17+00:00Added an answer on June 16, 2026 at 11:57 pm

    It turns out that when using AVAudioSessionCategoryRecord (or equivalently, kAudioSessionCategory_RecordAudio from the C APIs), you must also disable output on the audio unit:

        ...
        // Disable output
        err = AudioUnitSetProperty(unit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, kOutputElement, &disableFlag, sizeof(disableFlag));
        if (err != noErr) NSLog(@"Error disabling output for audio unit: %ld", err);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying get values from a GridView using the following code: foreach (GridViewRow row
I am trying to stream microphone input from my Symbian device (Nokia N8) to
I'm trying get some licensing code from AndroidPit.com working, but I get Unable to
In the following code i am trying to save the microphone contents to a
I'm trying get the visible portion of UIImage from an UIImageView . UIImageView takes
I'm building an application which records audio from the microphone to a file (.mp3).
I am trying get my head around how you can run the following php:
I'm trying to create my own custom sound effects Audio Unit based on the
below is my code through which I'm trying get certain values to a drop
I was trying to get the amplitude level of a microphone on Android like

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.