From 6b4dedfefeabf594c887fca517327dedeceae39a Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 2 Feb 2017 15:52:11 -0500 Subject: [PATCH] revert WebRTC related changes to AppAudioManager Initially we were using AppAudioManager in our WebRTC calling implementation to manage call related audio, but our differences from how redphone uses the AppAudioManager diverged too much, so instead we're instead using CallAudioManager. reverting these changes lest we inadvertently break something re: RedPhone. // FREEBIE --- Signal/src/audio/AppAudioManager.h | 11 +--- Signal/src/audio/AppAudioManager.m | 55 ++++++------------- .../view controllers/InCallViewController.m | 2 +- 3 files changed, 19 insertions(+), 49 deletions(-) diff --git a/Signal/src/audio/AppAudioManager.h b/Signal/src/audio/AppAudioManager.h index 64ee64f58..e3512da73 100644 --- a/Signal/src/audio/AppAudioManager.h +++ b/Signal/src/audio/AppAudioManager.h @@ -14,8 +14,6 @@ @import AVFoundation; -NS_ASSUME_NONNULL_BEGIN - @interface AppAudioManager : NSObject enum AudioProfile { @@ -33,9 +31,7 @@ enum AudioProfile { - (void)respondToTerminationType:(enum CallTerminationType)terminationType; - (BOOL)toggleSpeakerPhone; -- (void)toggleSpeakerPhoneIsEnabled:(BOOL)enabled NS_SWIFT_NAME(toggleSpeakerPhone(isEnabled:)); - -- (void)cancelAllAudio; +- (void)cancellAllAudio; - (void)requestRequiredPermissionsIfNeededWithCompletion:(PermissionBlock)permissionBlock incoming:(BOOL)isIncoming; - (BOOL)requestRecordingPrivilege; @@ -46,9 +42,4 @@ enum AudioProfile { - (void)didCompleteSoundInstanceOfType:(SoundInstanceType)instanceType; -- (void)handleInboundRing; -- (void)setDefaultAudioProfile; - @end - -NS_ASSUME_NONNULL_END diff --git a/Signal/src/audio/AppAudioManager.m b/Signal/src/audio/AppAudioManager.m index abc1bba66..d901e7616 100644 --- a/Signal/src/audio/AppAudioManager.m +++ b/Signal/src/audio/AppAudioManager.m @@ -3,7 +3,6 @@ #import "AudioRouter.h" #import "SoundBoard.h" -NS_ASSUME_NONNULL_BEGIN #define DEFAULT_CATEGORY AVAudioSessionCategorySoloAmbient #define RECORDING_CATEGORY AVAudioSessionCategoryPlayAndRecord @@ -35,8 +34,8 @@ AppAudioManager *sharedAppAudioManager; #pragma mark AudioState Management - (void)setAudioProfile:(enum AudioProfile)profile { - _audioProfile = profile; [self updateAudioRouter]; + _audioProfile = profile; } - (void)updateAudioRouter { @@ -56,6 +55,17 @@ AppAudioManager *sharedAppAudioManager; } } + +- (void)overrideAudioProfile { + isSpeakerphoneActive = YES; + [self updateAudioRouter]; +} + +- (void)resetOverride { + isSpeakerphoneActive = NO; + [self updateAudioRouter]; +} + - (enum AudioProfile)getCurrentAudioProfile { return (isSpeakerphoneActive) ? AudioProfile_ExternalSpeaker : _audioProfile; } @@ -100,33 +110,24 @@ AppAudioManager *sharedAppAudioManager; } - (void)handleInboundRing { - [self setAudioProfile:AudioProfile_ExternalSpeaker]; [_soundPlayer playSound:[SoundBoard instanceOfInboundRingtone]]; } - (void)handleOutboundRing { - [self setDefaultAudioProfile]; + [self setAudioProfile:AudioProfile_Default]; [_soundPlayer playSound:[SoundBoard instanceOfOutboundRingtone]]; } - (void)handleSecuring { [_soundPlayer stopAllAudio]; - [self setDefaultAudioProfile]; + [self setAudioProfile:AudioProfile_Default]; [_soundPlayer playSound:[SoundBoard instanceOfHandshakeSound]]; } - (void)handleCallEstablished { [_soundPlayer stopAllAudio]; - [self setDefaultAudioProfile]; - [_soundPlayer playSound:[SoundBoard instanceOfCompletedSound]]; -} - -/** - * Route traffic through internal speaker, unless speakerphone is enabled. - */ -- (void)setDefaultAudioProfile -{ [self setAudioProfile:AudioProfile_Default]; + [_soundPlayer playSound:[SoundBoard instanceOfCompletedSound]]; } - (BOOL)toggleSpeakerPhone { @@ -136,17 +137,9 @@ AppAudioManager *sharedAppAudioManager; return isSpeakerphoneActive; } -- (void)toggleSpeakerPhoneIsEnabled:(BOOL)enabled -{ - DDLogInfo(@"%@ Toggled speaker phone: %@", self.tag, enabled ? @"ON" : @"OFF"); - isSpeakerphoneActive = enabled; - [self updateAudioRouter]; -} - #pragma mark Audio Control -- (void)cancelAllAudio -{ +- (void)cancellAllAudio { [_soundPlayer stopAllAudio]; } @@ -203,8 +196,7 @@ AppAudioManager *sharedAppAudioManager; return (nil != e); } -- (void)awake -{ +- (void)awake { [_soundPlayer awake]; } @@ -217,18 +209,5 @@ AppAudioManager *sharedAppAudioManager; } } -#pragma mark - Logging - -+ (NSString *)tag -{ - return [NSString stringWithFormat:@"[%@]", self.class]; -} - -- (NSString *)tag -{ - return self.class.tag; -} @end - -NS_ASSUME_NONNULL_END diff --git a/Signal/src/view controllers/InCallViewController.m b/Signal/src/view controllers/InCallViewController.m index 19944af34..a8278c42c 100644 --- a/Signal/src/view controllers/InCallViewController.m +++ b/Signal/src/view controllers/InCallViewController.m @@ -61,7 +61,7 @@ [super viewWillDisappear:animated]; [self stopRingingAnimation]; [self stopConnectingFlashAnimation]; - [AppAudioManager.sharedInstance cancelAllAudio]; + [AppAudioManager.sharedInstance cancellAllAudio]; [UIDevice.currentDevice setProximityMonitoringEnabled:NO]; }