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

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

Issue 9655018: Make AudioParameters a class instead of a struct (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix copyright years 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
« no previous file with comments | « content/renderer/media/audio_hardware.h ('k') | content/renderer/media/audio_input_device.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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
11 static double output_sample_rate = 0.0; 11 static int output_sample_rate = 0;
12 static double input_sample_rate = 0.0; 12 static int input_sample_rate = 0;
13 static size_t output_buffer_size = 0; 13 static size_t output_buffer_size = 0;
14 static uint32 input_channel_count = 0; 14 static ChannelLayout input_channel_layout = CHANNEL_LAYOUT_NONE;
15 15
16 namespace audio_hardware { 16 namespace audio_hardware {
17 17
18 double GetOutputSampleRate() { 18 int GetOutputSampleRate() {
19 DCHECK(RenderThreadImpl::current() != NULL); 19 DCHECK(RenderThreadImpl::current() != NULL);
20 20
21 if (!output_sample_rate) { 21 if (!output_sample_rate) {
22 RenderThreadImpl::current()->Send( 22 RenderThreadImpl::current()->Send(
23 new ViewHostMsg_GetHardwareSampleRate(&output_sample_rate)); 23 new ViewHostMsg_GetHardwareSampleRate(&output_sample_rate));
24 } 24 }
25 return output_sample_rate; 25 return output_sample_rate;
26 } 26 }
27 27
28 double GetInputSampleRate() { 28 int GetInputSampleRate() {
29 DCHECK(RenderThreadImpl::current() != NULL); 29 DCHECK(RenderThreadImpl::current() != NULL);
30 30
31 if (!input_sample_rate) { 31 if (!input_sample_rate) {
32 RenderThreadImpl::current()->Send( 32 RenderThreadImpl::current()->Send(
33 new ViewHostMsg_GetHardwareInputSampleRate(&input_sample_rate)); 33 new ViewHostMsg_GetHardwareInputSampleRate(&input_sample_rate));
34 } 34 }
35 return input_sample_rate; 35 return input_sample_rate;
36 } 36 }
37 37
38 size_t GetOutputBufferSize() { 38 size_t GetOutputBufferSize() {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // |kMillisecondsPerHardwarePacket| worth of audio data. 71 // |kMillisecondsPerHardwarePacket| worth of audio data.
72 size_t samples = kMinSamplesPerHardwarePacket; 72 size_t samples = kMinSamplesPerHardwarePacket;
73 while (samples <= kMaxSamplesPerHardwarePacket && 73 while (samples <= kMaxSamplesPerHardwarePacket &&
74 samples * base::Time::kMillisecondsPerSecond < 74 samples * base::Time::kMillisecondsPerSecond <
75 sample_rate * kMillisecondsPerHardwarePacket) { 75 sample_rate * kMillisecondsPerHardwarePacket) {
76 samples *= 2; 76 samples *= 2;
77 } 77 }
78 return samples; 78 return samples;
79 } 79 }
80 80
81 uint32 GetInputChannelCount() { 81 ChannelLayout GetInputChannelLayout() {
82 DCHECK(RenderThreadImpl::current() != NULL); 82 DCHECK(RenderThreadImpl::current() != NULL);
83 83
84 if (!input_channel_count) { 84 if (input_channel_layout == CHANNEL_LAYOUT_NONE) {
85 uint32 channels = 0; 85 ChannelLayout layout = CHANNEL_LAYOUT_NONE;
86 RenderThreadImpl::current()->Send( 86 RenderThreadImpl::current()->Send(
87 new ViewHostMsg_GetHardwareInputChannelCount(&channels)); 87 new ViewHostMsg_GetHardwareInputChannelLayout(&layout));
88 input_channel_count = channels; 88 input_channel_layout = layout;
89 } 89 }
90 90
91 return input_channel_count; 91 return input_channel_layout;
92 } 92 }
93 93
94 void ResetCache() { 94 void ResetCache() {
95 DCHECK(RenderThreadImpl::current() != NULL); 95 DCHECK(RenderThreadImpl::current() != NULL);
96 96
97 output_sample_rate = 0.0; 97 output_sample_rate = 0.0;
98 input_sample_rate = 0.0; 98 input_sample_rate = 0.0;
99 output_buffer_size = 0; 99 output_buffer_size = 0;
100 input_channel_count = 0; 100 input_channel_layout = CHANNEL_LAYOUT_NONE;
101 } 101 }
102 102
103 } // namespace audio_hardware 103 } // namespace audio_hardware
OLDNEW
« no previous file with comments | « content/renderer/media/audio_hardware.h ('k') | content/renderer/media/audio_input_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698