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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/audio_hardware.cc
===================================================================
--- content/renderer/media/audio_hardware.cc (revision 0)
+++ content/renderer/media/audio_hardware.cc (revision 0)
@@ -0,0 +1,58 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/media/audio_hardware.h"
+
+#include "base/logging.h"
+#include "content/common/view_messages.h"
+#include "content/renderer/render_thread_impl.h"
+
+static double output_sample_rate = 0.0;
+static double input_sample_rate = 0.0;
+static size_t output_buffer_size = 0;
+
+namespace audio_hardware {
+
+double GetOutputSampleRate() {
+ DCHECK(RenderThreadImpl::current() != NULL);
+
+ if (!output_sample_rate) {
+ RenderThreadImpl::current()->Send(
+ new ViewHostMsg_GetHardwareSampleRate(&output_sample_rate));
+ }
+ return output_sample_rate;
+}
+
+double GetInputSampleRate() {
+ DCHECK(RenderThreadImpl::current() != NULL);
+
+ if (!input_sample_rate) {
+ RenderThreadImpl::current()->Send(
+ new ViewHostMsg_GetHardwareInputSampleRate(&input_sample_rate));
+ }
+ return input_sample_rate;
+}
+
+size_t GetOutputBufferSize() {
+ DCHECK(RenderThreadImpl::current() != NULL);
+
+ if (!output_buffer_size) {
+ uint32 buffer_size = 0;
+ RenderThreadImpl::current()->Send(
+ new ViewHostMsg_GetHardwareBufferSize(&buffer_size));
+ output_buffer_size = buffer_size;
+ }
+
+ return output_buffer_size;
+}
+
+void ResetCache() {
+ DCHECK(RenderThreadImpl::current() != NULL);
+
+ output_sample_rate = 0.0;
+ input_sample_rate = 0.0;
+ output_buffer_size = 0;
+}
+
+} // namespace audio_hardware
Property changes on: content\renderer\media\audio_hardware.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« 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