OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |