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

Unified Diff: chrome/browser/renderer_host/audio_renderer_host.cc

Issue 4661001: Simplified AudioOutputStream interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 10 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/renderer_host/audio_renderer_host_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_host/audio_renderer_host.cc
diff --git a/chrome/browser/renderer_host/audio_renderer_host.cc b/chrome/browser/renderer_host/audio_renderer_host.cc
index 4c833847dda1611c596e7e6756060e7ba5b864d7..5bfc77ea94310fcf7d96770870d1942731b53e11 100644
--- a/chrome/browser/renderer_host/audio_renderer_host.cc
+++ b/chrome/browser/renderer_host/audio_renderer_host.cc
@@ -55,7 +55,7 @@ static size_t GetMaxAudioStreamsAllowed() {
return kMaxStreams;
}
-static uint32 SelectHardwarePacketSize(AudioParameters params) {
+static uint32 SelectSamplesPerPacket(AudioParameters params) {
// Select the number of samples that can provide at least
// |kMillisecondsPerHardwarePacket| worth of audio data.
int samples = kMinSamplesPerHardwarePacket;
@@ -64,7 +64,7 @@ static uint32 SelectHardwarePacketSize(AudioParameters params) {
params.sample_rate * kMillisecondsPerHardwarePacket) {
samples *= 2;
}
- return params.channels * samples * params.bits_per_sample / 8;
+ return samples;
}
AudioRendererHost::AudioEntry::AudioEntry()
@@ -347,15 +347,17 @@ void AudioRendererHost::OnCreateStream(
return;
}
- // Select the hardwaer packet size if not specified.
- uint32 hardware_packet_size = params.packet_size;
- if (!hardware_packet_size) {
- hardware_packet_size = SelectHardwarePacketSize(params.params);
+ AudioParameters audio_params(params.params);
+
+ // Select the hardware packet size if not specified.
+ if (!audio_params.samples_per_packet) {
+ audio_params.samples_per_packet = SelectSamplesPerPacket(audio_params);
}
+ uint32 packet_size = audio_params.GetPacketSize();
scoped_ptr<AudioEntry> entry(new AudioEntry());
// Create the shared memory and share with the renderer process.
- if (!entry->shared_memory.CreateAndMapAnonymous(hardware_packet_size)) {
+ if (!entry->shared_memory.CreateAndMapAnonymous(packet_size)) {
// If creation of shared memory failed then send an error message.
SendErrorMessage(msg.routing_id(), stream_id);
return;
@@ -376,16 +378,13 @@ void AudioRendererHost::OnCreateStream(
// entry and construct an AudioOutputController.
entry->reader.reset(reader.release());
entry->controller =
- media::AudioOutputController::CreateLowLatency(
- this, params.params,
- hardware_packet_size,
- entry->reader.get());
+ media::AudioOutputController::CreateLowLatency(this, audio_params,
+ entry->reader.get());
} else {
// The choice of buffer capacity is based on experiment.
entry->controller =
- media::AudioOutputController::Create(this, params.params,
- hardware_packet_size,
- 3 * hardware_packet_size);
+ media::AudioOutputController::Create(this, audio_params,
+ 3 * packet_size);
}
if (!entry->controller) {
« no previous file with comments | « no previous file | chrome/browser/renderer_host/audio_renderer_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698