Re: iPad USB Audio Output
Re: iPad USB Audio Output
- Subject: Re: iPad USB Audio Output
- From: Aran Mulholland <email@hidden>
- Date: Fri, 23 Sep 2011 10:45:35 +1000
You said "So to get USB Audio working through a DAC the AudioQueue API
has to employed."
I really doubt this. AudioQueue probably uses AudioUnits under the
surface anyway.
On Thu, Sep 22, 2011 at 6:19 PM, Stuart MacLean <email@hidden> wrote:
> Hi
>
> I managed to have success making the USB Audio work from the iPad. Instead
> of using the AudioUnit API to play sound I used the AudioQueue API for
> playback. So to get USB Audio working through a DAC the AudioQueue API has
> to employed.
>
> Cheers for the help.
>
> Stuart
>
> On 21/09/2011 03:07, Patrick Shirkey wrote:
>>>
>>> Stuart,
>>>
>>> This is more of an iOS issue, and probably belongs in the iOS Dev Center
>>> forums.
>>>
>>> I will briefly say, though, that my guess is that either your Duet 2
>>> is acting as a plain old lineout output route or it is interacting
>>> with the iPod app in a manner that you will not be able to capitalize
>>> on. I don't have a Duet 2, though, so I can't say for sure.
>>>
>> I agree it does sound like different functionality for the ipod and ipad.
>>
>>
>>
>>
>>
>>> On Tue, Sep 20, 2011 at 5:16 AM, Stuart MacLean<email@hidden>
>>> wrote:
>>>>
>>>> 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
>>>>
>>> _______________________________________________
>>> 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
>>>
>>
>> --
>> Patrick Shirkey
>> Boost Hardware Ltd
>
> _______________________________________________
> 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
>
_______________________________________________
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