Commit d67d0020 authored by jehan's avatar jehan

restaure audioSession in play/record for backward compatibility with IOS3.x

parent 47f19a37
......@@ -257,23 +257,24 @@ static void au_configure(AUData *d) {
AudioComponentDescription au_description;
AudioComponent foundComponent;
OSStatus auresult;
UInt32 doSetProperty = 1;
UInt32 doNotSetProperty = 0;
auresult = AudioSessionSetActive(true);
check_auresult(auresult,"AudioSessionSetActive");
UInt32 audioCategory;
UInt32 audioCategory =kAudioSessionCategory_PlayAndRecord;
auresult =AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(audioCategory), &audioCategory);
check_auresult(auresult,"Configuring audio session ");
if (d->is_ringer) {
audioCategory= kAudioSessionCategory_MediaPlayback;
ms_message("Configuring audio session for play back");
auresult=AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryDefaultToSpeaker,sizeof (doSetProperty),&doSetProperty);
check_auresult(auresult,"kAudioSessionProperty_OverrideAudioRoute");
ms_message("Configuring audio session default route to speaker");
} else {
audioCategory = kAudioSessionCategory_PlayAndRecord;
ms_message("Configuring audio session for play back/record");
ms_message("Configuring audio session default route to receiver");
}
auresult =AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(audioCategory), &audioCategory);
check_auresult(auresult,"Configuring audio session ");
if (d->started == TRUE) {
//nothing else to do
return;
......@@ -299,38 +300,33 @@ static void au_configure(AUData *d) {
audioFormat.mBitsPerChannel = d->bits;
audioFormat.mBytesPerPacket = d->bits / 8;
audioFormat.mBytesPerFrame = d->nchannels * d->bits / 8;
UInt32 doSetProperty = 1;
UInt32 doNotSetProperty = 0;
AudioUnitElement outputBus = 0;
AudioUnitElement inputBus = 1;
auresult=AudioUnitUninitialize (d->io_unit);
check_auresult(auresult,"AudioUnitUninitialize");
if (!d->is_ringer) {
//read
auresult=AudioUnitSetProperty (
d->io_unit,
kAudioOutputUnitProperty_EnableIO,
kAudioUnitScope_Input ,
inputBus,
&doSetProperty,
sizeof (doSetProperty)
);
check_auresult(auresult,"kAudioOutputUnitProperty_EnableIO,kAudioUnitScope_Input");
auresult=AudioUnitSetProperty (
d->io_unit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output,
inputBus,
&audioFormat,
sizeof (audioFormat)
);
check_auresult(auresult,"kAudioUnitProperty_StreamFormat,kAudioUnitScope_Output");
}
//write
//read
auresult=AudioUnitSetProperty (
d->io_unit,
kAudioOutputUnitProperty_EnableIO,
kAudioUnitScope_Input ,
inputBus,
&doSetProperty,
sizeof (doSetProperty)
);
check_auresult(auresult,"kAudioOutputUnitProperty_EnableIO,kAudioUnitScope_Input");
//setup stream format
auresult=AudioUnitSetProperty (
d->io_unit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input,
outputBus,
&audioFormat,
sizeof (audioFormat)
);
//write
//enable output bus
auresult =AudioUnitSetProperty (
d->io_unit,
......@@ -346,11 +342,13 @@ static void au_configure(AUData *d) {
auresult=AudioUnitSetProperty (
d->io_unit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input,
outputBus,
kAudioUnitScope_Output,
inputBus,
&audioFormat,
sizeof (audioFormat)
);
check_auresult(auresult,"kAudioUnitProperty_StreamFormat,kAudioUnitScope_Output");
check_auresult(auresult,"kAudioUnitProperty_StreamFormat,kAudioUnitScope_Input");
//disable unit buffer allocation
......@@ -387,8 +385,6 @@ static void au_configure(AUData *d) {
check_auresult(auresult,"kAudioSessionProperty_PreferredHardwareSampleRate");
//start io unit
auresult=AudioUnitInitialize (d->io_unit);
Float32 preferredBufferSize;
switch (d->rate) {
case 11025:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment