OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_MEDIA_RENDERER_AUDIO_HARDWARE_CONFIG_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_RENDERER_AUDIO_HARDWARE_CONFIG_H_ |
| 7 |
| 8 #include "base/compiler_specific.h" |
| 9 #include "base/synchronization/lock.h" |
| 10 #include "content/common/content_export.h" |
| 11 #include "media/base/audio_hardware_config.h" |
| 12 |
| 13 namespace content { |
| 14 |
| 15 // Provides access to the audio hardware configuration from the renderer side. |
| 16 class CONTENT_EXPORT RendererAudioHardwareConfig |
| 17 : public media::AudioHardwareConfig { |
| 18 public: |
| 19 // Must be constructed on the render thread. RendererAudioHardwareConfig |
| 20 // sends a synchronous IPC to retrieve the audio hardware configuration; once |
| 21 // complete accessors and updaters may be called from any thread. |
| 22 RendererAudioHardwareConfig(); |
| 23 virtual ~RendererAudioHardwareConfig(); |
| 24 |
| 25 // Accessors for the currently cached hardware configuration. Safe to call |
| 26 // from any thread. |
| 27 virtual int GetOutputBufferSize() OVERRIDE; |
| 28 virtual int GetOutputSampleRate() OVERRIDE; |
| 29 virtual int GetInputSampleRate() OVERRIDE; |
| 30 virtual media::ChannelLayout GetInputChannelLayout() OVERRIDE; |
| 31 |
| 32 // Allows callers to update the cached values for either input or output. The |
| 33 // values are paired under the assumption that these values will only be set |
| 34 // after an input or output device change respectively. Safe to call from |
| 35 // any thread. |
| 36 void UpdateInputConfig(int sample_rate, media::ChannelLayout channel_layout); |
| 37 void UpdateOutputConfig(int buffer_size, int sample_rate); |
| 38 |
| 39 private: |
| 40 // Cached values; access is protected by |config_lock_|. |
| 41 base::Lock config_lock_; |
| 42 int output_buffer_size_; |
| 43 int output_sample_rate_; |
| 44 int input_sample_rate_; |
| 45 media::ChannelLayout input_channel_layout_; |
| 46 }; |
| 47 |
| 48 } // namespace content |
| 49 |
| 50 #endif // CONTENT_RENDERER_MEDIA_RENDERER_AUDIO_HARDWARE_CONFIG_H_ |
OLD | NEW |