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

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

Issue 8588030: Refactor the Get*Hardware* routines a bit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
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/renderer/media/audio_hardware.h"
6
7 #include "base/logging.h"
8 #include "content/common/view_messages.h"
9 #include "content/renderer/render_thread_impl.h"
10
11 static double output_sample_rate = 0.0;
12 static double input_sample_rate = 0.0;
13 static size_t output_buffer_size = 0;
14
15 namespace audio_hardware {
16
17 double GetOutputSampleRate() {
18 DCHECK(RenderThreadImpl::current() != NULL);
19
20 if (!output_sample_rate) {
21 RenderThreadImpl::current()->Send(
22 new ViewHostMsg_GetHardwareSampleRate(&output_sample_rate));
23 }
24 return output_sample_rate;
25 }
26
27 double GetInputSampleRate() {
28 DCHECK(RenderThreadImpl::current() != NULL);
29
30 if (!input_sample_rate) {
31 RenderThreadImpl::current()->Send(
32 new ViewHostMsg_GetHardwareInputSampleRate(&input_sample_rate));
33 }
34 return input_sample_rate;
35 }
36
37 size_t GetOutputBufferSize() {
38 DCHECK(RenderThreadImpl::current() != NULL);
39
40 if (!output_buffer_size) {
41 uint32 buffer_size = 0;
42 RenderThreadImpl::current()->Send(
43 new ViewHostMsg_GetHardwareBufferSize(&buffer_size));
44 output_buffer_size = buffer_size;
45 }
46
47 return output_buffer_size;
48 }
49
50 void ResetCache() {
51 DCHECK(RenderThreadImpl::current() != NULL);
52
53 output_sample_rate = 0.0;
54 input_sample_rate = 0.0;
55 output_buffer_size = 0;
56 }
57
58 } // namespace audio_hardware
OLDNEW
« no previous file with comments | « content/renderer/media/audio_hardware.h ('k') | content/renderer/media/webrtc_audio_device_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698