• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "media/audio/alsa/alsa_wrapper.h"
6 
7 #include <alsa/asoundlib.h>
8 
9 namespace media {
10 
AlsaWrapper()11 AlsaWrapper::AlsaWrapper() {
12 }
13 
~AlsaWrapper()14 AlsaWrapper::~AlsaWrapper() {
15 }
16 
PcmOpen(snd_pcm_t ** handle,const char * name,snd_pcm_stream_t stream,int mode)17 int AlsaWrapper::PcmOpen(snd_pcm_t** handle, const char* name,
18                          snd_pcm_stream_t stream, int mode) {
19   return snd_pcm_open(handle, name, stream, mode);
20 }
21 
DeviceNameHint(int card,const char * iface,void *** hints)22 int AlsaWrapper::DeviceNameHint(int card, const char* iface, void*** hints) {
23   return snd_device_name_hint(card, iface, hints);
24 }
25 
DeviceNameGetHint(const void * hint,const char * id)26 char* AlsaWrapper::DeviceNameGetHint(const void* hint, const char* id) {
27   return snd_device_name_get_hint(hint, id);
28 }
29 
DeviceNameFreeHint(void ** hints)30 int AlsaWrapper::DeviceNameFreeHint(void** hints) {
31   return snd_device_name_free_hint(hints);
32 }
33 
CardNext(int * rcard)34 int AlsaWrapper::CardNext(int* rcard) {
35   return snd_card_next(rcard);
36 }
37 
PcmClose(snd_pcm_t * handle)38 int AlsaWrapper::PcmClose(snd_pcm_t* handle) {
39   return snd_pcm_close(handle);
40 }
41 
PcmPrepare(snd_pcm_t * handle)42 int AlsaWrapper::PcmPrepare(snd_pcm_t* handle) {
43   return snd_pcm_prepare(handle);
44 }
45 
PcmDrop(snd_pcm_t * handle)46 int AlsaWrapper::PcmDrop(snd_pcm_t* handle) {
47   return snd_pcm_drop(handle);
48 }
49 
PcmDelay(snd_pcm_t * handle,snd_pcm_sframes_t * delay)50 int AlsaWrapper::PcmDelay(snd_pcm_t* handle, snd_pcm_sframes_t* delay) {
51   return snd_pcm_delay(handle, delay);
52 }
53 
PcmWritei(snd_pcm_t * handle,const void * buffer,snd_pcm_uframes_t size)54 snd_pcm_sframes_t AlsaWrapper::PcmWritei(snd_pcm_t* handle,
55                                          const void* buffer,
56                                          snd_pcm_uframes_t size) {
57   return snd_pcm_writei(handle, buffer, size);
58 }
59 
PcmReadi(snd_pcm_t * handle,void * buffer,snd_pcm_uframes_t size)60 snd_pcm_sframes_t AlsaWrapper::PcmReadi(snd_pcm_t* handle,
61                                         void* buffer,
62                                         snd_pcm_uframes_t size) {
63   return snd_pcm_readi(handle, buffer, size);
64 }
65 
PcmRecover(snd_pcm_t * handle,int err,int silent)66 int AlsaWrapper::PcmRecover(snd_pcm_t* handle, int err, int silent) {
67   return snd_pcm_recover(handle, err, silent);
68 }
69 
PcmName(snd_pcm_t * handle)70 const char* AlsaWrapper::PcmName(snd_pcm_t* handle) {
71   return snd_pcm_name(handle);
72 }
73 
PcmSetParams(snd_pcm_t * handle,snd_pcm_format_t format,snd_pcm_access_t access,unsigned int channels,unsigned int rate,int soft_resample,unsigned int latency)74 int AlsaWrapper::PcmSetParams(snd_pcm_t* handle, snd_pcm_format_t format,
75                               snd_pcm_access_t access, unsigned int channels,
76                               unsigned int rate, int soft_resample,
77                               unsigned int latency) {
78   return snd_pcm_set_params(handle,
79                             format,
80                             access,
81                             channels,
82                             rate,
83                             soft_resample,
84                             latency);
85 }
86 
PcmGetParams(snd_pcm_t * handle,snd_pcm_uframes_t * buffer_size,snd_pcm_uframes_t * period_size)87 int AlsaWrapper::PcmGetParams(snd_pcm_t* handle, snd_pcm_uframes_t* buffer_size,
88                               snd_pcm_uframes_t* period_size) {
89   return snd_pcm_get_params(handle, buffer_size, period_size);
90 }
91 
PcmAvailUpdate(snd_pcm_t * handle)92 snd_pcm_sframes_t AlsaWrapper::PcmAvailUpdate(snd_pcm_t* handle) {
93   return snd_pcm_avail_update(handle);
94 }
95 
PcmState(snd_pcm_t * handle)96 snd_pcm_state_t AlsaWrapper::PcmState(snd_pcm_t* handle) {
97   return snd_pcm_state(handle);
98 }
99 
StrError(int errnum)100 const char* AlsaWrapper::StrError(int errnum) {
101   return snd_strerror(errnum);
102 }
103 
PcmStart(snd_pcm_t * handle)104 int AlsaWrapper::PcmStart(snd_pcm_t* handle) {
105   return snd_pcm_start(handle);
106 }
107 
MixerOpen(snd_mixer_t ** mixer,int mode)108 int AlsaWrapper::MixerOpen(snd_mixer_t** mixer, int mode) {
109   return snd_mixer_open(mixer, mode);
110 }
111 
MixerAttach(snd_mixer_t * mixer,const char * name)112 int AlsaWrapper::MixerAttach(snd_mixer_t* mixer, const char* name) {
113   return snd_mixer_attach(mixer, name);
114 }
115 
MixerElementRegister(snd_mixer_t * mixer,struct snd_mixer_selem_regopt * options,snd_mixer_class_t ** classp)116 int AlsaWrapper::MixerElementRegister(snd_mixer_t* mixer,
117                                       struct snd_mixer_selem_regopt* options,
118                                       snd_mixer_class_t** classp) {
119   return snd_mixer_selem_register(mixer, options, classp);
120 }
121 
MixerFree(snd_mixer_t * mixer)122 void AlsaWrapper::MixerFree(snd_mixer_t* mixer) {
123   snd_mixer_free(mixer);
124 }
125 
MixerDetach(snd_mixer_t * mixer,const char * name)126 int AlsaWrapper::MixerDetach(snd_mixer_t* mixer, const char* name) {
127   return snd_mixer_detach(mixer, name);
128 }
129 
MixerClose(snd_mixer_t * mixer)130 int AlsaWrapper::MixerClose(snd_mixer_t* mixer) {
131   return snd_mixer_close(mixer);
132 }
133 
MixerLoad(snd_mixer_t * mixer)134 int AlsaWrapper::MixerLoad(snd_mixer_t* mixer) {
135   return snd_mixer_load(mixer);
136 }
137 
MixerFirstElem(snd_mixer_t * mixer)138 snd_mixer_elem_t* AlsaWrapper::MixerFirstElem(snd_mixer_t* mixer) {
139   return snd_mixer_first_elem(mixer);
140 }
141 
MixerNextElem(snd_mixer_elem_t * elem)142 snd_mixer_elem_t* AlsaWrapper::MixerNextElem(snd_mixer_elem_t* elem) {
143   return snd_mixer_elem_next(elem);
144 }
145 
MixerSelemIsActive(snd_mixer_elem_t * elem)146 int AlsaWrapper::MixerSelemIsActive(snd_mixer_elem_t* elem) {
147   return snd_mixer_selem_is_active(elem);
148 }
149 
MixerSelemName(snd_mixer_elem_t * elem)150 const char* AlsaWrapper::MixerSelemName(snd_mixer_elem_t* elem) {
151   return snd_mixer_selem_get_name(elem);
152 }
153 
MixerSelemSetCaptureVolumeAll(snd_mixer_elem_t * elem,long value)154 int AlsaWrapper::MixerSelemSetCaptureVolumeAll(
155     snd_mixer_elem_t* elem, long value) {
156   return snd_mixer_selem_set_capture_volume_all(elem, value);
157 }
158 
MixerSelemGetCaptureVolume(snd_mixer_elem_t * elem,snd_mixer_selem_channel_id_t channel,long * value)159 int AlsaWrapper::MixerSelemGetCaptureVolume(
160     snd_mixer_elem_t* elem, snd_mixer_selem_channel_id_t channel, long* value) {
161   return snd_mixer_selem_get_capture_volume(elem, channel, value);
162 }
163 
MixerSelemHasCaptureVolume(snd_mixer_elem_t * elem)164 int AlsaWrapper::MixerSelemHasCaptureVolume(snd_mixer_elem_t* elem) {
165   return snd_mixer_selem_has_capture_volume(elem);
166 }
167 
MixerSelemGetCaptureVolumeRange(snd_mixer_elem_t * elem,long * min,long * max)168 int AlsaWrapper::MixerSelemGetCaptureVolumeRange(snd_mixer_elem_t* elem,
169                                                  long* min, long* max) {
170   return snd_mixer_selem_get_capture_volume_range(elem, min, max);
171 }
172 
173 }  // namespace media
174