alsa_util.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #ifndef MEDIA_AUDIO_ALSA_ALSA_UTIL_H_
  5. #define MEDIA_AUDIO_ALSA_ALSA_UTIL_H_
  6. #include <alsa/asoundlib.h>
  7. #include <string>
  8. #include "media/base/media_export.h"
  9. namespace media {
  10. class AlsaWrapper;
  11. }
  12. namespace alsa_util {
  13. // When opening ALSA devices, |period_us| is the size of a packet and
  14. // |buffer_us| is the size of the ring buffer, which consists of multiple
  15. // packets. In capture devices, the latency relies more on |period_us|, and thus
  16. // one may require more details upon the value implicitly set by ALSA.
  17. MEDIA_EXPORT snd_pcm_t* OpenCaptureDevice(media::AlsaWrapper* wrapper,
  18. const char* device_name,
  19. int channels,
  20. int sample_rate,
  21. snd_pcm_format_t pcm_format,
  22. int buffer_us,
  23. int period_us);
  24. snd_pcm_t* OpenPlaybackDevice(media::AlsaWrapper* wrapper,
  25. const char* device_name,
  26. int channels,
  27. int sample_rate,
  28. snd_pcm_format_t pcm_format,
  29. int buffer_us);
  30. int CloseDevice(media::AlsaWrapper* wrapper, snd_pcm_t* handle);
  31. snd_mixer_t* OpenMixer(media::AlsaWrapper* wrapper,
  32. const std::string& device_name);
  33. void CloseMixer(media::AlsaWrapper* wrapper,
  34. snd_mixer_t* mixer,
  35. const std::string& device_name);
  36. snd_mixer_elem_t* LoadCaptureMixerElement(media::AlsaWrapper* wrapper,
  37. snd_mixer_t* mixer);
  38. } // namespace alsa_util
  39. #endif // MEDIA_AUDIO_ALSA_ALSA_UTIL_H_