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.
5 #include "media/audio/alsa/alsa_wrapper.h"
10 AlsaWrapper::AlsaWrapper() {
13 AlsaWrapper::~AlsaWrapper() {
16 int AlsaWrapper::PcmOpen(snd_pcm_t
** handle
, const char* name
,
17 snd_pcm_stream_t stream
, int mode
) {
18 return snd_pcm_open(handle
, name
, stream
, mode
);
21 int AlsaWrapper::DeviceNameHint(int card
, const char* iface
, void*** hints
) {
22 return snd_device_name_hint(card
, iface
, hints
);
25 char* AlsaWrapper::DeviceNameGetHint(const void* hint
, const char* id
) {
26 return snd_device_name_get_hint(hint
, id
);
29 int AlsaWrapper::DeviceNameFreeHint(void** hints
) {
30 return snd_device_name_free_hint(hints
);
33 int AlsaWrapper::CardNext(int* rcard
) {
34 return snd_card_next(rcard
);
37 int AlsaWrapper::PcmClose(snd_pcm_t
* handle
) {
38 return snd_pcm_close(handle
);
41 int AlsaWrapper::PcmPrepare(snd_pcm_t
* handle
) {
42 return snd_pcm_prepare(handle
);
45 int AlsaWrapper::PcmDrop(snd_pcm_t
* handle
) {
46 return snd_pcm_drop(handle
);
49 int AlsaWrapper::PcmDelay(snd_pcm_t
* handle
, snd_pcm_sframes_t
* delay
) {
50 return snd_pcm_delay(handle
, delay
);
53 snd_pcm_sframes_t
AlsaWrapper::PcmWritei(snd_pcm_t
* handle
,
55 snd_pcm_uframes_t size
) {
56 return snd_pcm_writei(handle
, buffer
, size
);
59 snd_pcm_sframes_t
AlsaWrapper::PcmReadi(snd_pcm_t
* handle
,
61 snd_pcm_uframes_t size
) {
62 return snd_pcm_readi(handle
, buffer
, size
);
65 int AlsaWrapper::PcmRecover(snd_pcm_t
* handle
, int err
, int silent
) {
66 return snd_pcm_recover(handle
, err
, silent
);
69 const char* AlsaWrapper::PcmName(snd_pcm_t
* handle
) {
70 return snd_pcm_name(handle
);
73 int AlsaWrapper::PcmSetParams(snd_pcm_t
* handle
, snd_pcm_format_t format
,
74 snd_pcm_access_t access
, unsigned int channels
,
75 unsigned int rate
, int soft_resample
,
76 unsigned int latency
) {
77 return snd_pcm_set_params(handle
,
86 int AlsaWrapper::PcmGetParams(snd_pcm_t
* handle
, snd_pcm_uframes_t
* buffer_size
,
87 snd_pcm_uframes_t
* period_size
) {
88 return snd_pcm_get_params(handle
, buffer_size
, period_size
);
91 snd_pcm_sframes_t
AlsaWrapper::PcmAvailUpdate(snd_pcm_t
* handle
) {
92 return snd_pcm_avail_update(handle
);
95 snd_pcm_state_t
AlsaWrapper::PcmState(snd_pcm_t
* handle
) {
96 return snd_pcm_state(handle
);
99 const char* AlsaWrapper::StrError(int errnum
) {
100 return snd_strerror(errnum
);
103 int AlsaWrapper::PcmStart(snd_pcm_t
* handle
) {
104 return snd_pcm_start(handle
);
107 int AlsaWrapper::MixerOpen(snd_mixer_t
** mixer
, int mode
) {
108 return snd_mixer_open(mixer
, mode
);
111 int AlsaWrapper::MixerAttach(snd_mixer_t
* mixer
, const char* name
) {
112 return snd_mixer_attach(mixer
, name
);
115 int AlsaWrapper::MixerElementRegister(snd_mixer_t
* mixer
,
116 struct snd_mixer_selem_regopt
* options
,
117 snd_mixer_class_t
** classp
) {
118 return snd_mixer_selem_register(mixer
, options
, classp
);
121 void AlsaWrapper::MixerFree(snd_mixer_t
* mixer
) {
122 snd_mixer_free(mixer
);
125 int AlsaWrapper::MixerDetach(snd_mixer_t
* mixer
, const char* name
) {
126 return snd_mixer_detach(mixer
, name
);
129 int AlsaWrapper::MixerClose(snd_mixer_t
* mixer
) {
130 return snd_mixer_close(mixer
);
133 int AlsaWrapper::MixerLoad(snd_mixer_t
* mixer
) {
134 return snd_mixer_load(mixer
);
137 snd_mixer_elem_t
* AlsaWrapper::MixerFirstElem(snd_mixer_t
* mixer
) {
138 return snd_mixer_first_elem(mixer
);
141 snd_mixer_elem_t
* AlsaWrapper::MixerNextElem(snd_mixer_elem_t
* elem
) {
142 return snd_mixer_elem_next(elem
);
145 int AlsaWrapper::MixerSelemIsActive(snd_mixer_elem_t
* elem
) {
146 return snd_mixer_selem_is_active(elem
);
149 const char* AlsaWrapper::MixerSelemName(snd_mixer_elem_t
* elem
) {
150 return snd_mixer_selem_get_name(elem
);
153 int AlsaWrapper::MixerSelemSetCaptureVolumeAll(
154 snd_mixer_elem_t
* elem
, long value
) {
155 return snd_mixer_selem_set_capture_volume_all(elem
, value
);
158 int AlsaWrapper::MixerSelemGetCaptureVolume(
159 snd_mixer_elem_t
* elem
, snd_mixer_selem_channel_id_t channel
, long* value
) {
160 return snd_mixer_selem_get_capture_volume(elem
, channel
, value
);
163 int AlsaWrapper::MixerSelemHasCaptureVolume(snd_mixer_elem_t
* elem
) {
164 return snd_mixer_selem_has_capture_volume(elem
);
167 int AlsaWrapper::MixerSelemGetCaptureVolumeRange(snd_mixer_elem_t
* elem
,
168 long* min
, long* max
) {
169 return snd_mixer_selem_get_capture_volume_range(elem
, min
, max
);