Chromium Code Reviews| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 } | 150 } |
| 151 | 151 |
| 152 Run(); | 152 Run(); |
| 153 | 153 |
| 154 // Release the reference for the thread. Note that after this, the Thread | 154 // Release the reference for the thread. Note that after this, the Thread |
| 155 // instance will most likely be deleted. | 155 // instance will most likely be deleted. |
| 156 Release(); | 156 Release(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void AudioDeviceThread::Thread::Run() { | 159 void AudioDeviceThread::Thread::Run() { |
| 160 uint32_t buffer_index = 0; | |
| 160 while (true) { | 161 while (true) { |
| 161 int pending_data = 0; | 162 int pending_data = 0; |
| 162 size_t bytes_read = socket_.Receive(&pending_data, sizeof(pending_data)); | 163 size_t bytes_read = socket_.Receive(&pending_data, sizeof(pending_data)); |
| 163 if (bytes_read != sizeof(pending_data)) { | 164 if (bytes_read != sizeof(pending_data)) { |
| 164 DCHECK_EQ(bytes_read, 0U); | 165 DCHECK_EQ(bytes_read, 0U); |
| 165 break; | 166 break; |
| 166 } | 167 } |
| 167 | 168 |
| 168 base::AutoLock auto_lock(callback_lock_); | 169 { |
| 169 if (callback_) | 170 base::AutoLock auto_lock(callback_lock_); |
| 170 callback_->Process(pending_data); | 171 if (callback_) |
| 172 callback_->Process(pending_data); | |
| 173 } | |
| 174 | |
| 175 // Let AudioSyncReader know which buffer we just filled. | |
| 176 buffer_index++; | |
|
henrika (OOO until Aug 14)
2013/08/20 07:50:30
Perhaps I am missing something here but isn't new
tommi (sloooow) - chröme
2013/08/20 10:55:57
nit: ++buffer_index;
DaleCurtis
2013/09/11 01:16:03
This is handled in the new WaitTilDataReady().
DaleCurtis
2013/09/11 01:16:03
Done.
| |
| 177 CHECK_EQ(socket_.Send(&buffer_index, sizeof(buffer_index)), | |
| 178 sizeof(buffer_index)); | |
| 171 } | 179 } |
| 172 } | 180 } |
| 173 | 181 |
| 174 // AudioDeviceThread::Callback implementation | 182 // AudioDeviceThread::Callback implementation |
| 175 | 183 |
| 176 AudioDeviceThread::Callback::Callback( | 184 AudioDeviceThread::Callback::Callback( |
| 177 const AudioParameters& audio_parameters, | 185 const AudioParameters& audio_parameters, |
| 178 base::SharedMemoryHandle memory, | 186 base::SharedMemoryHandle memory, |
| 179 int memory_length, | 187 int memory_length, |
| 180 int total_segments) | 188 int total_segments) |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 194 } | 202 } |
| 195 | 203 |
| 196 AudioDeviceThread::Callback::~Callback() {} | 204 AudioDeviceThread::Callback::~Callback() {} |
| 197 | 205 |
| 198 void AudioDeviceThread::Callback::InitializeOnAudioThread() { | 206 void AudioDeviceThread::Callback::InitializeOnAudioThread() { |
| 199 MapSharedMemory(); | 207 MapSharedMemory(); |
| 200 CHECK(shared_memory_.memory()); | 208 CHECK(shared_memory_.memory()); |
| 201 } | 209 } |
| 202 | 210 |
| 203 } // namespace media. | 211 } // namespace media. |
| OLD | NEW |