1 // Copyright 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 MEDIA_AUDIO_CRAS_AUDIO_MANAGER_CRAS_H_ 6 #define MEDIA_AUDIO_CRAS_AUDIO_MANAGER_CRAS_H_ 7 8 #include <cras_types.h> 9 10 #include <string> 11 12 #include "base/compiler_specific.h" 13 #include "base/memory/ref_counted.h" 14 #include "media/audio/audio_manager_base.h" 15 16 namespace media { 17 18 class MEDIA_EXPORT AudioManagerCras : public AudioManagerBase { 19 public: 20 AudioManagerCras(AudioLogFactory* audio_log_factory); 21 22 // AudioManager implementation. 23 virtual bool HasAudioOutputDevices() OVERRIDE; 24 virtual bool HasAudioInputDevices() OVERRIDE; 25 virtual void ShowAudioInputSettings() OVERRIDE; 26 virtual void GetAudioInputDeviceNames( 27 AudioDeviceNames* device_names) OVERRIDE; 28 virtual void GetAudioOutputDeviceNames( 29 AudioDeviceNames* device_names) OVERRIDE; 30 virtual AudioParameters GetInputStreamParameters( 31 const std::string& device_id) OVERRIDE; 32 virtual void SetHasKeyboardMic() OVERRIDE; 33 34 // AudioManagerBase implementation. 35 virtual AudioOutputStream* MakeLinearOutputStream( 36 const AudioParameters& params) OVERRIDE; 37 virtual AudioOutputStream* MakeLowLatencyOutputStream( 38 const AudioParameters& params, 39 const std::string& device_id) OVERRIDE; 40 virtual AudioInputStream* MakeLinearInputStream( 41 const AudioParameters& params, const std::string& device_id) OVERRIDE; 42 virtual AudioInputStream* MakeLowLatencyInputStream( 43 const AudioParameters& params, const std::string& device_id) OVERRIDE; 44 45 static snd_pcm_format_t BitsToFormat(int bits_per_sample); 46 47 protected: 48 virtual ~AudioManagerCras(); 49 50 virtual AudioParameters GetPreferredOutputStreamParameters( 51 const std::string& output_device_id, 52 const AudioParameters& input_params) OVERRIDE; 53 54 private: 55 // Called by MakeLinearOutputStream and MakeLowLatencyOutputStream. 56 AudioOutputStream* MakeOutputStream(const AudioParameters& params); 57 58 // Called by MakeLinearInputStream and MakeLowLatencyInputStream. 59 AudioInputStream* MakeInputStream(const AudioParameters& params, 60 const std::string& device_id); 61 62 bool has_keyboard_mic_; 63 64 DISALLOW_COPY_AND_ASSIGN(AudioManagerCras); 65 }; 66 67 } // namespace media 68 69 #endif // MEDIA_AUDIO_CRAS_AUDIO_MANAGER_CRAS_H_ 70