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

Side by Side Diff: content/browser/renderer_host/media/audio_common.cc

Issue 9416085: Increase the buffer size in AudioRendererImpl to fix muted playback rate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase ToT Created 8 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/renderer_host/media/audio_common.h"
6
7 #include "base/time.h"
8 #include "media/audio/audio_parameters.h"
9
10 // The minimum number of samples in a hardware packet.
11 // This value is selected so that we can handle down to 5khz sample rate.
12 static const int kMinSamplesPerHardwarePacket = 1024;
13
14 // The maximum number of samples in a hardware packet.
15 // This value is selected so that we can handle up to 192khz sample rate.
16 static const int kMaxSamplesPerHardwarePacket = 64 * 1024;
17
18 // This constant governs the hardware audio buffer size, this value should be
19 // chosen carefully.
20 // This value is selected so that we have 8192 samples for 48khz streams.
21 static const int kMillisecondsPerHardwarePacket = 170;
22
23 uint32 SelectSamplesPerPacket(const AudioParameters& params) {
24 // Select the number of samples that can provide at least
25 // |kMillisecondsPerHardwarePacket| worth of audio data.
26 int samples = kMinSamplesPerHardwarePacket;
27 while (samples <= kMaxSamplesPerHardwarePacket &&
28 samples * base::Time::kMillisecondsPerSecond <
29 params.sample_rate * kMillisecondsPerHardwarePacket) {
30 samples *= 2;
31 }
32 return samples;
33 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/audio_common.h ('k') | content/browser/renderer_host/media/audio_input_renderer_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698