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_input_device.h" | 5 #include "media/audio/audio_input_device.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.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 22 matching lines...) Expand all Loading... |
33 // Called whenever we receive notifications about pending data. | 33 // Called whenever we receive notifications about pending data. |
34 virtual void Process(int pending_data) OVERRIDE; | 34 virtual void Process(int pending_data) OVERRIDE; |
35 | 35 |
36 private: | 36 private: |
37 CaptureCallback* capture_callback_; | 37 CaptureCallback* capture_callback_; |
38 scoped_ptr<AudioBus> audio_bus_; | 38 scoped_ptr<AudioBus> audio_bus_; |
39 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback); | 39 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback); |
40 }; | 40 }; |
41 | 41 |
42 AudioInputDevice::AudioInputDevice( | 42 AudioInputDevice::AudioInputDevice( |
43 AudioInputIPC* ipc, | 43 scoped_ptr<AudioInputIPC> ipc, |
44 const scoped_refptr<base::MessageLoopProxy>& io_loop) | 44 const scoped_refptr<base::MessageLoopProxy>& io_loop) |
45 : ScopedLoopObserver(io_loop), | 45 : ScopedLoopObserver(io_loop), |
46 callback_(NULL), | 46 callback_(NULL), |
47 event_handler_(NULL), | 47 event_handler_(NULL), |
48 ipc_(ipc), | 48 ipc_(ipc.Pass()), |
49 stream_id_(0), | 49 stream_id_(0), |
50 session_id_(0), | 50 session_id_(0), |
51 pending_device_ready_(false), | 51 pending_device_ready_(false), |
52 agc_is_enabled_(false) { | 52 agc_is_enabled_(false) { |
53 CHECK(ipc_); | 53 CHECK(ipc_); |
54 } | 54 } |
55 | 55 |
56 void AudioInputDevice::Initialize(const AudioParameters& params, | 56 void AudioInputDevice::Initialize(const AudioParameters& params, |
57 CaptureCallback* callback, | 57 CaptureCallback* callback, |
58 CaptureEventHandler* event_handler) { | 58 CaptureEventHandler* event_handler) { |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 agc_is_enabled_); | 202 agc_is_enabled_); |
203 } | 203 } |
204 | 204 |
205 pending_device_ready_ = false; | 205 pending_device_ready_ = false; |
206 // Notify the client that the device has been started. | 206 // Notify the client that the device has been started. |
207 if (event_handler_) | 207 if (event_handler_) |
208 event_handler_->OnDeviceStarted(device_id); | 208 event_handler_->OnDeviceStarted(device_id); |
209 } | 209 } |
210 | 210 |
211 void AudioInputDevice::OnIPCClosed() { | 211 void AudioInputDevice::OnIPCClosed() { |
212 ipc_ = NULL; | 212 ipc_.reset(); |
213 } | 213 } |
214 | 214 |
215 AudioInputDevice::~AudioInputDevice() { | 215 AudioInputDevice::~AudioInputDevice() { |
216 // TODO(henrika): The current design requires that the user calls | 216 // TODO(henrika): The current design requires that the user calls |
217 // Stop before deleting this class. | 217 // Stop before deleting this class. |
218 CHECK_EQ(0, stream_id_); | 218 CHECK_EQ(0, stream_id_); |
219 } | 219 } |
220 | 220 |
221 void AudioInputDevice::InitializeOnIOThread() { | 221 void AudioInputDevice::InitializeOnIOThread() { |
222 DCHECK(message_loop()->BelongsToCurrentThread()); | 222 DCHECK(message_loop()->BelongsToCurrentThread()); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 // with nominal range -1.0 -> +1.0. | 336 // with nominal range -1.0 -> +1.0. |
337 audio_bus_->FromInterleaved(memory, audio_bus_->frames(), bytes_per_sample); | 337 audio_bus_->FromInterleaved(memory, audio_bus_->frames(), bytes_per_sample); |
338 | 338 |
339 // Deliver captured data to the client in floating point format | 339 // Deliver captured data to the client in floating point format |
340 // and update the audio-delay measurement. | 340 // and update the audio-delay measurement. |
341 capture_callback_->Capture(audio_bus_.get(), | 341 capture_callback_->Capture(audio_bus_.get(), |
342 audio_delay_milliseconds, volume); | 342 audio_delay_milliseconds, volume); |
343 } | 343 } |
344 | 344 |
345 } // namespace media | 345 } // namespace media |
OLD | NEW |