[safe-browsing] Database full hash matches like prefix match.
[chromium-blink-merge.git] / media / base / audio_hardware_config.h
bloba4baaac097909be858f61533e0260ce92a5845bf
1 // Copyright (c) 2013 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.
5 #ifndef MEDIA_BASE_AUDIO_HARDWARE_CONFIG_H_
6 #define MEDIA_BASE_AUDIO_HARDWARE_CONFIG_H_
8 #include "base/compiler_specific.h"
9 #include "base/synchronization/lock.h"
10 #include "media/audio/audio_parameters.h"
11 #include "media/base/channel_layout.h"
12 #include "media/base/media_export.h"
14 namespace media {
16 // Provides thread safe access to the audio hardware configuration.
17 class MEDIA_EXPORT AudioHardwareConfig {
18 public:
19 AudioHardwareConfig(const media::AudioParameters& input_params,
20 const media::AudioParameters& output_params);
21 virtual ~AudioHardwareConfig();
23 // Accessors for the currently cached hardware configuration. Safe to call
24 // from any thread.
25 int GetOutputBufferSize() const;
26 int GetOutputSampleRate() const;
27 ChannelLayout GetOutputChannelLayout() const;
28 int GetOutputChannels() const;
30 int GetInputSampleRate() const;
31 ChannelLayout GetInputChannelLayout() const;
32 int GetInputChannels() const;
34 media::AudioParameters GetInputConfig() const;
35 media::AudioParameters GetOutputConfig() const;
37 // Allows callers to update the cached values for either input or output. The
38 // values are paired under the assumption that these values will only be set
39 // after an input or output device change respectively. Safe to call from
40 // any thread.
41 void UpdateInputConfig(const media::AudioParameters& input_params);
42 void UpdateOutputConfig(const media::AudioParameters& output_params);
44 // For clients which don't need low latency, a larger buffer size should be
45 // used to save power and CPU resources.
46 int GetHighLatencyBufferSize() const;
48 private:
49 // Cached values; access is protected by |config_lock_|.
50 mutable base::Lock config_lock_;
51 media::AudioParameters input_params_;
52 media::AudioParameters output_params_;
54 DISALLOW_COPY_AND_ASSIGN(AudioHardwareConfig);
57 } // namespace media
59 #endif // MEDIA_BASE_AUDIO_HARDWARE_CONFIG_H_