Sophie

Sophie

distrib > Mageia > 5 > i586 > by-pkgid > 58d9c6b7b29d9bf576a984938621beb0 > files > 10

festival-2.1-9.mga5.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);