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 23 matching lines...) Expand all Loading... |
34 virtual void Process(int pending_data) OVERRIDE; | 34 virtual void Process(int pending_data) OVERRIDE; |
35 | 35 |
36 private: | 36 private: |
37 AudioRendererSink::RenderCallback* render_callback_; | 37 AudioRendererSink::RenderCallback* render_callback_; |
38 scoped_ptr<AudioBus> input_bus_; | 38 scoped_ptr<AudioBus> input_bus_; |
39 scoped_ptr<AudioBus> output_bus_; | 39 scoped_ptr<AudioBus> output_bus_; |
40 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback); | 40 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback); |
41 }; | 41 }; |
42 | 42 |
43 AudioOutputDevice::AudioOutputDevice( | 43 AudioOutputDevice::AudioOutputDevice( |
44 AudioOutputIPC* ipc, | 44 scoped_ptr<AudioOutputIPC> ipc, |
45 const scoped_refptr<base::MessageLoopProxy>& io_loop) | 45 const scoped_refptr<base::MessageLoopProxy>& io_loop) |
46 : ScopedLoopObserver(io_loop), | 46 : ScopedLoopObserver(io_loop), |
47 input_channels_(0), | 47 input_channels_(0), |
48 callback_(NULL), | 48 callback_(NULL), |
49 ipc_(ipc), | 49 ipc_(ipc.Pass()), |
50 stream_id_(0), | 50 stream_id_(0), |
51 play_on_start_(true), | 51 play_on_start_(true), |
52 is_started_(false), | 52 is_started_(false), |
53 stopping_hack_(false) { | 53 stopping_hack_(false) { |
54 CHECK(ipc_); | 54 CHECK(ipc_); |
55 } | 55 } |
56 | 56 |
57 void AudioOutputDevice::Initialize(const AudioParameters& params, | 57 void AudioOutputDevice::Initialize(const AudioParameters& params, |
58 RenderCallback* callback) { | 58 RenderCallback* callback) { |
59 CHECK_EQ(0, stream_id_) << | 59 CHECK_EQ(0, stream_id_) << |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 "AudioOutputDevice"); | 252 "AudioOutputDevice"); |
253 | 253 |
254 // We handle the case where Play() and/or Pause() may have been called | 254 // We handle the case where Play() and/or Pause() may have been called |
255 // multiple times before OnStreamCreated() gets called. | 255 // multiple times before OnStreamCreated() gets called. |
256 is_started_ = true; | 256 is_started_ = true; |
257 if (play_on_start_) | 257 if (play_on_start_) |
258 PlayOnIOThread(); | 258 PlayOnIOThread(); |
259 } | 259 } |
260 | 260 |
261 void AudioOutputDevice::OnIPCClosed() { | 261 void AudioOutputDevice::OnIPCClosed() { |
262 ipc_ = NULL; | 262 ipc_.reset(); |
263 } | 263 } |
264 | 264 |
265 void AudioOutputDevice::WillDestroyCurrentMessageLoop() { | 265 void AudioOutputDevice::WillDestroyCurrentMessageLoop() { |
266 LOG(ERROR) << "IO loop going away before the audio device has been stopped"; | 266 LOG(ERROR) << "IO loop going away before the audio device has been stopped"; |
267 ShutDownOnIOThread(); | 267 ShutDownOnIOThread(); |
268 } | 268 } |
269 | 269 |
270 // AudioOutputDevice::AudioThreadCallback | 270 // AudioOutputDevice::AudioThreadCallback |
271 | 271 |
272 AudioOutputDevice::AudioThreadCallback::AudioThreadCallback( | 272 AudioOutputDevice::AudioThreadCallback::AudioThreadCallback( |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 // TODO(dalecurtis): Technically this is not always correct. Due to channel | 342 // TODO(dalecurtis): Technically this is not always correct. Due to channel |
343 // padding for alignment, there may be more data available than this. We're | 343 // padding for alignment, there may be more data available than this. We're |
344 // relying on AudioSyncReader::Read() to parse this with that in mind. Rename | 344 // relying on AudioSyncReader::Read() to parse this with that in mind. Rename |
345 // these methods to Set/GetActualFrameCount(). | 345 // these methods to Set/GetActualFrameCount(). |
346 SetActualDataSizeInBytes( | 346 SetActualDataSizeInBytes( |
347 &shared_memory_, memory_length_, | 347 &shared_memory_, memory_length_, |
348 num_frames * sizeof(*output_bus_->channel(0)) * output_bus_->channels()); | 348 num_frames * sizeof(*output_bus_->channel(0)) * output_bus_->channels()); |
349 } | 349 } |
350 | 350 |
351 } // namespace media. | 351 } // namespace media. |
OLD | NEW |