• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

hardware/libaudio


Commit MetaInfo

Revisioncdbc332ddb87cbf5f02cf5a4d2754f0cec18680c (tree)
Zeit2015-10-07 00:15:21
AutorChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

fallback to sampling rates 44100 if possible

Ändern Zusammenfassung

Diff

--- a/audio_hw.c
+++ b/audio_hw.c
@@ -188,6 +188,19 @@ static int select_card(int d)
188188 return -1;
189189 }
190190
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+
191204 static void select_devices(struct audio_device *adev)
192205 {
193206 int headphone_on;
@@ -308,7 +321,7 @@ static int start_output_stream(struct stream_out *out)
308321 if (ret < 0) {
309322 return -ENODEV;
310323 }
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);
312325
313326 if (out->pcm && !pcm_is_ready(out->pcm)) {
314327 ALOGE("pcm_open(out) failed: %s", pcm_get_error(out->pcm));
@@ -380,7 +393,7 @@ static int start_input_stream(struct stream_in *in)
380393 if (ret < 0) {
381394 return -ENODEV;
382395 }
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);
384397
385398 if (in->pcm && !pcm_is_ready(in->pcm)) {
386399 ALOGE("pcm_open(in) failed: %s", pcm_get_error(in->pcm));
@@ -729,7 +742,7 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer,
729742 break;
730743 total_sleep_time_us += sleep_time_us;
731744 if (total_sleep_time_us > MAX_WRITE_SLEEP_US) {
732- ALOGW("out_write() limiting sleep time %d to %d",
745+ ALOGV("out_write() limiting sleep time %d to %d",
733746 total_sleep_time_us, MAX_WRITE_SLEEP_US);
734747 sleep_time_us = MAX_WRITE_SLEEP_US -
735748 (total_sleep_time_us - sleep_time_us);
@@ -769,6 +782,7 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer,
769782 if (ret == -EPIPE) {
770783 /* In case of underrun, don't sleep since we want to catch up asap */
771784 pthread_mutex_unlock(&out->lock);
785+ ALOGW("out_write underrun: %d", ret);
772786 return ret;
773787 }
774788
@@ -776,6 +790,7 @@ exit:
776790 pthread_mutex_unlock(&out->lock);
777791
778792 if (ret != 0) {
793+ ALOGW("out_write error: %d, sleeping...", ret);
779794 usleep(bytes * 1000000 / audio_stream_frame_size(&stream->common) /
780795 out_get_sample_rate(&stream->common));
781796 }