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

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

Issue 1877643002: Fix RTCAudioSession crash in removeDelegate. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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 | webrtc/modules/audio_device/ios/objc/RTCAudioSessionTest.mm » ('j') | 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 140 }
141 } 141 }
142 142
143 - (void)removeDelegate:(id<RTCAudioSessionDelegate>)delegate { 143 - (void)removeDelegate:(id<RTCAudioSessionDelegate>)delegate {
144 if (!delegate) { 144 if (!delegate) {
145 return; 145 return;
146 } 146 }
147 @synchronized(self) { 147 @synchronized(self) {
148 _delegates.erase(std::remove(_delegates.begin(), 148 _delegates.erase(std::remove(_delegates.begin(),
149 _delegates.end(), 149 _delegates.end(),
150 delegate)); 150 delegate),
151 _delegates.end());
151 [self removeZeroedDelegates]; 152 [self removeZeroedDelegates];
152 } 153 }
153 } 154 }
154 155
155 - (void)lockForConfiguration { 156 - (void)lockForConfiguration {
156 _crit.Enter(); 157 _crit.Enter();
157 rtc::AtomicOps::Increment(&_lockRecursionCount); 158 rtc::AtomicOps::Increment(&_lockRecursionCount);
158 } 159 }
159 160
160 - (void)unlockForConfiguration { 161 - (void)unlockForConfiguration {
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 514
514 // TODO(tkchin): check for duplicates. 515 // TODO(tkchin): check for duplicates.
515 - (void)pushDelegate:(id<RTCAudioSessionDelegate>)delegate { 516 - (void)pushDelegate:(id<RTCAudioSessionDelegate>)delegate {
516 @synchronized(self) { 517 @synchronized(self) {
517 _delegates.insert(_delegates.begin(), delegate); 518 _delegates.insert(_delegates.begin(), delegate);
518 } 519 }
519 } 520 }
520 521
521 - (void)removeZeroedDelegates { 522 - (void)removeZeroedDelegates {
522 @synchronized(self) { 523 @synchronized(self) {
523 for (auto it = _delegates.begin(); it != _delegates.end(); ++it) { 524 _delegates.erase(
524 if (!*it) { 525 std::remove_if(_delegates.begin(),
525 _delegates.erase(it); 526 _delegates.end(),
526 } 527 [](id delegate) -> bool { return delegate == nil; }),
527 } 528 _delegates.end());
528 } 529 }
529 } 530 }
530 531
531 - (int)activationCount { 532 - (int)activationCount {
532 return _activationCount; 533 return _activationCount;
533 } 534 }
534 535
535 - (int)incrementActivationCount { 536 - (int)incrementActivationCount {
536 RTCLog(@"Incrementing activation count."); 537 RTCLog(@"Incrementing activation count.");
537 return rtc::AtomicOps::Increment(&_activationCount); 538 return rtc::AtomicOps::Increment(&_activationCount);
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 - (void)notifyDidUnconfigure { 747 - (void)notifyDidUnconfigure {
747 for (auto delegate : self.delegates) { 748 for (auto delegate : self.delegates) {
748 SEL sel = @selector(audioSessionDidUnconfigure:); 749 SEL sel = @selector(audioSessionDidUnconfigure:);
749 if ([delegate respondsToSelector:sel]) { 750 if ([delegate respondsToSelector:sel]) {
750 [delegate audioSessionDidUnconfigure:self]; 751 [delegate audioSessionDidUnconfigure:self];
751 } 752 }
752 } 753 }
753 } 754 }
754 755
755 @end 756 @end
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_device/ios/objc/RTCAudioSessionTest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698