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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // Release the reference for the thread. Note that after this, the Thread | 159 // Release the reference for the thread. Note that after this, the Thread |
160 // instance will most likely be deleted. | 160 // instance will most likely be deleted. |
161 Release(); | 161 Release(); |
162 } | 162 } |
163 | 163 |
164 void AudioDeviceThread::Thread::Run() { | 164 void AudioDeviceThread::Thread::Run() { |
165 uint32 buffer_index = 0; | 165 uint32 buffer_index = 0; |
166 while (true) { | 166 while (true) { |
167 int pending_data = 0; | 167 int pending_data = 0; |
168 size_t bytes_read = socket_.Receive(&pending_data, sizeof(pending_data)); | 168 size_t bytes_read = socket_.Receive(&pending_data, sizeof(pending_data)); |
169 if (bytes_read != sizeof(pending_data)) { | 169 if (bytes_read != sizeof(pending_data)) |
170 DCHECK_EQ(bytes_read, 0U); | |
171 break; | 170 break; |
172 } | |
173 | 171 |
174 { | 172 { |
175 base::AutoLock auto_lock(callback_lock_); | 173 base::AutoLock auto_lock(callback_lock_); |
176 if (callback_) | 174 if (callback_) |
177 callback_->Process(pending_data); | 175 callback_->Process(pending_data); |
178 } | 176 } |
179 | 177 |
180 // Let the other end know which buffer we just filled. The buffer index is | 178 // Let the other end know which buffer we just filled. The buffer index is |
181 // used to ensure the other end is getting the buffer it expects. For more | 179 // used to ensure the other end is getting the buffer it expects. For more |
182 // details on how this works see AudioSyncReader::WaitUntilDataIsReady(). | 180 // details on how this works see AudioSyncReader::WaitUntilDataIsReady(). |
(...skipping 29 matching lines...) Expand all Loading... |
212 } | 210 } |
213 | 211 |
214 AudioDeviceThread::Callback::~Callback() {} | 212 AudioDeviceThread::Callback::~Callback() {} |
215 | 213 |
216 void AudioDeviceThread::Callback::InitializeOnAudioThread() { | 214 void AudioDeviceThread::Callback::InitializeOnAudioThread() { |
217 MapSharedMemory(); | 215 MapSharedMemory(); |
218 CHECK(shared_memory_.memory()); | 216 CHECK(shared_memory_.memory()); |
219 } | 217 } |
220 | 218 |
221 } // namespace media. | 219 } // namespace media. |
OLD | NEW |