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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 bytes_per_frame_(audio_parameters.GetBytesPerFrame()), | 223 bytes_per_frame_(audio_parameters.GetBytesPerFrame()), |
224 shared_memory_(memory, false), | 224 shared_memory_(memory, false), |
225 memory_length_(memory_length), | 225 memory_length_(memory_length), |
226 total_segments_(total_segments) { | 226 total_segments_(total_segments) { |
227 CHECK_NE(bytes_per_ms_, 0.0); // Catch division by zero early. | 227 CHECK_NE(bytes_per_ms_, 0.0); // Catch division by zero early. |
228 CHECK_NE(samples_per_ms_, 0.0); | 228 CHECK_NE(samples_per_ms_, 0.0); |
229 CHECK_NE(bytes_per_frame_, 0u); | 229 CHECK_NE(bytes_per_frame_, 0u); |
230 CHECK_GT(total_segments_, 0); | 230 CHECK_GT(total_segments_, 0); |
231 CHECK_EQ(memory_length_ % total_segments_, 0); | 231 CHECK_EQ(memory_length_ % total_segments_, 0); |
232 segment_length_ = memory_length_ / total_segments_; | 232 segment_length_ = memory_length_ / total_segments_; |
| 233 thread_checker_.DetachFromThread(); |
233 } | 234 } |
234 | 235 |
235 AudioDeviceThread::Callback::~Callback() {} | 236 AudioDeviceThread::Callback::~Callback() {} |
236 | 237 |
237 void AudioDeviceThread::Callback::InitializeOnAudioThread() { | 238 void AudioDeviceThread::Callback::InitializeOnAudioThread() { |
| 239 // Normally this function is called before the thread checker is used |
| 240 // elsewhere, but it's not guaranteed. DCHECK to ensure it was not used on |
| 241 // another thread before we get here. |
| 242 DCHECK(thread_checker_.CalledOnValidThread()) |
| 243 << "Thread checker was attached on the wrong thread"; |
238 MapSharedMemory(); | 244 MapSharedMemory(); |
239 CHECK(shared_memory_.memory()); | 245 CHECK(shared_memory_.memory()); |
240 } | 246 } |
241 | 247 |
242 } // namespace media. | 248 } // namespace media. |
OLD | NEW |