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
pull/1/head
Michael Kirk 8 years ago
parent b6f098bfa7
commit 6b4dedfefe

@ -14,8 +14,6 @@
@import AVFoundation; @import AVFoundation;
NS_ASSUME_NONNULL_BEGIN
@interface AppAudioManager : NSObject <SoundPlayerDelegate> @interface AppAudioManager : NSObject <SoundPlayerDelegate>
enum AudioProfile { enum AudioProfile {
@ -33,9 +31,7 @@ enum AudioProfile {
- (void)respondToTerminationType:(enum CallTerminationType)terminationType; - (void)respondToTerminationType:(enum CallTerminationType)terminationType;
- (BOOL)toggleSpeakerPhone; - (BOOL)toggleSpeakerPhone;
- (void)toggleSpeakerPhoneIsEnabled:(BOOL)enabled NS_SWIFT_NAME(toggleSpeakerPhone(isEnabled:)); - (void)cancellAllAudio;
- (void)cancelAllAudio;
- (void)requestRequiredPermissionsIfNeededWithCompletion:(PermissionBlock)permissionBlock incoming:(BOOL)isIncoming; - (void)requestRequiredPermissionsIfNeededWithCompletion:(PermissionBlock)permissionBlock incoming:(BOOL)isIncoming;
- (BOOL)requestRecordingPrivilege; - (BOOL)requestRecordingPrivilege;
@ -46,9 +42,4 @@ enum AudioProfile {
- (void)didCompleteSoundInstanceOfType:(SoundInstanceType)instanceType; - (void)didCompleteSoundInstanceOfType:(SoundInstanceType)instanceType;
- (void)handleInboundRing;
- (void)setDefaultAudioProfile;
@end @end
NS_ASSUME_NONNULL_END

@ -3,7 +3,6 @@
#import "AudioRouter.h" #import "AudioRouter.h"
#import "SoundBoard.h" #import "SoundBoard.h"
NS_ASSUME_NONNULL_BEGIN
#define DEFAULT_CATEGORY AVAudioSessionCategorySoloAmbient #define DEFAULT_CATEGORY AVAudioSessionCategorySoloAmbient
#define RECORDING_CATEGORY AVAudioSessionCategoryPlayAndRecord #define RECORDING_CATEGORY AVAudioSessionCategoryPlayAndRecord
@ -35,8 +34,8 @@ AppAudioManager *sharedAppAudioManager;
#pragma mark AudioState Management #pragma mark AudioState Management
- (void)setAudioProfile:(enum AudioProfile)profile { - (void)setAudioProfile:(enum AudioProfile)profile {
_audioProfile = profile;
[self updateAudioRouter]; [self updateAudioRouter];
_audioProfile = profile;
} }
- (void)updateAudioRouter { - (void)updateAudioRouter {
@ -56,6 +55,17 @@ AppAudioManager *sharedAppAudioManager;
} }
} }
- (void)overrideAudioProfile {
isSpeakerphoneActive = YES;
[self updateAudioRouter];
}
- (void)resetOverride {
isSpeakerphoneActive = NO;
[self updateAudioRouter];
}
- (enum AudioProfile)getCurrentAudioProfile { - (enum AudioProfile)getCurrentAudioProfile {
return (isSpeakerphoneActive) ? AudioProfile_ExternalSpeaker : _audioProfile; return (isSpeakerphoneActive) ? AudioProfile_ExternalSpeaker : _audioProfile;
} }
@ -100,33 +110,24 @@ AppAudioManager *sharedAppAudioManager;
} }
- (void)handleInboundRing { - (void)handleInboundRing {
[self setAudioProfile:AudioProfile_ExternalSpeaker];
[_soundPlayer playSound:[SoundBoard instanceOfInboundRingtone]]; [_soundPlayer playSound:[SoundBoard instanceOfInboundRingtone]];
} }
- (void)handleOutboundRing { - (void)handleOutboundRing {
[self setDefaultAudioProfile]; [self setAudioProfile:AudioProfile_Default];
[_soundPlayer playSound:[SoundBoard instanceOfOutboundRingtone]]; [_soundPlayer playSound:[SoundBoard instanceOfOutboundRingtone]];
} }
- (void)handleSecuring { - (void)handleSecuring {
[_soundPlayer stopAllAudio]; [_soundPlayer stopAllAudio];
[self setDefaultAudioProfile]; [self setAudioProfile:AudioProfile_Default];
[_soundPlayer playSound:[SoundBoard instanceOfHandshakeSound]]; [_soundPlayer playSound:[SoundBoard instanceOfHandshakeSound]];
} }
- (void)handleCallEstablished { - (void)handleCallEstablished {
[_soundPlayer stopAllAudio]; [_soundPlayer stopAllAudio];
[self setDefaultAudioProfile];
[_soundPlayer playSound:[SoundBoard instanceOfCompletedSound]];
}
/**
* Route traffic through internal speaker, unless speakerphone is enabled.
*/
- (void)setDefaultAudioProfile
{
[self setAudioProfile:AudioProfile_Default]; [self setAudioProfile:AudioProfile_Default];
[_soundPlayer playSound:[SoundBoard instanceOfCompletedSound]];
} }
- (BOOL)toggleSpeakerPhone { - (BOOL)toggleSpeakerPhone {
@ -136,17 +137,9 @@ AppAudioManager *sharedAppAudioManager;
return isSpeakerphoneActive; return isSpeakerphoneActive;
} }
- (void)toggleSpeakerPhoneIsEnabled:(BOOL)enabled
{
DDLogInfo(@"%@ Toggled speaker phone: %@", self.tag, enabled ? @"ON" : @"OFF");
isSpeakerphoneActive = enabled;
[self updateAudioRouter];
}
#pragma mark Audio Control #pragma mark Audio Control
- (void)cancelAllAudio - (void)cancellAllAudio {
{
[_soundPlayer stopAllAudio]; [_soundPlayer stopAllAudio];
} }
@ -203,8 +196,7 @@ AppAudioManager *sharedAppAudioManager;
return (nil != e); return (nil != e);
} }
- (void)awake - (void)awake {
{
[_soundPlayer 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 @end
NS_ASSUME_NONNULL_END

@ -61,7 +61,7 @@
[super viewWillDisappear:animated]; [super viewWillDisappear:animated];
[self stopRingingAnimation]; [self stopRingingAnimation];
[self stopConnectingFlashAnimation]; [self stopConnectingFlashAnimation];
[AppAudioManager.sharedInstance cancelAllAudio]; [AppAudioManager.sharedInstance cancellAllAudio];
[UIDevice.currentDevice setProximityMonitoringEnabled:NO]; [UIDevice.currentDevice setProximityMonitoringEnabled:NO];
} }

Loading…
Cancel
Save