hardware/libaudio
修订版 | 8707e3532d6c5250d45a362048ea641314481efe (tree) |
---|---|
时间 | 2015-07-15 20:28:20 |
作者 | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
audio_hw: fallback to sampling rates 44100 if possible
@@ -188,6 +188,19 @@ static int select_card(int d) | ||
188 | 188 | return -1; |
189 | 189 | } |
190 | 190 | |
191 | +struct pcm *my_pcm_open(unsigned int card, unsigned int device, unsigned int flags, struct pcm_config *config) | |
192 | +{ | |
193 | + struct pcm *pcm = pcm_open(card, device, flags, config); | |
194 | + if (pcm && !pcm_is_ready(pcm)) { | |
195 | + ALOGE("my_pcm_open(%d) failed: %s", flags, pcm_get_error(pcm)); | |
196 | + pcm_close(pcm); | |
197 | + ALOGI("my_pcm_open: re-try 44100 on card %d", card); | |
198 | + config->rate = 44100; | |
199 | + pcm = pcm_open(card, device, flags, config); | |
200 | + } | |
201 | + return pcm; | |
202 | +} | |
203 | + | |
191 | 204 | static void select_devices(struct audio_device *adev) |
192 | 205 | { |
193 | 206 | int headphone_on; |
@@ -308,7 +321,7 @@ static int start_output_stream(struct stream_out *out) | ||
308 | 321 | if (ret < 0) { |
309 | 322 | return -ENODEV; |
310 | 323 | } |
311 | - out->pcm = pcm_open(ret, device, PCM_OUT | PCM_NORESTART, out->pcm_config); | |
324 | + out->pcm = my_pcm_open(ret, device, PCM_OUT | PCM_NORESTART, out->pcm_config); | |
312 | 325 | |
313 | 326 | if (out->pcm && !pcm_is_ready(out->pcm)) { |
314 | 327 | ALOGE("pcm_open(out) failed: %s", pcm_get_error(out->pcm)); |
@@ -380,7 +393,7 @@ static int start_input_stream(struct stream_in *in) | ||
380 | 393 | if (ret < 0) { |
381 | 394 | return -ENODEV; |
382 | 395 | } |
383 | - in->pcm = pcm_open(ret, device, PCM_IN, in->pcm_config); | |
396 | + in->pcm = my_pcm_open(ret, device, PCM_IN, in->pcm_config); | |
384 | 397 | |
385 | 398 | if (in->pcm && !pcm_is_ready(in->pcm)) { |
386 | 399 | ALOGE("pcm_open(in) failed: %s", pcm_get_error(in->pcm)); |