Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Side by Side Diff: webrtc/modules/audio_device/ios/objc/RTCAudioSession.mm

Issue 2366753005: Adds support for AVAudioSessionSilenceSecondaryAudioHintNotification on iOS (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; 60 NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
61 [center addObserver:self 61 [center addObserver:self
62 selector:@selector(handleInterruptionNotification:) 62 selector:@selector(handleInterruptionNotification:)
63 name:AVAudioSessionInterruptionNotification 63 name:AVAudioSessionInterruptionNotification
64 object:nil]; 64 object:nil];
65 [center addObserver:self 65 [center addObserver:self
66 selector:@selector(handleRouteChangeNotification:) 66 selector:@selector(handleRouteChangeNotification:)
67 name:AVAudioSessionRouteChangeNotification 67 name:AVAudioSessionRouteChangeNotification
68 object:nil]; 68 object:nil];
69 // TODO(tkchin): Maybe listen to SilenceSecondaryAudioHintNotification.
70 [center addObserver:self 69 [center addObserver:self
71 selector:@selector(handleMediaServicesWereLost:) 70 selector:@selector(handleMediaServicesWereLost:)
72 name:AVAudioSessionMediaServicesWereLostNotification 71 name:AVAudioSessionMediaServicesWereLostNotification
73 object:nil]; 72 object:nil];
74 [center addObserver:self 73 [center addObserver:self
75 selector:@selector(handleMediaServicesWereReset:) 74 selector:@selector(handleMediaServicesWereReset:)
76 name:AVAudioSessionMediaServicesWereResetNotification 75 name:AVAudioSessionMediaServicesWereResetNotification
77 object:nil]; 76 object:nil];
77 // Posted on the main thread when the primary audio from other applications
78 // starts and stops. Foreground applications may use this notification as a
79 // hint to enable or disable audio that is sedondary.
Chuck 2016/09/23 13:22:54 typo: s/sedondary/secondary/
henrika_webrtc 2016/09/23 14:09:50 Done.
80 [center addObserver:self
81 selector:@selector(handleSilenceSecondaryAudioHintNotification:)
82 name:AVAudioSessionSilenceSecondaryAudioHintNotification
83 object:nil];
78 // Also track foreground event in order to deal with interruption ended situ ation. 84 // Also track foreground event in order to deal with interruption ended situ ation.
79 [center addObserver:self 85 [center addObserver:self
80 selector:@selector(handleApplicationDidBecomeActive:) 86 selector:@selector(handleApplicationDidBecomeActive:)
81 name:UIApplicationDidBecomeActiveNotification 87 name:UIApplicationDidBecomeActiveNotification
82 object:nil]; 88 object:nil];
83 } 89 }
84 return self; 90 return self;
85 } 91 }
86 92
87 - (void)dealloc { 93 - (void)dealloc {
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 [self updateAudioSessionAfterEvent]; 515 [self updateAudioSessionAfterEvent];
510 [self notifyMediaServicesWereLost]; 516 [self notifyMediaServicesWereLost];
511 } 517 }
512 518
513 - (void)handleMediaServicesWereReset:(NSNotification *)notification { 519 - (void)handleMediaServicesWereReset:(NSNotification *)notification {
514 RTCLog(@"Media services were reset."); 520 RTCLog(@"Media services were reset.");
515 [self updateAudioSessionAfterEvent]; 521 [self updateAudioSessionAfterEvent];
516 [self notifyMediaServicesWereReset]; 522 [self notifyMediaServicesWereReset];
517 } 523 }
518 524
525 - (void)handleSilenceSecondaryAudioHintNotification:
Chuck 2016/09/23 13:22:54 This looks like it would fit on a single line (525
henrika_webrtc 2016/09/23 14:09:50 It does...but I used git cl format ;-)
526 (NSNotification*)notification {
527 // TODO(henrika): just adding logs here for now until we know if we are ever
528 // see this notification and might be affected by it or if further actions
529 // are required.
530 NSNumber* typeNumber =
531 notification.userInfo[AVAudioSessionSilenceSecondaryAudioHintTypeKey];
532 AVAudioSessionSilenceSecondaryAudioHintType type =
533 (AVAudioSessionSilenceSecondaryAudioHintType)
Chuck 2016/09/23 13:22:54 533/534 single line
henrika_webrtc 2016/09/23 14:09:50 Done.
534 typeNumber.unsignedIntegerValue;
535 switch (type) {
536 case AVAudioSessionSilenceSecondaryAudioHintTypeBegin:
537 RTCLog(@"Another application's primary audio has started.");
538 break;
539 case AVAudioSessionSilenceSecondaryAudioHintTypeEnd:
540 RTCLog(@"Another application's primary audio has stopped.");
541 break;
542 }
543 }
544
519 - (void)handleApplicationDidBecomeActive:(NSNotification *)notification { 545 - (void)handleApplicationDidBecomeActive:(NSNotification *)notification {
520 if (self.isInterrupted) { 546 if (self.isInterrupted) {
521 RTCLog(@"Application became active after an interruption. Treating as interr uption end."); 547 RTCLog(@"Application became active after an interruption. Treating as interr uption end.");
522 self.isInterrupted = NO; 548 self.isInterrupted = NO;
523 [self updateAudioSessionAfterEvent]; 549 [self updateAudioSessionAfterEvent];
524 [self notifyDidEndInterruptionWithShouldResumeSession:YES]; 550 [self notifyDidEndInterruptionWithShouldResumeSession:YES];
525 } 551 }
526 } 552 }
527 553
528 #pragma mark - Private 554 #pragma mark - Private
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 - (void)notifyDidStopPlayOrRecord { 849 - (void)notifyDidStopPlayOrRecord {
824 for (auto delegate : self.delegates) { 850 for (auto delegate : self.delegates) {
825 SEL sel = @selector(audioSessionDidStopPlayOrRecord:); 851 SEL sel = @selector(audioSessionDidStopPlayOrRecord:);
826 if ([delegate respondsToSelector:sel]) { 852 if ([delegate respondsToSelector:sel]) {
827 [delegate audioSessionDidStopPlayOrRecord:self]; 853 [delegate audioSessionDidStopPlayOrRecord:self];
828 } 854 }
829 } 855 }
830 } 856 }
831 857
832 @end 858 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698