mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 19:18:06 +00:00
Fix issue with speaker and headset(disabled speaker)
This commit is contained in:
parent
5a8f48fa5b
commit
abfa99d3d8
3 changed files with 21 additions and 1 deletions
|
|
@ -132,6 +132,8 @@ typedef struct _LinphoneManagerSounds {
|
|||
|
||||
- (void)refreshRegisters;
|
||||
|
||||
- (bool)allowSpeaker;
|
||||
|
||||
+ (BOOL)copyFile:(NSString*)src destination:(NSString*)dst override:(BOOL)override;
|
||||
+ (NSString*)bundleFile:(NSString*)file;
|
||||
+ (NSString*)documentFile:(NSString*)file;
|
||||
|
|
|
|||
|
|
@ -1115,6 +1115,23 @@ static int comp_call_state_paused (const LinphoneCall* call, const void* param)
|
|||
|
||||
#pragma mark - Speaker Functions
|
||||
|
||||
- (bool)allowSpeaker {
|
||||
bool notallow = false;
|
||||
CFStringRef lNewRoute = CFSTR("Unknown");
|
||||
UInt32 lNewRouteSize = sizeof(lNewRoute);
|
||||
OSStatus lStatus = AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &lNewRouteSize, &lNewRoute);
|
||||
if (!lStatus && lNewRouteSize > 0) {
|
||||
NSString *route = (NSString *) lNewRoute;
|
||||
notallow = [route isEqualToString: @"Headset"] ||
|
||||
[route isEqualToString: @"Headphone"] ||
|
||||
[route isEqualToString: @"HeadphonesAndMicrophone"] ||
|
||||
[route isEqualToString: @"HeadsetInOut"] ||
|
||||
[route isEqualToString: @"Lineout"];
|
||||
CFRelease(lNewRoute);
|
||||
}
|
||||
return !notallow;
|
||||
}
|
||||
|
||||
static void audioRouteChangeListenerCallback (
|
||||
void *inUserData, // 1
|
||||
AudioSessionPropertyID inPropertyID, // 2
|
||||
|
|
@ -1142,7 +1159,7 @@ static void audioRouteChangeListenerCallback (
|
|||
|
||||
- (void)setSpeakerEnabled:(BOOL)enable {
|
||||
speakerEnabled = enable;
|
||||
if(enable) {
|
||||
if(enable && [self allowSpeaker]) {
|
||||
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
|
||||
AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute
|
||||
, sizeof (audioRouteOverride)
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ static void audioRouteChangeListenerCallback (
|
|||
}
|
||||
|
||||
- (bool)onUpdate {
|
||||
[self setEnabled:[[LinphoneManager instance] allowSpeaker]];
|
||||
return [[LinphoneManager instance] speakerEnabled];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue