mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
Clean code of Audio route management
This commit is contained in:
parent
23d5b11186
commit
b13fe9c56f
7 changed files with 20 additions and 18 deletions
|
|
@ -7,8 +7,6 @@
|
|||
//
|
||||
|
||||
#import "AudioHelper.h"
|
||||
#import <AVFoundation/AVAudioSession.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@implementation AudioHelper
|
||||
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
|
||||
- (IBAction)onRoutesBluetoothClick:(id)sender {
|
||||
[self hideRoutes:TRUE animated:TRUE];
|
||||
[LinphoneManager.instance setSpeakerEnabled:FALSE];
|
||||
[LinphoneManager.instance setBluetoothEnabled:TRUE];
|
||||
}
|
||||
|
||||
|
|
@ -105,6 +106,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
|
||||
- (IBAction)onRoutesSpeakerClick:(id)sender {
|
||||
[self hideRoutes:TRUE animated:TRUE];
|
||||
[LinphoneManager.instance setBluetoothEnabled:FALSE];
|
||||
[LinphoneManager.instance setSpeakerEnabled:TRUE];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -711,6 +711,7 @@ static void hideSpinner(LinphoneCall *call, void *user_data) {
|
|||
|
||||
- (IBAction)onRoutesBluetoothClick:(id)sender {
|
||||
[self hideRoutes:TRUE animated:TRUE];
|
||||
[LinphoneManager.instance setSpeakerEnabled:FALSE];
|
||||
[LinphoneManager.instance setBluetoothEnabled:TRUE];
|
||||
}
|
||||
|
||||
|
|
@ -722,6 +723,7 @@ static void hideSpinner(LinphoneCall *call, void *user_data) {
|
|||
|
||||
- (IBAction)onRoutesSpeakerClick:(id)sender {
|
||||
[self hideRoutes:TRUE animated:TRUE];
|
||||
[LinphoneManager.instance setBluetoothEnabled:FALSE];
|
||||
[LinphoneManager.instance setSpeakerEnabled:TRUE];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2564,17 +2564,14 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
|
||||
- (void)setSpeakerEnabled:(BOOL)enable {
|
||||
_speakerEnabled = enable;
|
||||
UInt32 override = kAudioSessionUnspecifiedError;
|
||||
NSError *err;
|
||||
|
||||
if (override != kAudioSessionNoError) {
|
||||
if (enable && [self allowSpeaker]) {
|
||||
[[AVAudioSession sharedInstance] overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:&err];
|
||||
_bluetoothEnabled = FALSE;
|
||||
} else {
|
||||
AVAudioSessionPortDescription *builtinPort = [AudioHelper builtinAudioDevice];
|
||||
[[AVAudioSession sharedInstance] setPreferredInput:builtinPort error:&err];
|
||||
}
|
||||
if (enable && [self allowSpeaker]) {
|
||||
[[AVAudioSession sharedInstance] overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:&err];
|
||||
_bluetoothEnabled = FALSE;
|
||||
} else {
|
||||
AVAudioSessionPortDescription *builtinPort = [AudioHelper builtinAudioDevice];
|
||||
[[AVAudioSession sharedInstance] setPreferredInput:builtinPort error:&err];
|
||||
}
|
||||
|
||||
if (err) {
|
||||
|
|
@ -2593,7 +2590,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
// if setting bluetooth failed, it must be because the device is not available
|
||||
// anymore (disconnected), so deactivate bluetooth.
|
||||
if (err) {
|
||||
_bluetoothAvailable = _bluetoothEnabled = FALSE;
|
||||
_bluetoothEnabled = FALSE;
|
||||
} else {
|
||||
_speakerEnabled = FALSE;
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -31,13 +31,13 @@
|
|||
LOGE(@"UIBluetoothButton error for %s: ret=%ld", method, au)
|
||||
|
||||
- (void)onOn {
|
||||
AVAudioSessionPortDescription *_bluetoothPort = [AudioHelper bluetoothAudioDevice];
|
||||
[[AVAudioSession sharedInstance] setPreferredInput:_bluetoothPort error:nil];
|
||||
// AVAudioSessionPortDescription *_bluetoothPort = [AudioHelper bluetoothAudioDevice];
|
||||
//[[AVAudioSession sharedInstance] setPreferredInput:_bluetoothPort error:nil];
|
||||
}
|
||||
|
||||
- (void)onOff {
|
||||
AVAudioSessionPortDescription *builtinPort = [AudioHelper builtinAudioDevice];
|
||||
[[AVAudioSession sharedInstance] setPreferredInput:builtinPort error:nil];
|
||||
// AVAudioSessionPortDescription *builtinPort = [AudioHelper builtinAudioDevice];
|
||||
//[[AVAudioSession sharedInstance] setPreferredInput:builtinPort error:nil];
|
||||
}
|
||||
|
||||
- (bool)onUpdate {
|
||||
|
|
|
|||
|
|
@ -52,11 +52,11 @@ INIT_WITH_COMMON_CF {
|
|||
}
|
||||
|
||||
- (void)onOn {
|
||||
[LinphoneManager.instance setSpeakerEnabled:TRUE];
|
||||
//[LinphoneManager.instance setSpeakerEnabled:TRUE];
|
||||
}
|
||||
|
||||
- (void)onOff {
|
||||
[LinphoneManager.instance setSpeakerEnabled:FALSE];
|
||||
//[LinphoneManager.instance setSpeakerEnabled:FALSE];
|
||||
}
|
||||
|
||||
- (bool)onUpdate {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@
|
|||
#ifndef AudioHelper_h
|
||||
#define AudioHelper_h
|
||||
|
||||
#import <AVFoundation/AVAudioSession.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface AudioHelper : NSObject
|
||||
|
||||
+ (NSArray *)bluetoothRoutes;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue