OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "media/audio/audio_device_thread.h" | 5 #include "media/audio/audio_device_thread.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // Avoid running Process() for the paused signal, we still need to update | 176 // Avoid running Process() for the paused signal, we still need to update |
177 // the buffer index if |synchronized_buffers_| is true though. | 177 // the buffer index if |synchronized_buffers_| is true though. |
178 // | 178 // |
179 // See comments in AudioOutputController::DoPause() for details on why. | 179 // See comments in AudioOutputController::DoPause() for details on why. |
180 if (pending_data != kuint32max) { | 180 if (pending_data != kuint32max) { |
181 base::AutoLock auto_lock(callback_lock_); | 181 base::AutoLock auto_lock(callback_lock_); |
182 if (callback_) | 182 if (callback_) |
183 callback_->Process(pending_data); | 183 callback_->Process(pending_data); |
184 } | 184 } |
185 | 185 |
186 // Let the other end know which buffer we just filled. The buffer index is | 186 // The usage of |synchronized_buffers_| differs between input and output |
187 // used to ensure the other end is getting the buffer it expects. For more | 187 // cases. |
| 188 // Input: |
| 189 // Let the other end know that we have read data, so that it can verify |
| 190 // it doesn't overwrite any data before read. The |buffer_index| value is |
| 191 // not used. For more details, see AudioInputSyncWriter::Write(). |
| 192 // Output: |
| 193 // Let the other end know which buffer we just filled. The |buffer_index| is |
| 194 // used to ensure the other end is getting the buffer it expects. For more |
188 // details on how this works see AudioSyncReader::WaitUntilDataIsReady(). | 195 // details on how this works see AudioSyncReader::WaitUntilDataIsReady(). |
189 if (synchronized_buffers_) { | 196 if (synchronized_buffers_) { |
190 ++buffer_index; | 197 ++buffer_index; |
191 size_t bytes_sent = socket_.Send(&buffer_index, sizeof(buffer_index)); | 198 size_t bytes_sent = socket_.Send(&buffer_index, sizeof(buffer_index)); |
192 if (bytes_sent != sizeof(buffer_index)) | 199 if (bytes_sent != sizeof(buffer_index)) |
193 break; | 200 break; |
194 } | 201 } |
195 } | 202 } |
196 } | 203 } |
197 | 204 |
(...skipping 20 matching lines...) Expand all Loading... |
218 } | 225 } |
219 | 226 |
220 AudioDeviceThread::Callback::~Callback() {} | 227 AudioDeviceThread::Callback::~Callback() {} |
221 | 228 |
222 void AudioDeviceThread::Callback::InitializeOnAudioThread() { | 229 void AudioDeviceThread::Callback::InitializeOnAudioThread() { |
223 MapSharedMemory(); | 230 MapSharedMemory(); |
224 CHECK(shared_memory_.memory()); | 231 CHECK(shared_memory_.memory()); |
225 } | 232 } |
226 | 233 |
227 } // namespace media. | 234 } // namespace media. |
OLD | NEW |