summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorneb@chromium.org <neb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-23 00:08:59 +0000
committerneb@chromium.org <neb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-23 00:08:59 +0000
commit059096924140847a5eb24bfd9a11d488bca89aca (patch)
treeab1072b2f9666142f2167f783a92e407dcbc3322 /chrome
parent34564b7e3f5f3c414665c8150b61efeef3b93207 (diff)
downloadchromium_src-059096924140847a5eb24bfd9a11d488bca89aca.zip
chromium_src-059096924140847a5eb24bfd9a11d488bca89aca.tar.gz
chromium_src-059096924140847a5eb24bfd9a11d488bca89aca.tar.bz2
Add a parameter to CreateAudioStream to choose between standard and low-latency mode.
Review URL: http://codereview.chromium.org/661386 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42291 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/renderer_host/audio_renderer_host.cc27
-rw-r--r--chrome/browser/renderer_host/audio_renderer_host.h6
-rw-r--r--chrome/browser/renderer_host/audio_renderer_host_unittest.cc3
-rw-r--r--chrome/common/render_messages_internal.h5
-rw-r--r--chrome/renderer/media/audio_renderer_impl.cc3
-rw-r--r--chrome/renderer/pepper_devices.cc2
6 files changed, 26 insertions, 20 deletions
diff --git a/chrome/browser/renderer_host/audio_renderer_host.cc b/chrome/browser/renderer_host/audio_renderer_host.cc
index 4e9c4db..032978c 100644
--- a/chrome/browser/renderer_host/audio_renderer_host.cc
+++ b/chrome/browser/renderer_host/audio_renderer_host.cc
@@ -95,7 +95,8 @@ AudioRendererHost::IPCAudioSource::CreateIPCAudioSource(
int sample_rate,
char bits_per_sample,
uint32 decoded_packet_size,
- uint32 buffer_capacity) {
+ uint32 buffer_capacity,
+ bool low_latency) {
// Perform come preliminary checks on the parameters.
// Make sure the renderer didn't ask for too much memory.
if (buffer_capacity > kMaxBufferCapacity ||
@@ -153,16 +154,7 @@ AudioRendererHost::IPCAudioSource::CreateIPCAudioSource(
source->shared_memory_.Map(decoded_packet_size) &&
source->shared_memory_.ShareToProcess(process_handle,
&foreign_memory_handle)) {
- // TODO(cpu): better define what triggers the low latency mode.
- if (decoded_packet_size > kLowLatencyPacketThreshold) {
- // Regular latency mode.
- host->Send(new ViewMsg_NotifyAudioStreamCreated(
- route_id, stream_id, foreign_memory_handle, decoded_packet_size));
-
- // Also request the first packet to kick start the pre-rolling.
- source->StartBuffering();
- return source;
- } else {
+ if (low_latency) {
// Low latency mode. We use SyncSocket to signal.
base::SyncSocket* sockets[2] = {0};
if (base::SyncSocket::CreatePair(sockets)) {
@@ -186,6 +178,14 @@ AudioRendererHost::IPCAudioSource::CreateIPCAudioSource(
return source;
}
}
+ } else {
+ // Regular latency mode.
+ host->Send(new ViewMsg_NotifyAudioStreamCreated(
+ route_id, stream_id, foreign_memory_handle, decoded_packet_size));
+
+ // Also request the first packet to kick start the pre-rolling.
+ source->StartBuffering();
+ return source;
}
}
// Failure. Close and free acquired resources.
@@ -462,7 +462,7 @@ bool AudioRendererHost::IsAudioRendererHostMessage(
void AudioRendererHost::OnCreateStream(
const IPC::Message& msg, int stream_id,
- const ViewHostMsg_Audio_CreateStream_Params& params) {
+ const ViewHostMsg_Audio_CreateStream_Params& params, bool low_latency) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
DCHECK(Lookup(msg.routing_id(), stream_id) == NULL);
@@ -477,7 +477,8 @@ void AudioRendererHost::OnCreateStream(
params.sample_rate,
params.bits_per_sample,
params.packet_size,
- params.buffer_capacity);
+ params.buffer_capacity,
+ low_latency);
// If we have created the source successfully, adds it to the map.
if (source) {
diff --git a/chrome/browser/renderer_host/audio_renderer_host.h b/chrome/browser/renderer_host/audio_renderer_host.h
index 78ae292..c17350e 100644
--- a/chrome/browser/renderer_host/audio_renderer_host.h
+++ b/chrome/browser/renderer_host/audio_renderer_host.h
@@ -180,7 +180,8 @@ class AudioRendererHost
int sample_rate, // Sampling frequency/rate.
char bits_per_sample, // Number of bits per sample.
uint32 decoded_packet_size, // Number of bytes per packet.
- uint32 buffer_capacity // Number of bytes in the buffer.
+ uint32 buffer_capacity, // Number of bytes in the buffer.
+ bool low_latency // Use low-latency (socket) code
);
~IPCAudioSource();
@@ -288,7 +289,8 @@ class AudioRendererHost
// required properties. See IPCAudioSource::CreateIPCAudioSource() for more
// details.
void OnCreateStream(const IPC::Message& msg, int stream_id,
- const ViewHostMsg_Audio_CreateStream_Params& params);
+ const ViewHostMsg_Audio_CreateStream_Params& params,
+ bool low_latency);
// Starts buffering for the audio output stream. Delegates the start method
// call to the corresponding IPCAudioSource::Play().
diff --git a/chrome/browser/renderer_host/audio_renderer_host_unittest.cc b/chrome/browser/renderer_host/audio_renderer_host_unittest.cc
index f868c2a..b778dff 100644
--- a/chrome/browser/renderer_host/audio_renderer_host_unittest.cc
+++ b/chrome/browser/renderer_host/audio_renderer_host_unittest.cc
@@ -161,7 +161,8 @@ class AudioRendererHostTest : public testing::Test {
AudioManager::kAudioCDSampleRate,
16,
kPacketSize,
- kBufferCapacity);
+ kBufferCapacity,
+ false);
EXPECT_TRUE(source);
EXPECT_EQ(kProcessId, source->process_id());
EXPECT_EQ(kRouteId, source->route_id());
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index c645104..adac8b5 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -1824,9 +1824,10 @@ IPC_BEGIN_MESSAGES(ViewHost)
std::string /* proxy list */)
// Request that got sent to browser for creating an audio output stream
- IPC_MESSAGE_ROUTED2(ViewHostMsg_CreateAudioStream,
+ IPC_MESSAGE_ROUTED3(ViewHostMsg_CreateAudioStream,
int /* stream_id */,
- ViewHostMsg_Audio_CreateStream_Params)
+ ViewHostMsg_Audio_CreateStream_Params,
+ bool /* low-latency */)
// Tell the browser the audio buffer prepared for stream
// (render_view_id, stream_id) is filled and is ready to be consumed.
diff --git a/chrome/renderer/media/audio_renderer_impl.cc b/chrome/renderer/media/audio_renderer_impl.cc
index b03ba9e..70cf769 100644
--- a/chrome/renderer/media/audio_renderer_impl.cc
+++ b/chrome/renderer/media/audio_renderer_impl.cc
@@ -253,7 +253,8 @@ void AudioRendererImpl::OnCreateStream(
params.packet_size = packet_size;
params.buffer_capacity = buffer_capacity;
- filter_->Send(new ViewHostMsg_CreateAudioStream(0, stream_id_, params));
+ filter_->Send(new ViewHostMsg_CreateAudioStream(0, stream_id_, params,
+ false));
}
void AudioRendererImpl::OnPlay() {
diff --git a/chrome/renderer/pepper_devices.cc b/chrome/renderer/pepper_devices.cc
index c47b846..2120b7b 100644
--- a/chrome/renderer/pepper_devices.cc
+++ b/chrome/renderer/pepper_devices.cc
@@ -173,7 +173,7 @@ NPError AudioDeviceContext::Initialize(AudioMessageFilter* filter,
" bits, " << config->outputChannelMap << "channels";
stream_id_ = filter_->AddDelegate(this);
- filter->Send(new ViewHostMsg_CreateAudioStream(0, stream_id_, params));
+ filter->Send(new ViewHostMsg_CreateAudioStream(0, stream_id_, params, true));
return NPERR_NO_ERROR;
}