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_output_device.h" | 5 #include "media/audio/audio_output_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 26 matching lines...) Expand all Loading... |
37 | 37 |
38 AudioOutputDevice::AudioOutputDevice( | 38 AudioOutputDevice::AudioOutputDevice( |
39 AudioOutputIPC* ipc, | 39 AudioOutputIPC* ipc, |
40 const scoped_refptr<base::MessageLoopProxy>& io_loop) | 40 const scoped_refptr<base::MessageLoopProxy>& io_loop) |
41 : ScopedLoopObserver(io_loop), | 41 : ScopedLoopObserver(io_loop), |
42 callback_(NULL), | 42 callback_(NULL), |
43 ipc_(ipc), | 43 ipc_(ipc), |
44 stream_id_(0), | 44 stream_id_(0), |
45 play_on_start_(true), | 45 play_on_start_(true), |
46 is_started_(false) { | 46 is_started_(false) { |
47 CHECK(ipc_); | 47 CHECK(ipc_.get()); |
48 } | 48 } |
49 | 49 |
50 void AudioOutputDevice::Initialize(const AudioParameters& params, | 50 void AudioOutputDevice::Initialize(const AudioParameters& params, |
51 RenderCallback* callback) { | 51 RenderCallback* callback) { |
52 CHECK_EQ(0, stream_id_) << | 52 CHECK_EQ(0, stream_id_) << |
53 "AudioOutputDevice::Initialize() must be called before Start()"; | 53 "AudioOutputDevice::Initialize() must be called before Start()"; |
54 | 54 |
55 CHECK(!callback_); // Calling Initialize() twice? | 55 CHECK(!callback_); // Calling Initialize() twice? |
56 | 56 |
57 audio_parameters_ = params; | 57 audio_parameters_ = params; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 "AudioOutputDevice"); | 215 "AudioOutputDevice"); |
216 | 216 |
217 // We handle the case where Play() and/or Pause() may have been called | 217 // We handle the case where Play() and/or Pause() may have been called |
218 // multiple times before OnStreamCreated() gets called. | 218 // multiple times before OnStreamCreated() gets called. |
219 is_started_ = true; | 219 is_started_ = true; |
220 if (play_on_start_) | 220 if (play_on_start_) |
221 PlayOnIOThread(); | 221 PlayOnIOThread(); |
222 } | 222 } |
223 | 223 |
224 void AudioOutputDevice::OnIPCClosed() { | 224 void AudioOutputDevice::OnIPCClosed() { |
225 ipc_ = NULL; | 225 ipc_.reset(); |
226 } | 226 } |
227 | 227 |
228 void AudioOutputDevice::WillDestroyCurrentMessageLoop() { | 228 void AudioOutputDevice::WillDestroyCurrentMessageLoop() { |
229 LOG(ERROR) << "IO loop going away before the audio device has been stopped"; | 229 LOG(ERROR) << "IO loop going away before the audio device has been stopped"; |
230 ShutDownOnIOThread(); | 230 ShutDownOnIOThread(); |
231 } | 231 } |
232 | 232 |
233 // AudioOutputDevice::AudioThreadCallback | 233 // AudioOutputDevice::AudioThreadCallback |
234 | 234 |
235 AudioOutputDevice::AudioThreadCallback::AudioThreadCallback( | 235 AudioOutputDevice::AudioThreadCallback::AudioThreadCallback( |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 // conversions that happen in the <audio> and WebRTC scenarios. | 271 // conversions that happen in the <audio> and WebRTC scenarios. |
272 InterleaveFloatToInt(audio_data_, shared_memory_.memory(), | 272 InterleaveFloatToInt(audio_data_, shared_memory_.memory(), |
273 num_frames, audio_parameters_.bits_per_sample() / 8); | 273 num_frames, audio_parameters_.bits_per_sample() / 8); |
274 | 274 |
275 // Let the host know we are done. | 275 // Let the host know we are done. |
276 SetActualDataSizeInBytes(&shared_memory_, memory_length_, | 276 SetActualDataSizeInBytes(&shared_memory_, memory_length_, |
277 num_frames * audio_parameters_.GetBytesPerFrame()); | 277 num_frames * audio_parameters_.GetBytesPerFrame()); |
278 } | 278 } |
279 | 279 |
280 } // namespace media. | 280 } // namespace media. |
OLD | NEW |