OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/audio/linux/alsa_wrapper.h" | 5 #include "media/audio/linux/alsa_wrapper.h" |
6 | 6 |
7 #include <alsa/asoundlib.h> | 7 #include <alsa/asoundlib.h> |
8 | 8 |
9 AlsaWrapper::AlsaWrapper() { | 9 AlsaWrapper::AlsaWrapper() { |
10 } | 10 } |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 err = snd_pcm_hw_params_set_buffer_time_near(handle, hw_params, | 121 err = snd_pcm_hw_params_set_buffer_time_near(handle, hw_params, |
122 &buffer_time, 0); | 122 &buffer_time, 0); |
123 return err; | 123 return err; |
124 } | 124 } |
125 | 125 |
126 int AlsaWrapper::PcmSetParams(snd_pcm_t* handle, snd_pcm_format_t format, | 126 int AlsaWrapper::PcmSetParams(snd_pcm_t* handle, snd_pcm_format_t format, |
127 snd_pcm_access_t access, unsigned int channels, | 127 snd_pcm_access_t access, unsigned int channels, |
128 unsigned int rate, int soft_resample, | 128 unsigned int rate, int soft_resample, |
129 unsigned int latency) { | 129 unsigned int latency) { |
130 int err = 0; | 130 int err = 0; |
131 snd_pcm_hw_params_t *hw_params; | 131 snd_pcm_hw_params_t* hw_params; |
132 if ((err = snd_pcm_hw_params_malloc(&hw_params)) < 0) | 132 if ((err = snd_pcm_hw_params_malloc(&hw_params)) < 0) |
133 return err; | 133 return err; |
134 | 134 |
135 if ((err = ConfigureHwParams(handle, hw_params, format, access, channels, | 135 if ((err = ConfigureHwParams(handle, hw_params, format, access, channels, |
136 rate, soft_resample, latency)) >= 0) { | 136 rate, soft_resample, latency)) >= 0) { |
137 err = snd_pcm_hw_params(handle, hw_params); | 137 err = snd_pcm_hw_params(handle, hw_params); |
138 } | 138 } |
139 | 139 |
140 snd_pcm_hw_params_free(hw_params); | 140 snd_pcm_hw_params_free(hw_params); |
141 return err; | 141 return err; |
(...skipping 13 matching lines...) Expand all Loading... |
155 } | 155 } |
156 | 156 |
157 const char* AlsaWrapper::StrError(int errnum) { | 157 const char* AlsaWrapper::StrError(int errnum) { |
158 return snd_strerror(errnum); | 158 return snd_strerror(errnum); |
159 } | 159 } |
160 | 160 |
161 int AlsaWrapper::PcmStart(snd_pcm_t* handle) { | 161 int AlsaWrapper::PcmStart(snd_pcm_t* handle) { |
162 return snd_pcm_start(handle); | 162 return snd_pcm_start(handle); |
163 } | 163 } |
164 | 164 |
| 165 int AlsaWrapper::MixerOpen(snd_mixer_t** mixer, int mode) { |
| 166 return snd_mixer_open(mixer, mode); |
| 167 } |
| 168 |
| 169 int AlsaWrapper::MixerAttach(snd_mixer_t* mixer, const char* name) { |
| 170 return snd_mixer_attach(mixer, name); |
| 171 } |
| 172 |
| 173 int AlsaWrapper::MixerElementRegister(snd_mixer_t* mixer, |
| 174 struct snd_mixer_selem_regopt* options, |
| 175 snd_mixer_class_t** classp) { |
| 176 return snd_mixer_selem_register(mixer, options, classp); |
| 177 } |
| 178 |
| 179 void AlsaWrapper::MixerFree(snd_mixer_t* mixer) { |
| 180 snd_mixer_free(mixer); |
| 181 } |
| 182 |
| 183 int AlsaWrapper::MixerDetach(snd_mixer_t* mixer, const char* name) { |
| 184 return snd_mixer_detach(mixer, name); |
| 185 } |
| 186 |
| 187 int AlsaWrapper::MixerClose(snd_mixer_t* mixer) { |
| 188 return snd_mixer_close(mixer); |
| 189 } |
| 190 |
| 191 int AlsaWrapper::MixerLoad(snd_mixer_t* mixer) { |
| 192 return snd_mixer_load(mixer); |
| 193 } |
| 194 |
| 195 snd_mixer_elem_t* AlsaWrapper::MixerFirstElem(snd_mixer_t* mixer) { |
| 196 return snd_mixer_first_elem(mixer); |
| 197 } |
| 198 |
| 199 snd_mixer_elem_t* AlsaWrapper::MixerNextElem(snd_mixer_elem_t* elem) { |
| 200 return snd_mixer_elem_next(elem); |
| 201 } |
| 202 |
| 203 int AlsaWrapper::MixerSelemIsActive(snd_mixer_elem_t* elem) { |
| 204 return snd_mixer_selem_is_active(elem); |
| 205 } |
| 206 |
| 207 const char* AlsaWrapper::MixerSelemName(snd_mixer_elem_t* elem) { |
| 208 return snd_mixer_selem_get_name(elem); |
| 209 } |
| 210 |
| 211 int AlsaWrapper::MixerSelemSetCaptureVolumeAll( |
| 212 snd_mixer_elem_t* elem, long value) { |
| 213 return snd_mixer_selem_set_capture_volume_all(elem, value); |
| 214 } |
| 215 |
| 216 int AlsaWrapper::MixerSelemGetCaptureVolume( |
| 217 snd_mixer_elem_t* elem, snd_mixer_selem_channel_id_t channel, long* value) { |
| 218 return snd_mixer_selem_get_capture_volume(elem, channel, value); |
| 219 } |
| 220 |
| 221 int AlsaWrapper::MixerSelemHasCaptureVolume(snd_mixer_elem_t* elem) { |
| 222 return snd_mixer_selem_has_capture_volume(elem); |
| 223 } |
| 224 |
| 225 int AlsaWrapper::MixerSelemGetCaptureVolumeRange(snd_mixer_elem_t* elem, |
| 226 long* min, long* max) { |
| 227 return snd_mixer_selem_get_capture_volume_range(elem, min, max); |
| 228 } |
OLD | NEW |