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

Side by Side Diff: content/renderer/media/audio_hardware.cc

Issue 9395057: Fix muted audio when playback rate != 1.0 or 0.0 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Response to CR Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/audio_hardware.h" 5 #include "content/renderer/media/audio_hardware.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/common/view_messages.h" 8 #include "content/common/view_messages.h"
9 #include "content/renderer/render_thread_impl.h" 9 #include "content/renderer/render_thread_impl.h"
10 10
(...skipping 30 matching lines...) Expand all
41 if (!output_buffer_size) { 41 if (!output_buffer_size) {
42 uint32 buffer_size = 0; 42 uint32 buffer_size = 0;
43 RenderThreadImpl::current()->Send( 43 RenderThreadImpl::current()->Send(
44 new ViewHostMsg_GetHardwareBufferSize(&buffer_size)); 44 new ViewHostMsg_GetHardwareBufferSize(&buffer_size));
45 output_buffer_size = buffer_size; 45 output_buffer_size = buffer_size;
46 } 46 }
47 47
48 return output_buffer_size; 48 return output_buffer_size;
49 } 49 }
50 50
51 size_t GetHighLatencyOutputBufferSize(int sample_rate) {
52 // kNominalBufferSize has been tested on Windows, Mac OS X, and Linux
53 // with the AUDIO_PCM_LINEAR flag.
54 const size_t kNominalBufferSize = 2048;
55
56 if (sample_rate <= 48000)
57 return kNominalBufferSize;
58 else if (sample_rate <= 96000)
59 return kNominalBufferSize * 2;
60
61 return kNominalBufferSize * 4;
62 }
63
51 uint32 GetInputChannelCount() { 64 uint32 GetInputChannelCount() {
52 DCHECK(RenderThreadImpl::current() != NULL); 65 DCHECK(RenderThreadImpl::current() != NULL);
53 66
54 if (!input_channel_count) { 67 if (!input_channel_count) {
55 uint32 channels = 0; 68 uint32 channels = 0;
56 RenderThreadImpl::current()->Send( 69 RenderThreadImpl::current()->Send(
57 new ViewHostMsg_GetHardwareInputChannelCount(&channels)); 70 new ViewHostMsg_GetHardwareInputChannelCount(&channels));
58 input_channel_count = channels; 71 input_channel_count = channels;
59 } 72 }
60 73
61 return input_channel_count; 74 return input_channel_count;
62 } 75 }
63 76
64 void ResetCache() { 77 void ResetCache() {
65 DCHECK(RenderThreadImpl::current() != NULL); 78 DCHECK(RenderThreadImpl::current() != NULL);
66 79
67 output_sample_rate = 0.0; 80 output_sample_rate = 0.0;
68 input_sample_rate = 0.0; 81 input_sample_rate = 0.0;
69 output_buffer_size = 0; 82 output_buffer_size = 0;
70 input_channel_count = 0; 83 input_channel_count = 0;
71 } 84 }
72 85
73 } // namespace audio_hardware 86 } // namespace audio_hardware
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698