Chromium Code Reviews| Index: content/browser/renderer_host/media/audio_input_renderer_host.cc |
| =================================================================== |
| --- content/browser/renderer_host/media/audio_input_renderer_host.cc (revision 186364) |
| +++ content/browser/renderer_host/media/audio_input_renderer_host.cc (working copy) |
| @@ -27,8 +27,11 @@ |
| // The audio input stream ID in the render view. |
| int stream_id; |
| - // Shared memory for transmission of the audio data. |
| + // Shared memory for transmission of the audio data. It has |
| + // |shared_memory_segment_count| equal lengthed segments. |
| base::SharedMemory shared_memory; |
| + uint32 shared_memory_segment_size; |
|
miu
2013/03/06 18:06:41
I think you can get rid of shared_memory_segment_s
wjia(left Chromium)
2013/03/06 22:12:41
Done.
|
| + uint32 shared_memory_segment_count; |
|
miu
2013/03/06 18:06:41
C++ Style: Should be int instead of uint32.
wjia(left Chromium)
2013/03/06 22:12:41
Done.
|
| // The synchronous writer to be used by the controller. We have the |
| // ownership of the writer. |
| @@ -40,6 +43,8 @@ |
| AudioInputRendererHost::AudioEntry::AudioEntry() |
| : stream_id(0), |
| + shared_memory_segment_size(0), |
| + shared_memory_segment_count(0), |
| pending_close(false) { |
| } |
| @@ -155,7 +160,8 @@ |
| Send(new AudioInputMsg_NotifyStreamCreated(entry->stream_id, |
| foreign_memory_handle, foreign_socket_handle, |
| - entry->shared_memory.created_size())); |
| + entry->shared_memory.created_size(), |
| + entry->shared_memory_segment_count)); |
| } |
| void AudioInputRendererHost::DoSendRecordingMessage( |
| @@ -209,8 +215,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)); |
| @@ -234,18 +243,22 @@ |
| // Create a new AudioEntry structure. |
| scoped_ptr<AudioEntry> entry(new AudioEntry()); |
| - uint32 mem_size = sizeof(media::AudioInputBufferParameters) + buffer_size; |
| + entry->shared_memory_segment_size = |
| + sizeof(media::AudioInputBufferParameters) + buffer_size; |
| + entry->shared_memory_segment_count = shared_memory_count; |
| // Create the shared memory and share it with the renderer process |
| // using a new SyncWriter object. |
| - if (!entry->shared_memory.CreateAndMapAnonymous(mem_size)) { |
| + if (!entry->shared_memory.CreateAndMapAnonymous( |
| + entry->shared_memory_segment_size * entry->shared_memory_segment_count)) { |
| // If creation of shared memory failed then send an error message. |
| SendErrorMessage(stream_id); |
| return; |
| } |
| scoped_ptr<AudioInputSyncWriter> writer( |
| - new AudioInputSyncWriter(&entry->shared_memory)); |
| + new AudioInputSyncWriter(&entry->shared_memory, |
| + entry->shared_memory_segment_count)); |
| if (!writer->Init()) { |
| SendErrorMessage(stream_id); |