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

Side by Side Diff: trunk/src/content/browser/renderer_host/media/audio_input_sync_writer.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 "content/browser/renderer_host/media/audio_input_sync_writer.h" 5 #include "content/browser/renderer_host/media/audio_input_sync_writer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 10
(...skipping 11 matching lines...) Expand all
22 shared_memory->requested_size() / shared_memory_segment_count; 22 shared_memory->requested_size() / shared_memory_segment_count;
23 } 23 }
24 24
25 AudioInputSyncWriter::~AudioInputSyncWriter() {} 25 AudioInputSyncWriter::~AudioInputSyncWriter() {}
26 26
27 // TODO(henrika): Combine into one method (including Write). 27 // TODO(henrika): Combine into one method (including Write).
28 void AudioInputSyncWriter::UpdateRecordedBytes(uint32 bytes) { 28 void AudioInputSyncWriter::UpdateRecordedBytes(uint32 bytes) {
29 socket_->Send(&bytes, sizeof(bytes)); 29 socket_->Send(&bytes, sizeof(bytes));
30 } 30 }
31 31
32 uint32 AudioInputSyncWriter::Write(const void* data, 32 uint32 AudioInputSyncWriter::Write(
33 uint32 size, 33 const void* data, uint32 size, double volume) {
34 double volume,
35 bool key_pressed) {
36 uint8* ptr = static_cast<uint8*>(shared_memory_->memory()); 34 uint8* ptr = static_cast<uint8*>(shared_memory_->memory());
37 ptr += current_segment_id_ * shared_memory_segment_size_; 35 ptr += current_segment_id_ * shared_memory_segment_size_;
38 media::AudioInputBuffer* buffer = 36 media::AudioInputBuffer* buffer =
39 reinterpret_cast<media::AudioInputBuffer*>(ptr); 37 reinterpret_cast<media::AudioInputBuffer*>(ptr);
40 buffer->params.volume = volume; 38 buffer->params.volume = volume;
41 buffer->params.size = size; 39 buffer->params.size = size;
42 buffer->params.key_pressed = key_pressed;
43 memcpy(buffer->audio, data, size); 40 memcpy(buffer->audio, data, size);
44 41
45 if (++current_segment_id_ >= shared_memory_segment_count_) 42 if (++current_segment_id_ >= shared_memory_segment_count_)
46 current_segment_id_ = 0; 43 current_segment_id_ = 0;
47 44
48 return size; 45 return size;
49 } 46 }
50 47
51 void AudioInputSyncWriter::Close() { 48 void AudioInputSyncWriter::Close() {
52 socket_->Close(); 49 socket_->Close();
(...skipping 23 matching lines...) Expand all
76 base::ProcessHandle process_handle, 73 base::ProcessHandle process_handle,
77 base::FileDescriptor* foreign_handle) { 74 base::FileDescriptor* foreign_handle) {
78 foreign_handle->fd = foreign_socket_->handle(); 75 foreign_handle->fd = foreign_socket_->handle();
79 foreign_handle->auto_close = false; 76 foreign_handle->auto_close = false;
80 return (foreign_handle->fd != -1); 77 return (foreign_handle->fd != -1);
81 } 78 }
82 79
83 #endif 80 #endif
84 81
85 } // namespace content 82 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698