• 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
iPad USB Audio Output
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

iPad USB Audio Output


  • Subject: iPad USB Audio Output
  • From: Stuart MacLean <email@hidden>
  • Date: Tue, 20 Sep 2011 10:16:06 +0100

Hi

I am trying to support the ability to playback audio through an external DAC connected to an iPad via USB
using the Camera Connector Kit employing CoreAudio. However I have not had any luck in getting any audio
output from my app to my external DAC. My specific setup is


iPad -> Camera Connector Kit -> USB Hub -> Apogee Duet 2 -> Amplifier

I know this setup works as I am able to successfully play music through the iPod App to my external DAC.

I have attached the code I am using to configure the AudioSession and open RemoteIO Audio Unit for rendering the audio output below.

Now I have tried a number of different types of stream formats (but tried to keep it to 44.1kHz at 16bit PCM sample) and I see the
audio route change to 'USB' when connected. But I have not been able to get any playback through the external DAC.


So I was wondering if anyone can help me to get this working?

With kind regards

Stuart MacLean

//-------------------------------------------------------------------------------------------

- (bool) openAudio
{
    OSStatus err;
    AudioComponent comp;
    AudioComponentDescription ioUnitDescription;

    ioUnitDescription.componentType = kAudioUnitType_Output;
    ioUnitDescription.componentSubType = kAudioUnitSubType_RemoteIO;
    ioUnitDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
    ioUnitDescription.componentFlags = 0;
    ioUnitDescription.componentFlagsMask = 0;

    comp = AudioComponentFindNext(0,&ioUnitDescription);
    if(comp==0)
        return false;
    err = AudioComponentInstanceNew(comp,&m_audioOutputUnit);
    if(err!=noErr)
        return false;

UInt32 enableIO = 1;
err = AudioUnitSetProperty(m_audioOutputUnit,kAudioOutputUnitProperty_EnableIO,kAudioUnitScope_Output,0,&enableIO,sizeof(enableIO));
if(err!=noErr)
return false;


AudioStreamBasicDescription streamFormat;
memset(&streamFormat,0,sizeof(AudioStreamBasicDescription));
streamFormat.mFormatID = kAudioFormatLinearPCM;
streamFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
streamFormat.mSampleRate = 44100.0;
streamFormat.mFramesPerPacket = 1;
streamFormat.mBitsPerChannel = 16;
streamFormat.mBytesPerPacket = 2;
streamFormat.mBytesPerFrame = 2;
streamFormat.mChannelsPerFrame = 1;


err = AudioUnitSetProperty(m_audioOutputUnit,kAudioUnitProperty_StreamFormat,kAudioUnitScope_Input,0,&streamFormat,sizeof(AudioStreamBasicDescription));
if(err!=noErr)
return false;


    AURenderCallbackStruct renderCallback;
    memset(&renderCallback,0,sizeof(AURenderCallbackStruct));
    renderCallback.inputProc = OmegaAudioCallbackIOProc;
    renderCallback.inputProcRefCon = (void *)(self);

err = AudioUnitSetProperty(m_audioOutputUnit,kAudioUnitProperty_SetRenderCallback,kAudioUnitScope_Global,0,&renderCallback,sizeof(renderCallback));
if(err!=noErr)
return false;


    err = AudioUnitInitialize(m_audioOutputUnit);
    if(err!=noErr)
        return false;

    err = AudioOutputUnitStart(m_audioOutputUnit);
    if(err!=noErr)
        return false;

    return true;
}

//-------------------------------------------------------------------------------------------

- (void) setupAudioSession
{
    AVAudioSession *aSession = [AVAudioSession sharedInstance];

    [aSession setDelegate:self];

NSError *audioSessionError = nil;
[aSession setCategory:AVAudioSessionCategoryPlayback error:&audioSessionError];
if(audioSessionError!=nil)
{
NSLog(@"Error setting audio session category.");
return;
}


[aSession setPreferredHardwareSampleRate:44100.0 error:&audioSessionError];
if(audioSessionError!=nil)
{
NSLog(@"Error setting preferred audio hardware sample rate.");
return;
}


UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory,sizeof(sessionCategory),&sessionCategory);


UInt32 allowMixing = false;
AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers,sizeof(allowMixing),&allowMixing);


    [aSession setActive:YES error:&audioSessionError];
    if(audioSessionError!=nil)
    {
        NSLog(@"Error activating audio session during initial setup.");
        return;
    }

AudioSessionAddPropertyListener(kAudioSessionProperty_AudioRouteChange,audioRouteChangeListenerCallback,(void*)self);
}


//-------------------------------------------------------------------------------------------

_______________________________________________
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


  • Follow-Ups:
    • Re: iPad USB Audio Output
      • From: Bill Phillips <email@hidden>
    • Re: iPad USB Audio Output
      • From: Rick Sustek <email@hidden>
  • Prev by Date: Re: where to start with converting an mp3 file to pcm
  • Next by Date: Re: where to start with converting an mp3 file to pcm
  • Previous by thread: Re: where to start with converting an mp3 file to pcm
  • Next by thread: Re: iPad USB Audio Output
  • Index(es):
    • Date
    • Thread