summaryrefslogtreecommitdiffstats
path: root/media/base/audio_hardware_config.h
diff options
context:
space:
mode:
authordalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-01 04:42:39 +0000
committerdalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-01 04:42:39 +0000
commit563d665f0a231e3a0237445b577b68bb9b3f212e (patch)
tree5f4b4dd7497f7fe94653850f3f4f3812fcecf4d8 /media/base/audio_hardware_config.h
parentccfa43f042db868f6584f9cceef94ca7c4ddf239 (diff)
downloadchromium_src-563d665f0a231e3a0237445b577b68bb9b3f212e.zip
chromium_src-563d665f0a231e3a0237445b577b68bb9b3f212e.tar.gz
chromium_src-563d665f0a231e3a0237445b577b68bb9b3f212e.tar.bz2
Introduce AudioHardwareConfig for renderer side audio device info.
As discussed, this creates a media::AudioHardwareConfig class lazily created, owned, and filled by RenderThreadImpl via a single synchronous IPC and updated via AudioMessageFilter. This change does not plumb part 2 where AudioRendererMixer recreates itself based on these device change updates. BUG=157216 TEST=New unittest. Device changes on Windows/Mac continue to work. Review URL: https://chromiumcodereview.appspot.com/11880009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180068 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/audio_hardware_config.h')
-rw-r--r--media/base/audio_hardware_config.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/media/base/audio_hardware_config.h b/media/base/audio_hardware_config.h
new file mode 100644
index 0000000..e61d9ba
--- /dev/null
+++ b/media/base/audio_hardware_config.h
@@ -0,0 +1,50 @@
+// Copyright (c) 2013 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.
+
+#ifndef MEDIA_BASE_AUDIO_HARDWARE_CONFIG_H_
+#define MEDIA_BASE_AUDIO_HARDWARE_CONFIG_H_
+
+#include "base/compiler_specific.h"
+#include "base/synchronization/lock.h"
+#include "media/base/channel_layout.h"
+#include "media/base/media_export.h"
+
+namespace media {
+
+// Provides thread safe access to the audio hardware configuration.
+class MEDIA_EXPORT AudioHardwareConfig {
+ public:
+ AudioHardwareConfig(int output_buffer_size, int output_sample_rate,
+ int input_sample_rate,
+ ChannelLayout input_channel_layout);
+ virtual ~AudioHardwareConfig();
+
+ // Accessors for the currently cached hardware configuration. Safe to call
+ // from any thread.
+ int GetOutputBufferSize();
+ int GetOutputSampleRate();
+ int GetInputSampleRate();
+ ChannelLayout GetInputChannelLayout();
+
+ // Allows callers to update the cached values for either input or output. The
+ // values are paired under the assumption that these values will only be set
+ // after an input or output device change respectively. Safe to call from
+ // any thread.
+ void UpdateInputConfig(int sample_rate, media::ChannelLayout channel_layout);
+ void UpdateOutputConfig(int buffer_size, int sample_rate);
+
+ private:
+ // Cached values; access is protected by |config_lock_|.
+ base::Lock config_lock_;
+ int output_buffer_size_;
+ int output_sample_rate_;
+ int input_sample_rate_;
+ ChannelLayout input_channel_layout_;
+
+ DISALLOW_COPY_AND_ASSIGN(AudioHardwareConfig);
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_AUDIO_HARDWARE_CONFIG_H_