• 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

Revision8707e3532d6c5250d45a362048ea641314481efe (tree)
Zeit2015-07-15 20:28:20
AutorChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

audio_hw: 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));