summaryrefslogtreecommitdiff
path: root/chromium/media/audio/alsa/alsa_util.h
blob: 47b5d1b6594418dbaa5abb1027bec1d2fd5f96d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_AUDIO_ALSA_ALSA_UTIL_H_
#define MEDIA_AUDIO_ALSA_ALSA_UTIL_H_

#include <alsa/asoundlib.h>
#include <string>

#include "media/base/media_export.h"

namespace media {
class AlsaWrapper;
}

namespace alsa_util {

// When opening ALSA devices, |period_us| is the size of a packet and
// |buffer_us| is the size of the ring buffer, which consists of multiple
// packets. In capture devices, the latency relies more on |period_us|, and thus
// one may require more details upon the value implicitly set by ALSA.
MEDIA_EXPORT snd_pcm_t* OpenCaptureDevice(media::AlsaWrapper* wrapper,
                                          const char* device_name,
                                          int channels,
                                          int sample_rate,
                                          snd_pcm_format_t pcm_format,
                                          int buffer_us,
                                          int period_us);

snd_pcm_t* OpenPlaybackDevice(media::AlsaWrapper* wrapper,
                              const char* device_name,
                              int channels,
                              int sample_rate,
                              snd_pcm_format_t pcm_format,
                              int buffer_us);

int CloseDevice(media::AlsaWrapper* wrapper, snd_pcm_t* handle);

snd_mixer_t* OpenMixer(media::AlsaWrapper* wrapper,
                       const std::string& device_name);

void CloseMixer(media::AlsaWrapper* wrapper,
                snd_mixer_t* mixer,
                const std::string& device_name);

snd_mixer_elem_t* LoadCaptureMixerElement(media::AlsaWrapper* wrapper,
                                          snd_mixer_t* mixer);

}  // namespace alsa_util

#endif  // MEDIA_AUDIO_ALSA_ALSA_UTIL_H_