Keep Bluetooth Sound When Initializing Avaudiosession

Keep bluetooth sound when initializing AVAudioSession

Unfortunately I got this answer directly from Apple Technical Support

There is no supported way to achieve the desired functionality given the currently shipping system configurations. If you would like for Apple to consider adding support for such features in the future, please submit an enhancement request via the Bug Reporter tool at http://bugreport.apple.com.

So that's it...

AudioSession Removes the Bluetooth functionality

I've been dealing with this same problem since May 2014.

I made this question here: Keep bluetooth sound when initializing AVAudioSession and also tried opening a paid support ticket with Apple that you can see their response as an answer on that question. But here it is for reference as well:

There is no supported way to achieve the desired functionality given the currently shipping system configurations. If you would like for Apple to consider adding support for such features in the future, please submit an enhancement request via the Bug Reporter tool at http://bugreport.apple.com.

So since there was no supported way, I made a proper feature request on their bug reporting system, which they never replied to me, until this week, when they said:

This is an older report and much has changed since it was filed. We are closing it. If this is still an issue for you, or if you have questions regarding the resolution of this issue, please update your bug report with them.

So, I checked with the latest iOS versions, betas, etc. Still the same.

So unless I'm missing something new, unfortunately the answer is: "We can't record and play through BlueTooth at the same time"

Hopefully you'll post your findings if you ever find a way to do it.

AVAudioSession properties after Initializing AUGraph

This is expected behavior per the developer documentation, inputDataSource should return nil if it is not possible to switch sources. So Apple is really not letting anything bad happen via a mis-config, but a nil source can also give the wrong idea. Hope this helps.

Discussion
The value of this property is nil if switching between multiple input
sources is not currently possible. This feature is supported only on
certain devices and peripherals–for example, on an iPhone equipped with
both front- and rear-facing microphones.

AVAudioSession manipulate sound output

So, I found solution for manipulating with sound output.

You could initialize sound settings with AVAudioSession

Something like this:

session = [AVAudioSession sharedInstance];

BOOL success;
NSError* error;

success = [session setCategory:AVAudioSessionCategoryPlayAndRecord error:&error];

if (!success) NSLog(@"AVAudioSession error setting category:%@",error);
success = [session setMode:AVAudioSessionModeVoiceChat error:&error];

if (!success) NSLog(@"AVAudioSession error setting mode:%@",error);

success = [session overrideOutputAudioPort:AVAudioSessionPortOverrideNone error:&error];

[session setPreferredOutputNumberOfChannels:0 error:nil];
if (!success) NSLog(@"AVAudioSession error overrideOutputAudioPort:%@",error);

success = [session setActive:YES error:&error];
if (!success) NSLog(@"AVAudioSession error activating: %@",error);
else NSLog(@"audioSession active");

With

[session overrideOutputAudioPort:AVAudioSessionPortOverrideNone error:&error];

You set don't override output port. And your app playing with default speaker. As I understand for mode AVAudioSessionModeVoiceChat used phone speaker. It's directly what I need for my SIP caller app.

Then you can override output port with

[session overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:&error];

I do it so:

- (void) loudSpeakerOn:(BOOL)isLoudSpeaker{
[session setActive:NO error:nil];

BOOL success;
NSError* error;

success = [session overrideOutputAudioPort:isLoudSpeaker?AVAudioSessionPortOverrideSpeaker:AVAudioSessionPortOverrideNone error:&error];

if (!success) NSLog(@"AVAudioSession error setting category:%@",error);

[session setActive:YES error:nil];
}


Related Topics



Leave a reply



Submit