diff options
author | Chih-Wei Huang <cwhuang@linux.org.tw> | 2015-07-15 19:28:20 +0800 |
---|---|---|
committer | Chih-Wei Huang <cwhuang@linux.org.tw> | 2015-07-15 19:28:20 +0800 |
commit | 8707e3532d6c5250d45a362048ea641314481efe (patch) | |
tree | d00191a9e12904b0db74c86e4dce90f13de33593 | |
parent | 5ead7ae2b30990fbcca1672ec7d77c2117720190 (diff) | |
download | platform_hardware_libaudio-kitkat-x86.tar.gz platform_hardware_libaudio-kitkat-x86.tar.bz2 platform_hardware_libaudio-kitkat-x86.zip |
audio_hw: fallback to sampling rates 44100 if possibleandroid-x86-4.4-r3kitkat-x86
-rw-r--r-- | audio_hw.c | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -188,6 +188,19 @@ static int select_card(int d) return -1; } +struct pcm *my_pcm_open(unsigned int card, unsigned int device, unsigned int flags, struct pcm_config *config) +{ + struct pcm *pcm = pcm_open(card, device, flags, config); + if (pcm && !pcm_is_ready(pcm)) { + ALOGE("my_pcm_open(%d) failed: %s", flags, pcm_get_error(pcm)); + pcm_close(pcm); + ALOGI("my_pcm_open: re-try 44100 on card %d", card); + config->rate = 44100; + pcm = pcm_open(card, device, flags, config); + } + return pcm; +} + static void select_devices(struct audio_device *adev) { int headphone_on; @@ -308,7 +321,7 @@ static int start_output_stream(struct stream_out *out) if (ret < 0) { return -ENODEV; } - out->pcm = pcm_open(ret, device, PCM_OUT | PCM_NORESTART, out->pcm_config); + out->pcm = my_pcm_open(ret, device, PCM_OUT | PCM_NORESTART, out->pcm_config); if (out->pcm && !pcm_is_ready(out->pcm)) { ALOGE("pcm_open(out) failed: %s", pcm_get_error(out->pcm)); @@ -380,7 +393,7 @@ static int start_input_stream(struct stream_in *in) if (ret < 0) { return -ENODEV; } - in->pcm = pcm_open(ret, device, PCM_IN, in->pcm_config); + in->pcm = my_pcm_open(ret, device, PCM_IN, in->pcm_config); if (in->pcm && !pcm_is_ready(in->pcm)) { ALOGE("pcm_open(in) failed: %s", pcm_get_error(in->pcm)); |