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

Unified Diff: content/browser/renderer_host/media/audio_input_renderer_host.cc

Issue 12379071: Use multiple shared memory buffers cyclically for audio capture. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: code review Created 7 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 side-by-side diff with in-line comments
Download patch
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,10 @@
// 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;
+ int shared_memory_segment_count;
// The synchronous writer to be used by the controller. We have the
// ownership of the writer.
@@ -40,6 +42,7 @@
AudioInputRendererHost::AudioEntry::AudioEntry()
: stream_id(0),
+ shared_memory_segment_count(0),
pending_close(false) {
}
@@ -155,7 +158,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 +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));
@@ -234,18 +241,22 @@
// Create a new AudioEntry structure.
scoped_ptr<AudioEntry> entry(new AudioEntry());
- uint32 mem_size = sizeof(media::AudioInputBufferParameters) + buffer_size;
+ uint32 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(
+ 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);

Powered by Google App Engine
This is Rietveld 408576698