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 28 matching lines...) Expand all Loading... | |
39 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback); | 39 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback); |
40 }; | 40 }; |
41 | 41 |
42 AudioDevice::AudioDevice() | 42 AudioDevice::AudioDevice() |
43 : ScopedLoopObserver(ChildProcess::current()->io_message_loop()), | 43 : ScopedLoopObserver(ChildProcess::current()->io_message_loop()), |
44 callback_(NULL), | 44 callback_(NULL), |
45 volume_(1.0), | 45 volume_(1.0), |
46 stream_id_(0), | 46 stream_id_(0), |
47 play_on_start_(true), | 47 play_on_start_(true), |
48 is_started_(false) { | 48 is_started_(false) { |
49 filter_ = RenderThreadImpl::current()->audio_message_filter(); | 49 filter_ = AudioMessageFilter::current(); |
henrika (OOO until Aug 14)
2012/06/20 12:33:52
By not injecting you make it much more difficult t
henrika (OOO until Aug 14)
2012/06/20 17:15:53
Bad example; sorry. I meant create the AD and perf
| |
50 } | 50 } |
51 | 51 |
52 AudioDevice::AudioDevice(const media::AudioParameters& params, | 52 AudioDevice::AudioDevice(const media::AudioParameters& params, |
53 RenderCallback* callback) | 53 RenderCallback* callback) |
54 : ScopedLoopObserver(ChildProcess::current()->io_message_loop()), | 54 : ScopedLoopObserver(ChildProcess::current()->io_message_loop()), |
55 audio_parameters_(params), | 55 audio_parameters_(params), |
56 callback_(callback), | 56 callback_(callback), |
57 volume_(1.0), | 57 volume_(1.0), |
58 stream_id_(0), | 58 stream_id_(0), |
59 play_on_start_(true), | 59 play_on_start_(true), |
60 is_started_(false) { | 60 is_started_(false) { |
61 filter_ = RenderThreadImpl::current()->audio_message_filter(); | 61 filter_ = AudioMessageFilter::current(); |
62 } | 62 } |
63 | 63 |
64 void AudioDevice::Initialize(const media::AudioParameters& params, | 64 void AudioDevice::Initialize(const media::AudioParameters& params, |
65 RenderCallback* callback) { | 65 RenderCallback* callback) { |
66 CHECK_EQ(0, stream_id_) << | 66 CHECK_EQ(0, stream_id_) << |
67 "AudioDevice::Initialize() must be called before Start()"; | 67 "AudioDevice::Initialize() must be called before Start()"; |
68 | 68 |
69 CHECK(!callback_); // Calling Initialize() twice? | 69 CHECK(!callback_); // Calling Initialize() twice? |
70 | 70 |
71 audio_parameters_ = params; | 71 audio_parameters_ = params; |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 // TODO(crogers/vrk): Figure out a way to avoid the float -> int -> float | 292 // TODO(crogers/vrk): Figure out a way to avoid the float -> int -> float |
293 // conversions that happen in the <audio> and WebRTC scenarios. | 293 // conversions that happen in the <audio> and WebRTC scenarios. |
294 media::InterleaveFloatToInt(audio_data_, shared_memory_.memory(), | 294 media::InterleaveFloatToInt(audio_data_, shared_memory_.memory(), |
295 audio_parameters_.frames_per_buffer(), | 295 audio_parameters_.frames_per_buffer(), |
296 audio_parameters_.bits_per_sample() / 8); | 296 audio_parameters_.bits_per_sample() / 8); |
297 | 297 |
298 // Let the host know we are done. | 298 // Let the host know we are done. |
299 media::SetActualDataSizeInBytes(&shared_memory_, memory_length_, | 299 media::SetActualDataSizeInBytes(&shared_memory_, memory_length_, |
300 num_frames * audio_parameters_.GetBytesPerFrame()); | 300 num_frames * audio_parameters_.GetBytesPerFrame()); |
301 } | 301 } |
OLD | NEW |