| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/protocol/webrtc_audio_source_adapter.h" | 5 #include "remoting/protocol/webrtc_audio_source_adapter.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
| 10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 partial_frame_.insert(partial_frame_.end(), data.data(), | 118 partial_frame_.insert(partial_frame_.end(), data.data(), |
| 119 data.data() + bytes_to_append); | 119 data.data() + bytes_to_append); |
| 120 if (partial_frame_.size() < bytes_per_frame) { | 120 if (partial_frame_.size() < bytes_per_frame) { |
| 121 // Still don't have full frame. | 121 // Still don't have full frame. |
| 122 return; | 122 return; |
| 123 } | 123 } |
| 124 | 124 |
| 125 // Here |partial_frame_| always contains a full frame. | 125 // Here |partial_frame_| always contains a full frame. |
| 126 DCHECK_EQ(partial_frame_.size(), bytes_per_frame); | 126 DCHECK_EQ(partial_frame_.size(), bytes_per_frame); |
| 127 | 127 |
| 128 FOR_EACH_OBSERVER(webrtc::AudioTrackSinkInterface, audio_sinks_, | 128 for (auto& observer : audio_sinks_) { |
| 129 OnData(&partial_frame_.front(), kBytesPerSample * 8, | 129 observer.OnData(&partial_frame_.front(), kBytesPerSample * 8, |
| 130 sampling_rate_, kChannels, samples_per_frame)); | 130 sampling_rate_, kChannels, samples_per_frame); |
| 131 } |
| 131 } | 132 } |
| 132 | 133 |
| 133 while (position + bytes_per_frame <= data.size()) { | 134 while (position + bytes_per_frame <= data.size()) { |
| 134 FOR_EACH_OBSERVER(webrtc::AudioTrackSinkInterface, audio_sinks_, | 135 for (auto& observer : audio_sinks_) { |
| 135 OnData(data.data() + position, kBytesPerSample * 8, | 136 observer.OnData(data.data() + position, kBytesPerSample * 8, |
| 136 sampling_rate_, kChannels, samples_per_frame)); | 137 sampling_rate_, kChannels, samples_per_frame); |
| 138 } |
| 137 position += bytes_per_frame; | 139 position += bytes_per_frame; |
| 138 } | 140 } |
| 139 | 141 |
| 140 partial_frame_.assign(data.data() + position, data.data() + data.size()); | 142 partial_frame_.assign(data.data() + position, data.data() + data.size()); |
| 141 } | 143 } |
| 142 | 144 |
| 143 WebrtcAudioSourceAdapter::WebrtcAudioSourceAdapter( | 145 WebrtcAudioSourceAdapter::WebrtcAudioSourceAdapter( |
| 144 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner) | 146 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner) |
| 145 : audio_task_runner_(audio_task_runner), core_(new Core()) {} | 147 : audio_task_runner_(audio_task_runner), core_(new Core()) {} |
| 146 | 148 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 core_->RemoveSink(sink); | 184 core_->RemoveSink(sink); |
| 183 } | 185 } |
| 184 | 186 |
| 185 void WebrtcAudioSourceAdapter::RegisterObserver( | 187 void WebrtcAudioSourceAdapter::RegisterObserver( |
| 186 webrtc::ObserverInterface* observer) {} | 188 webrtc::ObserverInterface* observer) {} |
| 187 void WebrtcAudioSourceAdapter::UnregisterObserver( | 189 void WebrtcAudioSourceAdapter::UnregisterObserver( |
| 188 webrtc::ObserverInterface* observer) {} | 190 webrtc::ObserverInterface* observer) {} |
| 189 | 191 |
| 190 } // namespace protocol | 192 } // namespace protocol |
| 191 } // namespace remoting | 193 } // namespace remoting |
| OLD | NEW |