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

Side by Side Diff: content/browser/renderer_host/media/audio_input_sync_writer.cc

Issue 21183002: Adding key press detection in the browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
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( 32 uint32 AudioInputSyncWriter::Write(const void* data,
33 const void* data, uint32 size, double volume) { 33 uint32 size,
34 double volume,
35 bool key_pressed) {
34 uint8* ptr = static_cast<uint8*>(shared_memory_->memory()); 36 uint8* ptr = static_cast<uint8*>(shared_memory_->memory());
35 ptr += current_segment_id_ * shared_memory_segment_size_; 37 ptr += current_segment_id_ * shared_memory_segment_size_;
36 media::AudioInputBuffer* buffer = 38 media::AudioInputBuffer* buffer =
37 reinterpret_cast<media::AudioInputBuffer*>(ptr); 39 reinterpret_cast<media::AudioInputBuffer*>(ptr);
38 buffer->params.volume = volume; 40 buffer->params.volume = volume;
39 buffer->params.size = size; 41 buffer->params.size = size;
42 buffer->params.key_pressed = key_pressed;
40 memcpy(buffer->audio, data, size); 43 memcpy(buffer->audio, data, size);
41 44
42 if (++current_segment_id_ >= shared_memory_segment_count_) 45 if (++current_segment_id_ >= shared_memory_segment_count_)
43 current_segment_id_ = 0; 46 current_segment_id_ = 0;
44 47
45 return size; 48 return size;
46 } 49 }
47 50
48 void AudioInputSyncWriter::Close() { 51 void AudioInputSyncWriter::Close() {
49 socket_->Close(); 52 socket_->Close();
(...skipping 23 matching lines...) Expand all
73 base::ProcessHandle process_handle, 76 base::ProcessHandle process_handle,
74 base::FileDescriptor* foreign_handle) { 77 base::FileDescriptor* foreign_handle) {
75 foreign_handle->fd = foreign_socket_->handle(); 78 foreign_handle->fd = foreign_socket_->handle();
76 foreign_handle->auto_close = false; 79 foreign_handle->auto_close = false;
77 return (foreign_handle->fd != -1); 80 return (foreign_handle->fd != -1);
78 } 81 }
79 82
80 #endif 83 #endif
81 84
82 } // namespace content 85 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698