Sophie

Sophie

distrib > Mageia > 6 > armv7hl > media > core-updates-src > by-pkgid > 50f160eec42a116e37bc13a0420dcbf7 > files > 11

festival-2.1-10.1.mga6.src.rpm

--- festival/speech_tools/audio/linux_sound.cc.orig	2013-07-02 02:45:02.953142985 +0200
+++ festival/speech_tools/audio/linux_sound.cc	2013-07-02 02:48:05.249370165 +0200
@@ -544,7 +544,14 @@
 
   /* Set sample rate near the disired rate */
   real_rate = sps;
-  err = snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &real_rate, 0);
+  /* For some reason, ALSA sometimes sets a rate way too high when using
+   * snd_pcm_hw_params_set_rate_near(), so try setting the exact rate first
+   * before falling back to a nearby one */
+  err = snd_pcm_hw_params_set_rate(pcm_handle, hwparams, real_rate, 0);
+  if (err < 0)   
+  {
+	err = snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &real_rate, 0);
+  }
   if (err < 0)   
   {
 	snd_pcm_close(pcm_handle);