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 "content/renderer/media/audio_device.h" | 5 #include "content/renderer/media/audio_device.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 if (!audio_thread_.IsStopped()) | 203 if (!audio_thread_.IsStopped()) |
204 callback_->OnRenderError(); | 204 callback_->OnRenderError(); |
205 } | 205 } |
206 } | 206 } |
207 | 207 |
208 void AudioDevice::OnStreamCreated( | 208 void AudioDevice::OnStreamCreated( |
209 base::SharedMemoryHandle handle, | 209 base::SharedMemoryHandle handle, |
210 base::SyncSocket::Handle socket_handle, | 210 base::SyncSocket::Handle socket_handle, |
211 uint32 length) { | 211 uint32 length) { |
212 DCHECK(message_loop()->BelongsToCurrentThread()); | 212 DCHECK(message_loop()->BelongsToCurrentThread()); |
| 213 /* |
213 DCHECK_GE(length, | 214 DCHECK_GE(length, |
214 audio_parameters_.frames_per_buffer() * sizeof(int16) * | 215 audio_parameters_.frames_per_buffer() * sizeof(int16) * |
215 audio_parameters_.channels()); | 216 audio_parameters_.channels()); |
| 217 */ |
216 #if defined(OS_WIN) | 218 #if defined(OS_WIN) |
217 DCHECK(handle); | 219 DCHECK(handle); |
218 DCHECK(socket_handle); | 220 DCHECK(socket_handle); |
219 #else | 221 #else |
220 DCHECK_GE(handle.fd, 0); | 222 DCHECK_GE(handle.fd, 0); |
221 DCHECK_GE(socket_handle, 0); | 223 DCHECK_GE(socket_handle, 0); |
222 #endif | 224 #endif |
223 | 225 |
224 base::AutoLock auto_lock(audio_thread_lock_); | 226 base::AutoLock auto_lock(audio_thread_lock_); |
225 | 227 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 // to the browser process as float, so we don't lose precision for | 295 // to the browser process as float, so we don't lose precision for |
294 // audio hardware which has better than 16bit precision. | 296 // audio hardware which has better than 16bit precision. |
295 int16* data = reinterpret_cast<int16*>(shared_memory_.memory()); | 297 int16* data = reinterpret_cast<int16*>(shared_memory_.memory()); |
296 media::InterleaveFloatToInt16(audio_data_, data, | 298 media::InterleaveFloatToInt16(audio_data_, data, |
297 audio_parameters_.frames_per_buffer()); | 299 audio_parameters_.frames_per_buffer()); |
298 | 300 |
299 // Let the host know we are done. | 301 // Let the host know we are done. |
300 media::SetActualDataSizeInBytes(&shared_memory_, memory_length_, | 302 media::SetActualDataSizeInBytes(&shared_memory_, memory_length_, |
301 num_frames * audio_parameters_.channels() * sizeof(data[0])); | 303 num_frames * audio_parameters_.channels() * sizeof(data[0])); |
302 } | 304 } |
OLD | NEW |