Chromium Code Reviews| 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/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 AudioThreadCallback(const AudioParameters& audio_parameters, | 29 AudioThreadCallback(const AudioParameters& audio_parameters, |
| 30 base::SharedMemoryHandle memory, | 30 base::SharedMemoryHandle memory, |
| 31 int memory_length, | 31 int memory_length, |
| 32 int total_segments, | 32 int total_segments, |
| 33 CaptureCallback* capture_callback); | 33 CaptureCallback* capture_callback); |
| 34 ~AudioThreadCallback() override; | 34 ~AudioThreadCallback() override; |
| 35 | 35 |
| 36 void MapSharedMemory() override; | 36 void MapSharedMemory() override; |
| 37 | 37 |
| 38 // Called whenever we receive notifications about pending data. | 38 // Called whenever we receive notifications about pending data. |
| 39 void Process(uint32 pending_data) override; | 39 void Process(uint32_t pending_data) override; |
| 40 | 40 |
| 41 private: | 41 private: |
| 42 int current_segment_id_; | 42 int current_segment_id_; |
| 43 uint32 last_buffer_id_; | 43 uint32 last_buffer_id_; |
| 44 ScopedVector<media::AudioBus> audio_buses_; | 44 ScopedVector<media::AudioBus> audio_buses_; |
| 45 CaptureCallback* capture_callback_; | 45 CaptureCallback* capture_callback_; |
| 46 | 46 |
| 47 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback); | 47 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback); |
| 48 }; | 48 }; |
| 49 | 49 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 base::AutoLock auto_lock(audio_thread_lock_); | 134 base::AutoLock auto_lock(audio_thread_lock_); |
| 135 // TODO(miu): See TODO in OnStreamCreated method for AudioOutputDevice. | 135 // TODO(miu): See TODO in OnStreamCreated method for AudioOutputDevice. |
| 136 // Interface changes need to be made; likely, after AudioInputDevice is merged | 136 // Interface changes need to be made; likely, after AudioInputDevice is merged |
| 137 // into AudioOutputDevice (http://crbug.com/179597). | 137 // into AudioOutputDevice (http://crbug.com/179597). |
| 138 if (stopping_hack_) | 138 if (stopping_hack_) |
| 139 return; | 139 return; |
| 140 | 140 |
| 141 DCHECK(audio_thread_.IsStopped()); | 141 DCHECK(audio_thread_.IsStopped()); |
| 142 audio_callback_.reset(new AudioInputDevice::AudioThreadCallback( | 142 audio_callback_.reset(new AudioInputDevice::AudioThreadCallback( |
| 143 audio_parameters_, handle, length, total_segments, callback_)); | 143 audio_parameters_, handle, length, total_segments, callback_)); |
| 144 audio_thread_.Start( | 144 audio_thread_.Start(audio_callback_.get(), socket_handle, "AudioInputDevice", |
| 145 audio_callback_.get(), socket_handle, "AudioInputDevice", true); | 145 true); |
|
tommi (sloooow) - chröme
2015/12/08 08:34:51
no change?
Henrik Grunell
2015/12/08 09:30:34
Mandatory "git cl format media"...
tommi (sloooow) - chröme
2015/12/08 10:08:09
git cl format isn't supposed to change code that h
Henrik Grunell
2015/12/08 11:12:32
Ah, yes that's what happened. Reverted.
| |
| 146 | 146 |
| 147 state_ = RECORDING; | 147 state_ = RECORDING; |
| 148 ipc_->RecordStream(); | 148 ipc_->RecordStream(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void AudioInputDevice::OnVolume(double volume) { | 151 void AudioInputDevice::OnVolume(double volume) { |
| 152 NOTIMPLEMENTED(); | 152 NOTIMPLEMENTED(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void AudioInputDevice::OnStateChanged( | 155 void AudioInputDevice::OnStateChanged( |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 290 for (int i = 0; i < total_segments_; ++i) { | 290 for (int i = 0; i < total_segments_; ++i) { |
| 291 media::AudioInputBuffer* buffer = | 291 media::AudioInputBuffer* buffer = |
| 292 reinterpret_cast<media::AudioInputBuffer*>(ptr); | 292 reinterpret_cast<media::AudioInputBuffer*>(ptr); |
| 293 scoped_ptr<media::AudioBus> audio_bus = | 293 scoped_ptr<media::AudioBus> audio_bus = |
| 294 media::AudioBus::WrapMemory(audio_parameters_, buffer->audio); | 294 media::AudioBus::WrapMemory(audio_parameters_, buffer->audio); |
| 295 audio_buses_.push_back(audio_bus.Pass()); | 295 audio_buses_.push_back(audio_bus.Pass()); |
| 296 ptr += segment_length_; | 296 ptr += segment_length_; |
| 297 } | 297 } |
| 298 } | 298 } |
| 299 | 299 |
| 300 void AudioInputDevice::AudioThreadCallback::Process(uint32 pending_data) { | 300 void AudioInputDevice::AudioThreadCallback::Process(uint32_t pending_data) { |
| 301 // The shared memory represents parameters, size of the data buffer and the | 301 // The shared memory represents parameters, size of the data buffer and the |
| 302 // actual data buffer containing audio data. Map the memory into this | 302 // actual data buffer containing audio data. Map the memory into this |
| 303 // structure and parse out parameters and the data area. | 303 // structure and parse out parameters and the data area. |
| 304 uint8* ptr = static_cast<uint8*>(shared_memory_.memory()); | 304 uint8* ptr = static_cast<uint8*>(shared_memory_.memory()); |
| 305 ptr += current_segment_id_ * segment_length_; | 305 ptr += current_segment_id_ * segment_length_; |
| 306 AudioInputBuffer* buffer = reinterpret_cast<AudioInputBuffer*>(ptr); | 306 AudioInputBuffer* buffer = reinterpret_cast<AudioInputBuffer*>(ptr); |
| 307 | 307 |
| 308 // Usually this will be equal but in the case of low sample rate (e.g. 8kHz, | 308 // Usually this will be equal but in the case of low sample rate (e.g. 8kHz, |
| 309 // the buffer may be bigger (on mac at least)). | 309 // the buffer may be bigger (on mac at least)). |
| 310 DCHECK_GE(buffer->params.size, | 310 DCHECK_GE(buffer->params.size, |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 336 audio_bus, | 336 audio_bus, |
| 337 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms | 337 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms |
| 338 buffer->params.volume, | 338 buffer->params.volume, |
| 339 buffer->params.key_pressed); | 339 buffer->params.key_pressed); |
| 340 | 340 |
| 341 if (++current_segment_id_ >= total_segments_) | 341 if (++current_segment_id_ >= total_segments_) |
| 342 current_segment_id_ = 0; | 342 current_segment_id_ = 0; |
| 343 } | 343 } |
| 344 | 344 |
| 345 } // namespace media | 345 } // namespace media |
| OLD | NEW |