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

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

Issue 22871007: Revert 217768 "Adding key press detection in the browser process." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 4 months 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 | Annotate | Revision Log
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/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 void AudioInputDevice::AudioThreadCallback::Process(int pending_data) { 287 void AudioInputDevice::AudioThreadCallback::Process(int pending_data) {
288 // The shared memory represents parameters, size of the data buffer and the 288 // The shared memory represents parameters, size of the data buffer and the
289 // actual data buffer containing audio data. Map the memory into this 289 // actual data buffer containing audio data. Map the memory into this
290 // structure and parse out parameters and the data area. 290 // structure and parse out parameters and the data area.
291 uint8* ptr = static_cast<uint8*>(shared_memory_.memory()); 291 uint8* ptr = static_cast<uint8*>(shared_memory_.memory());
292 ptr += current_segment_id_ * segment_length_; 292 ptr += current_segment_id_ * segment_length_;
293 AudioInputBuffer* buffer = reinterpret_cast<AudioInputBuffer*>(ptr); 293 AudioInputBuffer* buffer = reinterpret_cast<AudioInputBuffer*>(ptr);
294 DCHECK_EQ(buffer->params.size, 294 DCHECK_EQ(buffer->params.size,
295 segment_length_ - sizeof(AudioInputBufferParameters)); 295 segment_length_ - sizeof(AudioInputBufferParameters));
296 double volume = buffer->params.volume; 296 double volume = buffer->params.volume;
297 bool key_pressed = buffer->params.key_pressed;
298 297
299 int audio_delay_milliseconds = pending_data / bytes_per_ms_; 298 int audio_delay_milliseconds = pending_data / bytes_per_ms_;
300 int16* memory = reinterpret_cast<int16*>(&buffer->audio[0]); 299 int16* memory = reinterpret_cast<int16*>(&buffer->audio[0]);
301 const int bytes_per_sample = sizeof(memory[0]); 300 const int bytes_per_sample = sizeof(memory[0]);
302 301
303 if (++current_segment_id_ >= total_segments_) 302 if (++current_segment_id_ >= total_segments_)
304 current_segment_id_ = 0; 303 current_segment_id_ = 0;
305 304
306 // Deinterleave each channel and convert to 32-bit floating-point 305 // Deinterleave each channel and convert to 32-bit floating-point
307 // with nominal range -1.0 -> +1.0. 306 // with nominal range -1.0 -> +1.0.
308 audio_bus_->FromInterleaved(memory, audio_bus_->frames(), bytes_per_sample); 307 audio_bus_->FromInterleaved(memory, audio_bus_->frames(), bytes_per_sample);
309 308
310 // Deliver captured data to the client in floating point format 309 // Deliver captured data to the client in floating point format
311 // and update the audio-delay measurement. 310 // and update the audio-delay measurement.
312 capture_callback_->Capture( 311 capture_callback_->Capture(audio_bus_.get(),
313 audio_bus_.get(), audio_delay_milliseconds, volume, key_pressed); 312 audio_delay_milliseconds, volume);
314 } 313 }
315 314
316 } // namespace media 315 } // namespace media
OLDNEW
« no previous file with comments | « trunk/src/media/audio/audio_input_controller_unittest.cc ('k') | trunk/src/media/audio/audio_parameters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698