| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 Run(); | 163 Run(); |
| 164 | 164 |
| 165 // Release the reference for the thread. Note that after this, the Thread | 165 // Release the reference for the thread. Note that after this, the Thread |
| 166 // instance will most likely be deleted. | 166 // instance will most likely be deleted. |
| 167 Release(); | 167 Release(); |
| 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 Packet packet = {0, AudioTimestamp()}; |
| 174 size_t bytes_read = socket_.Receive(&pending_data, sizeof(pending_data)); | 174 size_t bytes_read = socket_.Receive(&packet, sizeof(packet)); |
| 175 if (bytes_read != sizeof(pending_data)) | 175 if (bytes_read != sizeof(packet)) |
| 176 break; | 176 break; |
| 177 | 177 |
| 178 // std::numeric_limits<uint32_t>::max() is a special signal which is | 178 // 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 | 179 // returned after the browser stops the output device in response to a |
| 180 // renderer side request. | 180 // renderer side request. |
| 181 // | 181 // |
| 182 // Avoid running Process() for the paused signal, we still need to update | 182 // Avoid running Process() for the paused signal, we still need to update |
| 183 // the buffer index if |synchronized_buffers_| is true though. | 183 // the buffer index if |synchronized_buffers_| is true though. |
| 184 // | 184 // |
| 185 // See comments in AudioOutputController::DoPause() for details on why. | 185 // See comments in AudioOutputController::DoPause() for details on why. |
| 186 if (pending_data != std::numeric_limits<uint32_t>::max()) { | 186 if (packet.pending_data != std::numeric_limits<uint32_t>::max()) { |
| 187 base::AutoLock auto_lock(callback_lock_); | 187 base::AutoLock auto_lock(callback_lock_); |
| 188 if (callback_) | 188 if (callback_) |
| 189 callback_->Process(pending_data); | 189 callback_->Process(packet.pending_data, packet.timestamp); |
| 190 } | 190 } |
| 191 | 191 |
| 192 // The usage of |synchronized_buffers_| differs between input and output | 192 // The usage of |synchronized_buffers_| differs between input and output |
| 193 // cases. | 193 // cases. |
| 194 // Input: | 194 // Input: |
| 195 // Let the other end know that we have read data, so that it can verify | 195 // 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 | 196 // it doesn't overwrite any data before read. The |buffer_index| value is |
| 197 // not used. For more details, see AudioInputSyncWriter::Write(). | 197 // not used. For more details, see AudioInputSyncWriter::Write(). |
| 198 // Output: | 198 // Output: |
| 199 // Let the other end know which buffer we just filled. The |buffer_index| is | 199 // 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 } | 233 } |
| 234 | 234 |
| 235 AudioDeviceThread::Callback::~Callback() {} | 235 AudioDeviceThread::Callback::~Callback() {} |
| 236 | 236 |
| 237 void AudioDeviceThread::Callback::InitializeOnAudioThread() { | 237 void AudioDeviceThread::Callback::InitializeOnAudioThread() { |
| 238 MapSharedMemory(); | 238 MapSharedMemory(); |
| 239 CHECK(shared_memory_.memory()); | 239 CHECK(shared_memory_.memory()); |
| 240 } | 240 } |
| 241 | 241 |
| 242 } // namespace media. | 242 } // namespace media. |
| OLD | NEW |