Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: media/audio/audio_input_device.cc

Issue 687563004: Change parameter type on AudioDeviceThread::Callback::Process() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/audio/audio_device_thread.cc ('k') | media/audio/audio_output_device.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
(...skipping 18 matching lines...) Expand all
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(int pending_data) override; 39 void Process(uint32 pending_data) override;
40 40
41 private: 41 private:
42 int current_segment_id_; 42 int current_segment_id_;
43 ScopedVector<media::AudioBus> audio_buses_; 43 ScopedVector<media::AudioBus> audio_buses_;
44 CaptureCallback* capture_callback_; 44 CaptureCallback* capture_callback_;
45 45
46 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback); 46 DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback);
47 }; 47 };
48 48
49 AudioInputDevice::AudioInputDevice( 49 AudioInputDevice::AudioInputDevice(
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 for (int i = 0; i < total_segments_; ++i) { 288 for (int i = 0; i < total_segments_; ++i) {
289 media::AudioInputBuffer* buffer = 289 media::AudioInputBuffer* buffer =
290 reinterpret_cast<media::AudioInputBuffer*>(ptr); 290 reinterpret_cast<media::AudioInputBuffer*>(ptr);
291 scoped_ptr<media::AudioBus> audio_bus = 291 scoped_ptr<media::AudioBus> audio_bus =
292 media::AudioBus::WrapMemory(audio_parameters_, buffer->audio); 292 media::AudioBus::WrapMemory(audio_parameters_, buffer->audio);
293 audio_buses_.push_back(audio_bus.release()); 293 audio_buses_.push_back(audio_bus.release());
294 ptr += segment_length_; 294 ptr += segment_length_;
295 } 295 }
296 } 296 }
297 297
298 void AudioInputDevice::AudioThreadCallback::Process(int pending_data) { 298 void AudioInputDevice::AudioThreadCallback::Process(uint32 pending_data) {
299 // The shared memory represents parameters, size of the data buffer and the 299 // The shared memory represents parameters, size of the data buffer and the
300 // actual data buffer containing audio data. Map the memory into this 300 // actual data buffer containing audio data. Map the memory into this
301 // structure and parse out parameters and the data area. 301 // structure and parse out parameters and the data area.
302 uint8* ptr = static_cast<uint8*>(shared_memory_.memory()); 302 uint8* ptr = static_cast<uint8*>(shared_memory_.memory());
303 ptr += current_segment_id_ * segment_length_; 303 ptr += current_segment_id_ * segment_length_;
304 AudioInputBuffer* buffer = reinterpret_cast<AudioInputBuffer*>(ptr); 304 AudioInputBuffer* buffer = reinterpret_cast<AudioInputBuffer*>(ptr);
305 // Usually this will be equal but in the case of low sample rate (e.g. 8kHz, 305 // Usually this will be equal but in the case of low sample rate (e.g. 8kHz,
306 // the buffer may be bigger (on mac at least)). 306 // the buffer may be bigger (on mac at least)).
307 DCHECK_GE(buffer->params.size, 307 DCHECK_GE(buffer->params.size,
308 segment_length_ - sizeof(AudioInputBufferParameters)); 308 segment_length_ - sizeof(AudioInputBufferParameters));
309 double volume = buffer->params.volume; 309 double volume = buffer->params.volume;
310 bool key_pressed = buffer->params.key_pressed; 310 bool key_pressed = buffer->params.key_pressed;
311 311
312 // Use pre-allocated audio bus wrapping existing block of shared memory. 312 // Use pre-allocated audio bus wrapping existing block of shared memory.
313 media::AudioBus* audio_bus = audio_buses_[current_segment_id_]; 313 media::AudioBus* audio_bus = audio_buses_[current_segment_id_];
314 314
315 // Deliver captured data to the client in floating point format 315 // Deliver captured data to the client in floating point format
316 // and update the audio-delay measurement. 316 // and update the audio-delay measurement.
317 int audio_delay_milliseconds = pending_data / bytes_per_ms_; 317 int audio_delay_milliseconds = pending_data / bytes_per_ms_;
318 capture_callback_->Capture( 318 capture_callback_->Capture(
319 audio_bus, audio_delay_milliseconds, volume, key_pressed); 319 audio_bus, audio_delay_milliseconds, volume, key_pressed);
320 320
321 if (++current_segment_id_ >= total_segments_) 321 if (++current_segment_id_ >= total_segments_)
322 current_segment_id_ = 0; 322 current_segment_id_ = 0;
323 } 323 }
324 324
325 } // namespace media 325 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_device_thread.cc ('k') | media/audio/audio_output_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698