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!oErr)
return false;
UInt32 enableIO = 1;
err =
AudioUnitSetProperty(m_audioOutputUnit,kAudioOutputUnitProperty_EnableIO,kAudioUnitScope_Output,0,&enableIO,sizeof(enableIO));
if(err!oErr)
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!oErr)
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!oErr)
return false;
err = AudioUnitInitialize(m_audioOutputUnit);
if(err!oErr)
return false;
err = AudioOutputUnitStart(m_audioOutputUnit);
if(err!oErr)
return false;
return true;
}
//-------------------------------------------------------------------------------------------
- (void) setupAudioSession
{
AVAudioSession *aSession = [AVAudioSession sharedInstance];
[aSession setDelegate:self];
NSError *audioSessionError = nil;
[aSession setCategory:AVAudioSessionCategoryPlayback
error:&audioSessionError];
if(audioSessionError!il)
{
NSLog(@"Error setting audio session category.");
return;
}
[aSession setPreferredHardwareSampleRate:44100.0
error:&audioSessionError];
if(audioSessionError!il)
{
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!il)
{
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