| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } | 168 } |
| 169 | 169 |
| 170 void AudioDeviceThread::Thread::Run() { | 170 void AudioDeviceThread::Thread::Run() { |
| 171 uint32_t buffer_index = 0; | 171 uint32_t buffer_index = 0; |
| 172 while (true) { | 172 while (true) { |
| 173 uint32_t pending_data = 0; | 173 uint32_t pending_data = 0; |
| 174 size_t bytes_read = socket_.Receive(&pending_data, sizeof(pending_data)); | 174 size_t bytes_read = socket_.Receive(&pending_data, sizeof(pending_data)); |
| 175 if (bytes_read != sizeof(pending_data)) | 175 if (bytes_read != sizeof(pending_data)) |
| 176 break; | 176 break; |
| 177 | 177 |
| 178 AudioTimestamp output_timestamp = {0, 0}; |
| 179 bytes_read = socket_.Receive(&output_timestamp, sizeof(output_timestamp)); |
| 180 if (bytes_read != sizeof(output_timestamp)) |
| 181 break; |
| 182 |
| 178 // std::numeric_limits<uint32_t>::max() is a special signal which is | 183 // std::numeric_limits<uint32_t>::max() is a special signal which is |
| 179 // returned after the browser stops the output device in response to a | 184 // returned after the browser stops the output device in response to a |
| 180 // renderer side request. | 185 // renderer side request. |
| 181 // | 186 // |
| 182 // Avoid running Process() for the paused signal, we still need to update | 187 // Avoid running Process() for the paused signal, we still need to update |
| 183 // the buffer index if |synchronized_buffers_| is true though. | 188 // the buffer index if |synchronized_buffers_| is true though. |
| 184 // | 189 // |
| 185 // See comments in AudioOutputController::DoPause() for details on why. | 190 // See comments in AudioOutputController::DoPause() for details on why. |
| 186 if (pending_data != std::numeric_limits<uint32_t>::max()) { | 191 if (pending_data != std::numeric_limits<uint32_t>::max()) { |
| 187 base::AutoLock auto_lock(callback_lock_); | 192 base::AutoLock auto_lock(callback_lock_); |
| 188 if (callback_) | 193 if (callback_) |
| 189 callback_->Process(pending_data); | 194 callback_->Process(pending_data, output_timestamp); |
| 190 } | 195 } |
| 191 | 196 |
| 192 // The usage of |synchronized_buffers_| differs between input and output | 197 // The usage of |synchronized_buffers_| differs between input and output |
| 193 // cases. | 198 // cases. |
| 194 // Input: | 199 // Input: |
| 195 // Let the other end know that we have read data, so that it can verify | 200 // Let the other end know that we have read data, so that it can verify |
| 196 // it doesn't overwrite any data before read. The |buffer_index| value is | 201 // it doesn't overwrite any data before read. The |buffer_index| value is |
| 197 // not used. For more details, see AudioInputSyncWriter::Write(). | 202 // not used. For more details, see AudioInputSyncWriter::Write(). |
| 198 // Output: | 203 // Output: |
| 199 // Let the other end know which buffer we just filled. The |buffer_index| is | 204 // Let the other end know which buffer we just filled. The |buffer_index| is |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 } | 238 } |
| 234 | 239 |
| 235 AudioDeviceThread::Callback::~Callback() {} | 240 AudioDeviceThread::Callback::~Callback() {} |
| 236 | 241 |
| 237 void AudioDeviceThread::Callback::InitializeOnAudioThread() { | 242 void AudioDeviceThread::Callback::InitializeOnAudioThread() { |
| 238 MapSharedMemory(); | 243 MapSharedMemory(); |
| 239 CHECK(shared_memory_.memory()); | 244 CHECK(shared_memory_.memory()); |
| 240 } | 245 } |
| 241 | 246 |
| 242 } // namespace media. | 247 } // namespace media. |
| OLD | NEW |