[packages/speech_tools] Native pulseaudio support from fedora

baggins baggins at pld-linux.org
Tue Jul 17 22:20:26 CEST 2012


commit e58a297f024808c8236333a08bdcca1d756c87cb
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Tue Jul 17 21:50:46 2012 +0200

    Native pulseaudio support from fedora

 speech_tools-pulse.patch | 298 +++++++++++++++++++++++++++++++++++++++++++++++
 speech_tools.spec        |   5 +-
 2 files changed, 302 insertions(+), 1 deletion(-)
---
diff --git a/speech_tools-pulse.patch b/speech_tools-pulse.patch
new file mode 100644
index 0000000..0c37e93
--- /dev/null
+++ b/speech_tools-pulse.patch
@@ -0,0 +1,298 @@
+diff -up speech_tools/audio/audioP.h.pulse speech_tools/audio/audioP.h
+--- speech_tools/audio/audioP.h.pulse	2004-07-15 19:03:04.000000000 -0400
++++ speech_tools/audio/audioP.h	2009-09-29 02:05:53.353695375 -0400
+@@ -40,6 +40,7 @@
+ #define __AUDIOP_H__
+ 
+ int play_nas_wave(EST_Wave &inwave, EST_Option &al);
++int play_pulse_wave(EST_Wave &inwave, EST_Option &al);
+ int play_esd_wave(EST_Wave &inwave, EST_Option &al);
+ int play_sun16_wave(EST_Wave &inwave, EST_Option &al);
+ int play_voxware_wave(EST_Wave &inwave, EST_Option &al);
+@@ -49,6 +50,7 @@ int play_irix_wave(EST_Wave &inwave, EST
+ int play_macosx_wave(EST_Wave &inwave, EST_Option &al);
+ 
+ int record_nas_wave(EST_Wave &inwave, EST_Option &al);
++int record_pulse_wave(EST_Wave &inwave, EST_Option &al);
+ int record_esd_wave(EST_Wave &inwave, EST_Option &al);
+ int record_sun16_wave(EST_Wave &inwave, EST_Option &al);
+ int record_voxware_wave(EST_Wave &inwave, EST_Option &al);
+diff -up speech_tools/audio/gen_audio.cc.pulse speech_tools/audio/gen_audio.cc
+--- speech_tools/audio/gen_audio.cc.pulse	2004-09-30 08:53:35.000000000 -0400
++++ speech_tools/audio/gen_audio.cc	2009-09-29 02:05:53.354687890 -0400
+@@ -89,6 +89,8 @@ int play_wave(EST_Wave &inwave, EST_Opti
+     {
+ 	if (nas_supported)
+ 	    protocol = "netaudio";  // the default protocol
++	else if (pulse_supported)
++	    protocol = "pulseaudio";
+ 	else if (esd_supported)
+ 	    protocol = "esdaudio";
+ 	else if (sun16_supported)
+@@ -111,6 +113,8 @@ int play_wave(EST_Wave &inwave, EST_Opti
+ 
+     if (upcase(protocol) == "NETAUDIO")
+ 	return play_nas_wave(*toplay,al);
++    else if (upcase(protocol) == "PULSEAUDIO")
++	return play_pulse_wave(*toplay,al);
+     else if (upcase(protocol) == "ESDAUDIO")
+ 	return play_esd_wave(*toplay,al);
+     else if (upcase(protocol) == "SUNAUDIO")
+@@ -246,6 +250,8 @@ EST_String options_supported_audio(void)
+ 	audios += " netaudio";
+     else if (esd_supported)
+ 	audios += " esdaudio";
++    if (pulse_supported)
++	audios += " pulseaudio";
+     if (sun16_supported)
+ 	audios += " sun16audio";
+     if (freebsd16_supported)
+@@ -286,8 +292,10 @@ int record_wave(EST_Wave &wave, EST_Opti
+     {
+ 	if (nas_supported)
+ 	    protocol = "netaudio";  // the default protocol
++	else if (pulse_supported)
++	    protocol = "pulseaudio";
+ 	else if (esd_supported)
+-	    protocol = "esdaudio";  // the default protocol
++	    protocol = "esdaudio";
+ 	else if (sun16_supported)
+ 	    protocol = "sun16audio";
+ 	else if (freebsd16_supported)
+@@ -306,6 +314,8 @@ int record_wave(EST_Wave &wave, EST_Opti
+ 
+     if (upcase(protocol) == "NETAUDIO")
+ 	return record_nas_wave(wave,al);
++    else if (upcase(protocol) == "PULSEAUDIO")
++	return record_pulse_wave(wave,al);
+     else if (upcase(protocol) == "ESDAUDIO")
+         return record_esd_wave(wave,al);
+     else if (upcase(protocol) == "SUN16AUDIO")
+diff -up speech_tools/audio/Makefile.pulse speech_tools/audio/Makefile
+--- speech_tools/audio/Makefile.pulse	2004-07-15 19:03:04.000000000 -0400
++++ speech_tools/audio/Makefile	2009-09-29 02:05:53.355692417 -0400
+@@ -44,7 +44,7 @@ LOCAL_DEFAULT_LIBRARY = estbase
+ H = audioP.h
+ CPPSRCS = gen_audio.cc nas.cc esd.cc sun16audio.cc voxware.cc  \
+           mplayer.cc win32audio.cc irixaudio.cc os2audio.cc \
+-          macosxaudio.cc linux_sound.cc
++          macosxaudio.cc linux_sound.cc pulseaudio.cc
+ 
+ SRCS = $(CPPSRCS)
+ OBJS = $(CPPSRCS:.cc=.o)
+diff -up /dev/null speech_tools/audio/pulseaudio.cc
+--- /dev/null	2009-09-29 00:23:01.118964058 -0400
++++ speech_tools/audio/pulseaudio.cc	2009-09-29 02:05:53.357688202 -0400
+@@ -0,0 +1,134 @@
++/*************************************************************************/
++/*                                                                       */
++/*                Centre for Speech Technology Research                  */
++/*                     University of Edinburgh, UK                       */
++/*                      Copyright (c) 1997,1998                          */
++/*                            Red Hat, Inc.                              */
++/*                         Copyright (c) 2008                            */
++/*                        All Rights Reserved.                           */
++/*                                                                       */
++/*  Permission is hereby granted, free of charge, to use and distribute  */
++/*  this software and its documentation without restriction, including   */
++/*  without limitation the rights to use, copy, modify, merge, publish,  */
++/*  distribute, sublicense, and/or sell copies of this work, and to      */
++/*  permit persons to whom this work is furnished to do so, subject to   */
++/*  the following conditions:                                            */
++/*   1. The code must retain the above copyright notice, this list of    */
++/*      conditions and the following disclaimer.                         */
++/*   2. Any modifications must be clearly marked as such.                */
++/*   3. Original authors' names are not deleted.                         */
++/*   4. The authors' names are not used to endorse or promote products   */
++/*      derived from this software without specific prior written        */
++/*      permission.                                                      */
++/*                                                                       */
++/*  THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK        */
++/*  DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING      */
++/*  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT   */
++/*  SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE     */
++/*  FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES    */
++/*  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN   */
++/*  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,          */
++/*  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF       */
++/*  THIS SOFTWARE.                                                       */
++/*                                                                       */
++/*************************************************************************/
++/*                Author :  Michal Schmidt                               */
++/*                Date   :  November 2008                                */
++/*-----------------------------------------------------------------------*/
++/*  Optional support for PulseAudio                                      */
++/*=======================================================================*/
++
++#include "EST_Wave.h"
++#include "EST_Option.h"
++#include "audioP.h"
++
++#ifdef SUPPORT_PULSE
++
++#include <pulse/simple.h>
++#include <pulse/error.h>
++
++int pulse_supported = TRUE;
++const static char *err_prefix = "Pulseaudio: ";
++
++static int transfer_pulse_wave(EST_Wave &inwave, EST_Option &al, int record)
++{
++    short *waveform;
++    int num_samples;
++    int err, pa_ret;
++    int ret = -1;
++    pa_simple *s = NULL;
++    pa_sample_spec ss;
++
++    ss.format   = PA_SAMPLE_S16NE;
++    ss.channels = 1;
++    ss.rate     = inwave.sample_rate();
++
++    waveform    = inwave.values().memory();
++    num_samples = inwave.num_samples();
++
++    s = pa_simple_new(NULL,           // Use the default server.
++	"Festival",                   // Our application's name.
++	record ? PA_STREAM_RECORD : PA_STREAM_PLAYBACK,
++	NULL,                         // Use the default device.
++	record ? "Record" : "Speech", // Description of our stream.
++	&ss,                // Our sample format.
++	NULL,               // Use default channel map
++	NULL,               // Use default buffering attributes.
++	&err);
++
++    if (!s) {
++	cerr << err_prefix << pa_strerror(err) << endl;
++	goto finish;
++    }
++
++    pa_ret = record ?
++	pa_simple_read (s, waveform, num_samples*sizeof(short), &err) :
++	pa_simple_write(s, waveform, num_samples*sizeof(short), &err);
++
++    if (pa_ret < 0) {
++	cerr << err_prefix << pa_strerror(err) << endl;
++	goto finish;
++    }
++
++    if (!record && pa_simple_drain(s, &err) < 0) {
++	cerr << err_prefix << pa_strerror(err) << endl;
++	goto finish;
++    }
++
++    ret = 1;
++finish:
++    if (s)
++	pa_simple_free(s);
++    return ret;
++}
++
++int play_pulse_wave(EST_Wave &inwave, EST_Option &al)
++{
++	return transfer_pulse_wave(inwave, al, 0);
++}
++
++int record_pulse_wave(EST_Wave &inwave, EST_Option &al)
++{
++	return transfer_pulse_wave(inwave, al, 1);
++}
++
++#else
++int pulse_supported = FALSE;
++
++int play_pulse_wave(EST_Wave &inwave, EST_Option &al)
++{
++    (void)inwave;
++    (void)al;
++    cerr << "Audio: pulse not compiled in this version" << endl;
++    return -1;
++}
++
++int record_pulse_wave(EST_Wave &inwave, EST_Option &al)
++{
++    (void)inwave;
++    (void)al;
++    cerr << "Audio: pulse not compiled in this version" << endl;
++    return -1;
++}
++
++#endif
+diff -up speech_tools/config/config.in.pulse speech_tools/config/config.in
+--- speech_tools/config/config.in.pulse	2009-09-29 02:05:53.045693311 -0400
++++ speech_tools/config/config.in	2009-09-29 02:05:53.358687421 -0400
+@@ -79,6 +79,9 @@ OPTIMISE_sigpr = 3
+ ## NCD's network audio system, This is recommended.
+ # INCLUDE_MODULES += NAS_AUDIO
+ 
++## PulseAudio sound server
++INCLUDE_MODULES += PULSE_AUDIO
++
+ ## Elightenment Sound Demon, for KDE etc.
+ # INCLUDE_MODULES += ESD_AUDIO
+ 
+diff -up speech_tools/config/modules/Makefile.pulse speech_tools/config/modules/Makefile
+--- speech_tools/config/modules/Makefile.pulse	2004-07-15 19:03:05.000000000 -0400
++++ speech_tools/config/modules/Makefile	2009-09-29 02:05:53.359687618 -0400
+@@ -41,7 +41,8 @@ RULESETS = efence.mak dmalloc.mak debugg
+ 	psola_tm.mak editline.mak tcl.mak \
+ 	freebsd16_audio.mak irix_audio.mak linux16_audio.mak \
+ 	sun16_audio.mak win32_audio.mak macosx_audio.mak \
+-	mplayer_audio.mak nas_audio.mak esd_audio.mak
++	mplayer_audio.mak nas_audio.mak esd_audio.mak \
++	pulse_audio.mak
+ 
+ FILES = Makefile descriptions $(RULESETS) 
+ 
+diff -up /dev/null speech_tools/config/modules/pulse_audio.mak
+--- /dev/null	2009-09-29 00:23:01.118964058 -0400
++++ speech_tools/config/modules/pulse_audio.mak	2009-09-29 02:05:53.361688082 -0400
+@@ -0,0 +1,9 @@
++## Definitions for PulseAudio
++
++INCLUDE_PULSE_AUDIO=1
++
++MOD_DESC_PULSE_AUDIO=PulseAudio support
++
++AUDIO_DEFINES += -DSUPPORT_PULSE
++AUDIO_INCLUDES += -I$(PULSE_INCLUDE)
++MODULE_LIBS += -lpulse-simple -lpulse
+diff -up speech_tools/config/project.mak.pulse speech_tools/config/project.mak
+--- speech_tools/config/project.mak.pulse	2009-09-29 02:05:53.104720729 -0400
++++ speech_tools/config/project.mak	2009-09-29 02:05:53.362687372 -0400
+@@ -60,7 +60,7 @@ MODULE_DIRECTORY = $(TOP)
+ # List of all known modules
+ 
+ DISTRIBUTED_MODULES = \
+-	NAS_AUDIO ESD_AUDIO NATIVE_AUDIO MPLAYER_AUDIO \
++	NAS_AUDIO PULSE_AUDIO ESD_AUDIO NATIVE_AUDIO MPLAYER_AUDIO \
+ 	EDITLINE \
+ 	SIOD WAGON SCFG WFST OLS \
+ 	JAVA JAVA_CPP JAVA_MEDIA \
+diff -up speech_tools/config/systems/default.mak.pulse speech_tools/config/systems/default.mak
+--- speech_tools/config/systems/default.mak.pulse	2005-07-17 09:06:49.000000000 -0400
++++ speech_tools/config/systems/default.mak	2009-09-29 02:05:53.364688115 -0400
+@@ -61,6 +61,12 @@ NAS_INCLUDE = /usr/X11R6/include
+ NAS_LIB = /usr/X11R6/lib
+ 
+ ###########################################################################
++## Where to find PulseAudio
++
++PULSE_INCLUDE = /usr/include
++PULSE_LIB = /usr/lib
++
++###########################################################################
+ ## Where to find Enlightenment Speech Demon
+ 
+ ESD_INCLUDE = /usr/local/include
+diff -up speech_tools/include/EST_audio.h.pulse speech_tools/include/EST_audio.h
+--- speech_tools/include/EST_audio.h.pulse	2004-07-15 19:03:05.000000000 -0400
++++ speech_tools/include/EST_audio.h	2009-09-29 02:05:53.365689290 -0400
+@@ -43,6 +43,7 @@
+ #include "EST_Option.h"
+ 
+ extern int nas_supported;
++extern int pulse_supported;
+ extern int esd_supported;
+ extern int sun16_supported;
+ extern int freebsd16_supported;
diff --git a/speech_tools.spec b/speech_tools.spec
index a57d22a..3331c3f 100644
--- a/speech_tools.spec
+++ b/speech_tools.spec
@@ -4,7 +4,7 @@ Summary:	Edinburgh Speech Tools Library
 Summary(pl.UTF-8):	Biblioteka narzędzi mowy Edinburgh
 Name:		speech_tools
 Version:	2.1
-Release:	2
+Release:	2.1
 License:	distributable
 Group:		Applications/Sound
 # also:		http://www.cstr.ed.ac.uk/download/festival/2.1/%{name}-%{version}-release.tar.gz
@@ -19,6 +19,7 @@ Patch5:		%{name}-gcc42.patch
 Patch6:		%{name}-gcc44.patch
 Patch7:		%{name}-link.patch
 Patch8:		%{name}-gcc47.patch
+Patch9:		%{name}-pulse.patch
 URL:		http://www.cstr.ed.ac.uk/projects/speech_tools/
 BuildRequires:	alsa-lib-devel
 BuildRequires:	autoconf
@@ -26,6 +27,7 @@ BuildRequires:	automake
 BuildRequires:	coreutils >= 5.0-7
 BuildRequires:	libstdc++-devel
 BuildRequires:	ncurses-devel
+BuildRequires:	pulseaudio-devel
 BuildRequires:	rpmbuild(macros) >= 1.583
 BuildRequires:	sed >= 4.0
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
@@ -87,6 +89,7 @@ Programy użytkowe narzędzi mowy Edinburgh.
 %patch6 -p1
 %patch7 -p1
 %patch8 -p1
+%patch9 -p1
 %if "%{_lib}" == "lib64"
 # fix regression output for 64-bit archs (sizeof(ptr)==8 instead of 4).
 %{__sed} -i 's:20 bytes:24 bytes:' testsuite/correct/matrix_regression.out


More information about the pld-cvs-commit mailing list