The attached debdiff is arch-aware and only adds ALSA support on a linux
environment.
The ALSA interface (audio/linux_sound.cc) has been patched to use
snd_pcm_set_params() instead of hwparams.
This has been tested on my launchpad ppa (
https://launchpad.net/~zeehio/+archive/ppa/+packages) and it works.

If there is anything I can do to push this patch, I am willing to help.

Regards,

Sergio
diff -u speech-tools-2.1~release/debian/rules speech-tools-2.1~release/debian/rules
--- speech-tools-2.1~release/debian/rules
+++ speech-tools-2.1~release/debian/rules
@@ -36,6 +36,13 @@
 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
 	cp -f /usr/share/misc/config.guess config.guess
 endif
+ifeq ($(DEB_HOST_ARCH_OS),linux)
+	echo "Enabling native ALSA support"
+	echo "LINUXAUDIO = alsa" >> config/config
+else
+	echo "ALSA support disabled"
+	echo "LINUXAUDIO = none" >> config/config
+endif
 	$(MAKE) PROJECT_VERSION=$(shell dpkg-parsechangelog|grep "Version:"|sed 's/^.*://;s/~.*$$//') PROJECT_MAJOR_VERSION=$(MAJORVER)
 	touch $@
 
diff -u speech-tools-2.1~release/debian/changelog speech-tools-2.1~release/debian/changelog
--- speech-tools-2.1~release/debian/changelog
+++ speech-tools-2.1~release/debian/changelog
@@ -1,3 +1,33 @@
+speech-tools (1:2.1~release-3) unstable; urgency=low
+
+  * Enable native ALSA support for Linux arch.
+  * Fixed audio/linux_sound.cc applying patch from
+    https://lists.berlios.de/pipermail/festlang-talk/2010-August/002425.html
+
+ -- Sergio Oller <sergiol...@gmail.com>  Wed, 24 Aug 2011 11:04:52 +0200
+
 speech-tools (1:2.1~release-2) unstable; urgency=low
 
   * Make libestools2.1-dev provide libestools2.0-dev, so that binNMUs can
diff -u speech-tools-2.1~release/debian/control speech-tools-2.1~release/debian/control
--- speech-tools-2.1~release/debian/control
+++ speech-tools-2.1~release/debian/control
@@ -6,6 +6,7 @@
 Build-Depends: debhelper (>= 5),
                autotools-dev,
                gawk | awk,
+               libasound2-dev [!kfreebsd-i386 !kfreebsd-amd64 !hurd-i386],
                libesd0-dev,
                libncurses5-dev,
                quilt (>= 0.40)
@@ -32,6 +33,7 @@
 Section: libdevel
 Depends: ${misc:Depends},
          libc6-dev,
+         libasound2-dev [!kfreebsd-i386 !kfreebsd-amd64 !hurd-i386],
          libesd0-dev,
          libestools2.1 (= ${binary:Version}),
          libncurses5-dev
diff -u speech-tools-2.1~release/debian/patches/series speech-tools-2.1~release/debian/patches/series
--- speech-tools-2.1~release/debian/patches/series
+++ speech-tools-2.1~release/debian/patches/series
@@ -1,6 +1,7 @@
 audio_esd.cc.diff
 audio_gen_audio.cc.diff
 audio_nas.cc.diff
+audio_linux_sound.cc.diff
 config_compilers_egcs.mak.diff
 config_compilers_gcc28.mak.diff
 config_compilers_gcc295.mak.diff
only in patch2:
unchanged:
--- speech-tools-2.1~release.orig/debian/patches/audio_linux_sound.cc.diff
+++ speech-tools-2.1~release/debian/patches/audio_linux_sound.cc.diff
@@ -0,0 +1,105 @@
+Index: speech-tools-2.1~release/audio/linux_sound.cc
+===================================================================
+--- speech-tools-2.1~release.orig/audio/linux_sound.cc	2011-08-23 21:30:32.171790493 +0200
++++ speech-tools-2.1~release/audio/linux_sound.cc	2011-08-23 21:20:47.000000000 +0200
+@@ -469,19 +469,14 @@
+ cst_audiodev *audio_open_alsa(int sps, int channels, cst_audiofmt fmt)
+ {
+   cst_audiodev *ad;
+-  unsigned 	int real_rate;
+   int err;
+ 
+   /* alsa specific stuff */
+   snd_pcm_t *pcm_handle;          
+   snd_pcm_stream_t stream = SND_PCM_STREAM_PLAYBACK;
+-  snd_pcm_hw_params_t *hwparams;
+   snd_pcm_format_t format;
+   snd_pcm_access_t access = SND_PCM_ACCESS_RW_INTERLEAVED;
+ 
+-  /* Allocate the snd_pcm_hw_params_t structure on the stack. */
+-  snd_pcm_hw_params_alloca(&hwparams);
+-
+   /* Open pcm device */
+   err = snd_pcm_open(&pcm_handle, pcm_dev_name, stream, 0);
+   if (err < 0) 
+@@ -491,24 +486,6 @@
+       return NULL;
+   }
+ 
+-  /* Init hwparams with full configuration space */
+-  err = snd_pcm_hw_params_any(pcm_handle, hwparams);
+-  if (err < 0) 
+-  {
+-	snd_pcm_close(pcm_handle);
+-	EST_warning("audio_open_alsa: failed to get hardware parameters from audio device. %s\n", snd_strerror(err));
+-	return NULL;
+-  }
+-
+-  /* Set access mode */
+-  err = snd_pcm_hw_params_set_access(pcm_handle, hwparams, access);
+-  if (err < 0) 
+-  {
+-	snd_pcm_close(pcm_handle);
+-	EST_warning("audio_open_alsa: failed to set access mode. %s.\n", snd_strerror(err));
+-	return NULL;
+-  }
+-
+   /* Determine matching alsa sample format */
+   /* This could be implemented in a more */
+   /* flexible way (byte order conversion). */
+@@ -530,50 +507,19 @@
+ 	snd_pcm_close(pcm_handle);
+ 	EST_warning("audio_open_alsa: failed to find suitable format.\n");
+ 	return NULL;
+-	break;
+-  }
+-
+-  /* Set samble format */
+-  err = snd_pcm_hw_params_set_format(pcm_handle, hwparams, format);
+-  if (err <0) 
+-  {
+-	snd_pcm_close(pcm_handle);
+-	EST_warning("audio_open_alsa: failed to set format. %s.\n", snd_strerror(err));
+-	return NULL;
+   }
+ 
+-  /* Set sample rate near the disired rate */
+-  real_rate = sps;
+-  err = snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &real_rate, 0);
+-  if (err < 0)   
+-  {
+-	snd_pcm_close(pcm_handle);
+-	EST_warning("audio_open_alsa: failed to set sample rate near %d. %s.\n", sps, snd_strerror(err));
+-	return NULL;
+-  }
+-
+-  /* Set number of channels */
+-  assert(channels >0);
+-  err = snd_pcm_hw_params_set_channels(pcm_handle, hwparams, channels);
+-  if (err < 0) 
+-  {
++  if ((err = snd_pcm_set_params(
++       pcm_handle,format,access,channels,sps,1,50000)) < 0) {
++       EST_warning("audio_open_alsa: et params error: %s\n", snd_strerror(err));
+ 	snd_pcm_close(pcm_handle);
+-	EST_warning("audio_open_alsa: failed to set number of channels to %d. %s.\n", channels, snd_strerror(err));
+ 	return NULL;
+   }
+-
+-  /* Commit hardware parameters */
+-  err = snd_pcm_hw_params(pcm_handle, hwparams);
+-  if (err < 0) 
+-  {
+-	snd_pcm_close(pcm_handle);
+-	EST_warning("audio_open_alsa: failed to set hw parameters. %s.\n", snd_strerror(err));
+-	return NULL;
+-  }
+-
++/********************************************************************/
+   /* Make sure the device is ready to accept data */
+   assert(snd_pcm_state(pcm_handle) == SND_PCM_STATE_PREPARED);
+ 
++
+   /* Write hardware parameters to flite audio device data structure */
+   ad = walloc(cst_audiodev, 1);
+   assert(ad != NULL);

Reply via email to