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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <limits> | 10 #include <limits> |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 Run(); | 161 Run(); |
162 | 162 |
163 // Release the reference for the thread. Note that after this, the Thread | 163 // Release the reference for the thread. Note that after this, the Thread |
164 // instance will most likely be deleted. | 164 // instance will most likely be deleted. |
165 Release(); | 165 Release(); |
166 } | 166 } |
167 | 167 |
168 void AudioDeviceThread::Thread::Run() { | 168 void AudioDeviceThread::Thread::Run() { |
169 uint32_t buffer_index = 0; | 169 uint32_t buffer_index = 0; |
170 while (true) { | 170 while (true) { |
171 uint32_t pending_data = 0; | 171 uint32 pending_data = 0; |
172 size_t bytes_read = socket_.Receive(&pending_data, sizeof(pending_data)); | 172 size_t bytes_read = socket_.Receive(&pending_data, sizeof(pending_data)); |
173 if (bytes_read != sizeof(pending_data)) | 173 if (bytes_read != sizeof(pending_data)) |
174 break; | 174 break; |
175 | 175 |
176 // std::numeric_limits<uint32_t>::max() is a special signal which is | 176 // std::numeric_limits<uint32_t>::max() is a special signal which is |
177 // returned after the browser stops the output device in response to a | 177 // returned after the browser |
178 // renderer side request. | 178 // stops the output device in response to a renderer side request. |
179 // | 179 // |
180 // Avoid running Process() for the paused signal, we still need to update | 180 // Avoid running Process() for the paused signal, we still need to update |
181 // the buffer index if |synchronized_buffers_| is true though. | 181 // the buffer index if |synchronized_buffers_| is true though. |
182 // | 182 // |
183 // See comments in AudioOutputController::DoPause() for details on why. | 183 // See comments in AudioOutputController::DoPause() for details on why. |
184 if (pending_data != std::numeric_limits<uint32_t>::max()) { | 184 if (pending_data != std::numeric_limits<uint32_t>::max()) { |
185 base::AutoLock auto_lock(callback_lock_); | 185 base::AutoLock auto_lock(callback_lock_); |
186 if (callback_) | 186 if (callback_) |
187 callback_->Process(pending_data); | 187 callback_->Process(pending_data); |
188 } | 188 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 } | 229 } |
230 | 230 |
231 AudioDeviceThread::Callback::~Callback() {} | 231 AudioDeviceThread::Callback::~Callback() {} |
232 | 232 |
233 void AudioDeviceThread::Callback::InitializeOnAudioThread() { | 233 void AudioDeviceThread::Callback::InitializeOnAudioThread() { |
234 MapSharedMemory(); | 234 MapSharedMemory(); |
235 CHECK(shared_memory_.memory()); | 235 CHECK(shared_memory_.memory()); |
236 } | 236 } |
237 | 237 |
238 } // namespace media. | 238 } // namespace media. |
OLD | NEW |