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

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

Issue 9702019: Adds Analog Gain Control (AGC) to the WebRTC client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Improved AGC comments Created 8 years, 9 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/process_util.h" 9 #include "base/process_util.h"
10 #include "base/shared_memory.h" 10 #include "base/shared_memory.h"
11 11
12 AudioInputSyncWriter::AudioInputSyncWriter(base::SharedMemory* shared_memory) 12 AudioInputSyncWriter::AudioInputSyncWriter(base::SharedMemory* shared_memory)
13 : shared_memory_(shared_memory) { 13 : shared_memory_(shared_memory) {
14 } 14 }
15 15
16 AudioInputSyncWriter::~AudioInputSyncWriter() {} 16 AudioInputSyncWriter::~AudioInputSyncWriter() {}
17 17
18 // TODO(henrika): Combine into one method (including Write).
18 void AudioInputSyncWriter::UpdateRecordedBytes(uint32 bytes) { 19 void AudioInputSyncWriter::UpdateRecordedBytes(uint32 bytes) {
19 socket_->Send(&bytes, sizeof(bytes)); 20 socket_->Send(&bytes, sizeof(bytes));
20 } 21 }
21 22
22 uint32 AudioInputSyncWriter::Write(const void* data, uint32 size) { 23 uint32 AudioInputSyncWriter::Write(const void* data, uint32 size,
23 uint32 write_size = std::min(size, shared_memory_->created_size()); 24 double volume) {
scherkus (not reviewing) 2012/03/26 22:41:04 nit: indent to align w/ other params
henrika (OOO until Aug 14) 2012/03/27 09:20:38 Done.
24 // Copy audio input samples from recorded data to shared memory. 25 AudioInputBuffer* buffer =
25 memcpy(shared_memory_->memory(), data, write_size); 26 reinterpret_cast<AudioInputBuffer*>(shared_memory_->memory());
26 return write_size; 27 buffer->params.volume = volume;
28 buffer->params.size = size;
29 memcpy(buffer->audio, data, size);
30
31 return size;
27 } 32 }
28 33
29 void AudioInputSyncWriter::Close() { 34 void AudioInputSyncWriter::Close() {
30 socket_->Close(); 35 socket_->Close();
31 } 36 }
32 37
33 bool AudioInputSyncWriter::Init() { 38 bool AudioInputSyncWriter::Init() {
34 socket_.reset(new base::CancelableSyncSocket()); 39 socket_.reset(new base::CancelableSyncSocket());
35 foreign_socket_.reset(new base::CancelableSyncSocket()); 40 foreign_socket_.reset(new base::CancelableSyncSocket());
36 return base::CancelableSyncSocket::CreatePair(socket_.get(), 41 return base::CancelableSyncSocket::CreatePair(socket_.get(),
(...skipping 15 matching lines...) Expand all
52 57
53 bool AudioInputSyncWriter::PrepareForeignSocketHandle( 58 bool AudioInputSyncWriter::PrepareForeignSocketHandle(
54 base::ProcessHandle process_handle, 59 base::ProcessHandle process_handle,
55 base::FileDescriptor* foreign_handle) { 60 base::FileDescriptor* foreign_handle) {
56 foreign_handle->fd = foreign_socket_->handle(); 61 foreign_handle->fd = foreign_socket_->handle();
57 foreign_handle->auto_close = false; 62 foreign_handle->auto_close = false;
58 return (foreign_handle->fd != -1); 63 return (foreign_handle->fd != -1);
59 } 64 }
60 65
61 #endif 66 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698