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

Unified Diff: content/renderer/media/audio_input_message_filter.cc

Issue 12379071: Use multiple shared memory buffers cyclically for audio capture. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: rebase Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/audio_input_message_filter.cc
===================================================================
--- content/renderer/media/audio_input_message_filter.cc (revision 186213)
+++ content/renderer/media/audio_input_message_filter.cc (working copy)
@@ -46,6 +46,8 @@
IPC_BEGIN_MESSAGE_MAP(AudioInputMessageFilter, message)
IPC_MESSAGE_HANDLER(AudioInputMsg_NotifyStreamCreated,
OnStreamCreated)
+ IPC_MESSAGE_HANDLER(AudioInputMsg_NotifySharedMemoryCreated,
+ OnSharedMemoryCreated)
IPC_MESSAGE_HANDLER(AudioInputMsg_NotifyStreamVolume, OnStreamVolume)
IPC_MESSAGE_HANDLER(AudioInputMsg_NotifyStreamStateChanged,
OnStreamStateChanged)
@@ -88,13 +90,12 @@
void AudioInputMessageFilter::OnStreamCreated(
int stream_id,
- base::SharedMemoryHandle handle,
#if defined(OS_WIN)
base::SyncSocket::Handle socket_handle,
#else
base::FileDescriptor socket_descriptor,
#endif
- uint32 length) {
+ uint32 total_handles) {
DCHECK(io_message_loop_->BelongsToCurrentThread());
#if !defined(OS_WIN)
@@ -104,14 +105,31 @@
if (!delegate) {
DLOG(WARNING) << "Got audio stream event for a non-existent or removed"
<< " audio capturer (stream_id=" << stream_id << ").";
- base::SharedMemory::CloseHandle(handle);
base::SyncSocket socket(socket_handle);
return;
}
// Forward message to the stream delegate.
- delegate->OnStreamCreated(handle, socket_handle, length);
+ delegate->OnStreamCreated(socket_handle, total_handles);
}
+void AudioInputMessageFilter::OnSharedMemoryCreated(
+ int stream_id,
+ base::SharedMemoryHandle handle,
+ uint32 length,
+ uint32 handle_index) {
+ DCHECK(io_message_loop_->BelongsToCurrentThread());
+
+ media::AudioInputIPCDelegate* delegate = delegates_.Lookup(stream_id);
+ if (!delegate) {
+ DLOG(WARNING) << "Got audio stream event for a non-existent or removed"
+ << " audio capturer (stream_id=" << stream_id << ").";
+ base::SharedMemory::CloseHandle(handle);
+ return;
+ }
+ // Forward message to the stream delegate.
+ delegate->OnSharedMemoryCreated(handle, length, handle_index);
+}
+
void AudioInputMessageFilter::OnStreamVolume(int stream_id, double volume) {
DCHECK(io_message_loop_->BelongsToCurrentThread());
media::AudioInputIPCDelegate* delegate = delegates_.Lookup(stream_id);
@@ -160,9 +178,11 @@
void AudioInputMessageFilter::CreateStream(int stream_id,
const media::AudioParameters& params,
const std::string& device_id,
- bool automatic_gain_control) {
+ bool automatic_gain_control,
+ int shared_memory_count) {
Send(new AudioInputHostMsg_CreateStream(
- stream_id, params, device_id, automatic_gain_control));
+ stream_id, params, device_id, automatic_gain_control,
+ shared_memory_count));
}
void AudioInputMessageFilter::AssociateStreamWithConsumer(int stream_id,

Powered by Google App Engine
This is Rietveld 408576698