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_ALSA_ALSA_UTIL_H_ 6 #define MEDIA_AUDIO_ALSA_ALSA_UTIL_H_ 7 8 #include <alsa/asoundlib.h> 9 #include <string> 10 11 namespace media { 12 class AlsaWrapper; 13 } 14 15 namespace alsa_util { 16 17 snd_pcm_format_t BitsToFormat(int bits_per_sample); 18 19 snd_pcm_t* OpenCaptureDevice(media::AlsaWrapper* wrapper, 20 const char* device_name, 21 int channels, 22 int sample_rate, 23 snd_pcm_format_t pcm_format, 24 int latency_us); 25 26 snd_pcm_t* OpenPlaybackDevice(media::AlsaWrapper* wrapper, 27 const char* device_name, 28 int channels, 29 int sample_rate, 30 snd_pcm_format_t pcm_format, 31 int latency_us); 32 33 int CloseDevice(media::AlsaWrapper* wrapper, snd_pcm_t* handle); 34 35 snd_mixer_t* OpenMixer(media::AlsaWrapper* wrapper, 36 const std::string& device_name); 37 38 void CloseMixer(media::AlsaWrapper* wrapper, 39 snd_mixer_t* mixer, 40 const std::string& device_name); 41 42 snd_mixer_elem_t* LoadCaptureMixerElement(media::AlsaWrapper* wrapper, 43 snd_mixer_t* mixer); 44 45 } // namespace alsa_util 46 47 #endif // MEDIA_AUDIO_ALSA_ALSA_UTIL_H_ 48