| Index: content/browser/renderer_host/media/audio_input_renderer_host.cc
|
| ===================================================================
|
| --- content/browser/renderer_host/media/audio_input_renderer_host.cc (revision 185810)
|
| +++ content/browser/renderer_host/media/audio_input_renderer_host.cc (working copy)
|
| @@ -27,8 +27,8 @@
|
| // The audio input stream ID in the render view.
|
| int stream_id;
|
|
|
| - // Shared memory for transmission of the audio data.
|
| - base::SharedMemory shared_memory;
|
| + // Shared memory buffers for transmission of the audio data.
|
| + AudioInputSyncWriter::SharedMemoryVector shared_memory;
|
|
|
| // The synchronous writer to be used by the controller. We have the
|
| // ownership of the writer.
|
| @@ -127,15 +127,6 @@
|
|
|
| // Once the audio stream is created then complete the creation process by
|
| // mapping shared memory and sharing with the renderer process.
|
| - base::SharedMemoryHandle foreign_memory_handle;
|
| - if (!entry->shared_memory.ShareToProcess(peer_handle(),
|
| - &foreign_memory_handle)) {
|
| - // If we failed to map and share the shared memory then close the audio
|
| - // stream and send an error message.
|
| - DeleteEntryOnError(entry);
|
| - return;
|
| - }
|
| -
|
| AudioInputSyncWriter* writer =
|
| static_cast<AudioInputSyncWriter*>(entry->writer.get());
|
|
|
| @@ -152,10 +143,23 @@
|
| DeleteEntryOnError(entry);
|
| return;
|
| }
|
| + Send(new AudioInputMsg_NotifyStreamCreated(entry->stream_id,
|
| + foreign_socket_handle,
|
| + entry->shared_memory.size()));
|
|
|
| - Send(new AudioInputMsg_NotifyStreamCreated(entry->stream_id,
|
| - foreign_memory_handle, foreign_socket_handle,
|
| - entry->shared_memory.created_size()));
|
| + for (size_t i = 0; i < entry->shared_memory.size(); ++i) {
|
| + base::SharedMemoryHandle foreign_memory_handle;
|
| + if (!entry->shared_memory[i]->ShareToProcess(peer_handle(),
|
| + &foreign_memory_handle)) {
|
| + // If we failed to map and share the shared memory then close the audio
|
| + // stream and send an error message.
|
| + DeleteEntryOnError(entry);
|
| + return;
|
| + }
|
| + Send(new AudioInputMsg_NotifySharedMemoryCreated(entry->stream_id,
|
| + foreign_memory_handle,
|
| + entry->shared_memory[i]->created_size(), i));
|
| + }
|
| }
|
|
|
| void AudioInputRendererHost::DoSendRecordingMessage(
|
| @@ -209,8 +213,11 @@
|
| }
|
|
|
| void AudioInputRendererHost::OnCreateStream(
|
| - int stream_id, const media::AudioParameters& params,
|
| - const std::string& device_id, bool automatic_gain_control) {
|
| + int stream_id,
|
| + const media::AudioParameters& params,
|
| + const std::string& device_id,
|
| + bool automatic_gain_control,
|
| + int shared_memory_count) {
|
| VLOG(1) << "AudioInputRendererHost::OnCreateStream(stream_id="
|
| << stream_id << ")";
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| @@ -238,10 +245,14 @@
|
|
|
| // Create the shared memory and share it with the renderer process
|
| // using a new SyncWriter object.
|
| - if (!entry->shared_memory.CreateAndMapAnonymous(mem_size)) {
|
| - // If creation of shared memory failed then send an error message.
|
| - SendErrorMessage(stream_id);
|
| - return;
|
| + entry->shared_memory.resize(shared_memory_count);
|
| + for (size_t i = 0; i < entry->shared_memory.size(); ++i) {
|
| + entry->shared_memory[i] = new base::SharedMemory();
|
| + if (!entry->shared_memory[i]->CreateAndMapAnonymous(mem_size)) {
|
| + // If creation of shared memory failed then send an error message.
|
| + SendErrorMessage(stream_id);
|
| + return;
|
| + }
|
| }
|
|
|
| scoped_ptr<AudioInputSyncWriter> writer(
|
|
|