| 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 17 matching lines...) Expand all Loading... |
| 28 CaptureCallback* capture_callback); | 28 CaptureCallback* capture_callback); |
| 29 virtual ~AudioThreadCallback(); | 29 virtual ~AudioThreadCallback(); |
| 30 | 30 |
| 31 virtual void MapSharedMemory() OVERRIDE; | 31 virtual void MapSharedMemory() OVERRIDE; |
| 32 | 32 |
| 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 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback); | 39 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback); |
| 39 }; | 40 }; |
| 40 | 41 |
| 41 AudioInputDevice::AudioInputDevice( | 42 AudioInputDevice::AudioInputDevice( |
| 42 AudioInputIPC* ipc, | 43 AudioInputIPC* ipc, |
| 43 const scoped_refptr<base::MessageLoopProxy>& io_loop) | 44 const scoped_refptr<base::MessageLoopProxy>& io_loop) |
| 44 : ScopedLoopObserver(io_loop), | 45 : ScopedLoopObserver(io_loop), |
| 45 callback_(NULL), | 46 callback_(NULL), |
| 46 event_handler_(NULL), | 47 event_handler_(NULL), |
| 47 ipc_(ipc), | 48 ipc_(ipc), |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 } | 301 } |
| 301 | 302 |
| 302 // AudioInputDevice::AudioThreadCallback | 303 // AudioInputDevice::AudioThreadCallback |
| 303 AudioInputDevice::AudioThreadCallback::AudioThreadCallback( | 304 AudioInputDevice::AudioThreadCallback::AudioThreadCallback( |
| 304 const AudioParameters& audio_parameters, | 305 const AudioParameters& audio_parameters, |
| 305 base::SharedMemoryHandle memory, | 306 base::SharedMemoryHandle memory, |
| 306 int memory_length, | 307 int memory_length, |
| 307 CaptureCallback* capture_callback) | 308 CaptureCallback* capture_callback) |
| 308 : AudioDeviceThread::Callback(audio_parameters, memory, memory_length), | 309 : AudioDeviceThread::Callback(audio_parameters, memory, memory_length), |
| 309 capture_callback_(capture_callback) { | 310 capture_callback_(capture_callback) { |
| 311 audio_bus_ = AudioBus::Create(audio_parameters_); |
| 310 } | 312 } |
| 311 | 313 |
| 312 AudioInputDevice::AudioThreadCallback::~AudioThreadCallback() { | 314 AudioInputDevice::AudioThreadCallback::~AudioThreadCallback() { |
| 313 } | 315 } |
| 314 | 316 |
| 315 void AudioInputDevice::AudioThreadCallback::MapSharedMemory() { | 317 void AudioInputDevice::AudioThreadCallback::MapSharedMemory() { |
| 316 shared_memory_.Map(memory_length_); | 318 shared_memory_.Map(memory_length_); |
| 317 } | 319 } |
| 318 | 320 |
| 319 void AudioInputDevice::AudioThreadCallback::Process(int pending_data) { | 321 void AudioInputDevice::AudioThreadCallback::Process(int pending_data) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 334 // with nominal range -1.0 -> +1.0. | 336 // with nominal range -1.0 -> +1.0. |
| 335 audio_bus_->FromInterleaved(memory, audio_bus_->frames(), bytes_per_sample); | 337 audio_bus_->FromInterleaved(memory, audio_bus_->frames(), bytes_per_sample); |
| 336 | 338 |
| 337 // Deliver captured data to the client in floating point format | 339 // Deliver captured data to the client in floating point format |
| 338 // and update the audio-delay measurement. | 340 // and update the audio-delay measurement. |
| 339 capture_callback_->Capture(audio_bus_.get(), | 341 capture_callback_->Capture(audio_bus_.get(), |
| 340 audio_delay_milliseconds, volume); | 342 audio_delay_milliseconds, volume); |
| 341 } | 343 } |
| 342 | 344 |
| 343 } // namespace media | 345 } // namespace media |
| OLD | NEW |