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

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

Issue 10830268: Allow audio system to handle synchronized low-latency audio I/O (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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_renderer_host.cc
===================================================================
--- content/browser/renderer_host/media/audio_renderer_host.cc (revision 156123)
+++ content/browser/renderer_host/media/audio_renderer_host.cc (working copy)
@@ -18,6 +18,7 @@
using content::BrowserMessageFilter;
using content::BrowserThread;
+using media::AudioBus;
AudioRendererHost::AudioEntry::AudioEntry()
: stream_id(0),
@@ -194,7 +195,7 @@
}
void AudioRendererHost::OnCreateStream(
- int stream_id, const media::AudioParameters& params) {
+ int stream_id, const media::AudioParameters& params, int input_channels) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK(LookupById(stream_id) == NULL);
@@ -204,11 +205,28 @@
DCHECK_LE(buffer_size,
static_cast<uint32>(media::limits::kMaxPacketSizeInBytes));
+ DCHECK_GE(input_channels, 0);
+ DCHECK_LT(input_channels, media::limits::kMaxChannels);
+
+ // Calculate output and input memory size.
+ int output_memory_size = AudioBus::CalculateMemorySize(audio_params);
+ DCHECK_GT(output_memory_size, 0);
+
+ int frames = audio_params.frames_per_buffer();
+ int input_memory_size =
+ AudioBus::CalculateMemorySize(input_channels, frames);
+
+ DCHECK_GE(input_memory_size, 0);
+
scoped_ptr<AudioEntry> entry(new AudioEntry());
// Create the shared memory and share with the renderer process.
+ // For synchronized I/O (if input_channels > 0) then we allocate
+ // extra memory after the output data for the input data.
+ uint32 io_buffer_size = output_memory_size + input_memory_size;
+
uint32 shared_memory_size =
- media::TotalSharedMemorySizeInBytes(buffer_size);
+ media::TotalSharedMemorySizeInBytes(io_buffer_size);
if (!entry->shared_memory.CreateAndMapAnonymous(shared_memory_size)) {
// If creation of shared memory failed then send an error message.
SendErrorMessage(stream_id);
@@ -217,7 +235,7 @@
// Create sync reader and try to initialize it.
scoped_ptr<AudioSyncReader> reader(
- new AudioSyncReader(&entry->shared_memory, params));
+ new AudioSyncReader(&entry->shared_memory, params, input_channels));
if (!reader->Init()) {
SendErrorMessage(stream_id);

Powered by Google App Engine
This is Rietveld 408576698