Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:11.4
espeak
espeak-audio-runtime-detection.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File espeak-audio-runtime-detection.patch of Package espeak
diff -ur espeak-1.42.04-source/src/Makefile espeak-1.42.04-runtime-detection/src/Makefile --- espeak-1.42.04-source/src/Makefile 2009-11-26 01:11:54.000000000 +0100 +++ espeak-1.42.04-runtime-detection/src/Makefile 2009-12-17 17:08:57.000000000 +0100 @@ -24,10 +24,16 @@ LN_SF = /bin/ln -sf MKDIR = mkdir -p -AUDIO = portaudio +AUDIO = runtime +#AUDIO = portaudio #AUDIO = pulseaudio #AUDIO = sada +ifeq ($(AUDIO),runtime) +WAVE=wave.cpp wave_pulse.cpp +LIB_AUDIO=-lpulse -lpulse-simple -lportaudio +USE_AUDIO=-DUSE_PULSEAUDIO -DUSE_PORTAUDIO +else ifeq ($(AUDIO),pulseaudio) WAVE=wave_pulse.cpp LIB_AUDIO=-lpulse @@ -46,6 +52,7 @@ endif endif endif +endif speak_SOURCES = speak.cpp compiledict.cpp dictionary.cpp intonation.cpp \ readclause.cpp setlengths.cpp numbers.cpp synth_mbrola.cpp \ diff -ur espeak-1.42.04-source/src/wave.cpp espeak-1.42.04-runtime-detection/src/wave.cpp --- espeak-1.42.04-source/src/wave.cpp 2009-12-09 18:48:13.000000000 +0100 +++ espeak-1.42.04-runtime-detection/src/wave.cpp 2009-12-17 16:30:14.000000000 +0100 @@ -53,6 +53,145 @@ #endif +#ifdef USE_PULSEAUDIO +// create some wrappers for runtime detection + +// checked on wave_init +static int pulse_running; + +// wave.cpp (this file) +void wave_port_init(); +void* wave_port_open(const char* the_api); +size_t wave_port_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize); +int wave_port_close(void* theHandler); +int wave_port_is_busy(void* theHandler); +void wave_port_terminate(); +uint32_t wave_port_get_read_position(void* theHandler); +uint32_t wave_port_get_write_position(void* theHandler); +void wave_port_flush(void* theHandler); +void wave_port_set_callback_is_output_enabled(t_wave_callback* cb); +void* wave_port_test_get_write_buffer(); +int wave_port_get_remaining_time(uint32_t sample, uint32_t* time); + +// wave_pulse.cpp +int is_pulse_running(); +void wave_pulse_init(); +void* wave_pulse_open(const char* the_api); +size_t wave_pulse_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize); +int wave_pulse_close(void* theHandler); +int wave_pulse_is_busy(void* theHandler); +void wave_pulse_terminate(); +uint32_t wave_pulse_get_read_position(void* theHandler); +uint32_t wave_pulse_get_write_position(void* theHandler); +void wave_pulse_flush(void* theHandler); +void wave_pulse_set_callback_is_output_enabled(t_wave_callback* cb); +void* wave_pulse_test_get_write_buffer(); +int wave_pulse_get_remaining_time(uint32_t sample, uint32_t* time); + +// wrappers +void wave_init() { + pulse_running = is_pulse_running(); + + if (pulse_running) + wave_pulse_init(); + else + wave_port_init(); +} + +void* wave_open(const char* the_api) { + if (pulse_running) + return wave_pulse_open(the_api); + else + return wave_port_open(the_api); +} + +size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize) { + if (pulse_running) + return wave_pulse_write(theHandler, theMono16BitsWaveBuffer, theSize); + else + return wave_port_write(theHandler, theMono16BitsWaveBuffer, theSize); +} + +int wave_close(void* theHandler) { + if (pulse_running) + return wave_pulse_close(theHandler); + else + return wave_port_close(theHandler); +} + +int wave_is_busy(void* theHandler) { + if (pulse_running) + return wave_pulse_is_busy(theHandler); + else + return wave_port_is_busy(theHandler); +} + +void wave_terminate() { + if (pulse_running) + wave_pulse_terminate(); + else + wave_port_terminate(); +} + +uint32_t wave_get_read_position(void* theHandler) { + if (pulse_running) + return wave_pulse_get_read_position(theHandler); + else + return wave_port_get_read_position(theHandler); +} + +uint32_t wave_get_write_position(void* theHandler) { + if (pulse_running) + return wave_pulse_get_write_position(theHandler); + else + return wave_port_get_write_position(theHandler); +} + +void wave_flush(void* theHandler) { + if (pulse_running) + wave_pulse_flush(theHandler); + else + wave_port_flush(theHandler); +} + +void wave_set_callback_is_output_enabled(t_wave_callback* cb) { + if (pulse_running) + wave_pulse_set_callback_is_output_enabled(cb); + else + wave_port_set_callback_is_output_enabled(cb); +} + +void* wave_test_get_write_buffer() { + if (pulse_running) + return wave_pulse_test_get_write_buffer(); + else + return wave_port_test_get_write_buffer(); +} + +int wave_get_remaining_time(uint32_t sample, uint32_t* time) +{ + if (pulse_running) + return wave_pulse_get_remaining_time(sample, time); + else + return wave_port_get_remaining_time(sample, time); +} + +// rename functions to be wrapped +#define wave_init wave_port_init +#define wave_open wave_port_open +#define wave_write wave_port_write +#define wave_close wave_port_close +#define wave_is_busy wave_port_is_busy +#define wave_terminate wave_port_terminate +#define wave_get_read_position wave_port_get_read_position +#define wave_get_write_position wave_port_get_write_position +#define wave_flush wave_port_flush +#define wave_set_callback_is_output_enabled wave_port_set_callback_is_output_enabled +#define wave_test_get_write_buffer wave_port_test_get_write_buffer +#define wave_get_remaining_time wave_port_get_remaining_time +#endif + + static t_wave_callback* my_callback_is_output_enabled=NULL; #define N_WAV_BUF 10 diff -ur espeak-1.42.04-source/src/wave_pulse.cpp espeak-1.42.04-runtime-detection/src/wave_pulse.cpp --- espeak-1.42.04-source/src/wave_pulse.cpp 2009-12-09 18:48:13.000000000 +0100 +++ espeak-1.42.04-runtime-detection/src/wave_pulse.cpp 2009-12-17 17:11:35.000000000 +0100 @@ -75,6 +75,39 @@ #define MINREQ 880 #define FRAGSIZE 0 +#ifdef USE_PORTAUDIO +// rename functions to be wrapped +#define wave_init wave_pulse_init +#define wave_open wave_pulse_open +#define wave_write wave_pulse_write +#define wave_close wave_pulse_close +#define wave_is_busy wave_pulse_is_busy +#define wave_terminate wave_pulse_terminate +#define wave_get_read_position wave_pulse_get_read_position +#define wave_get_write_position wave_pulse_get_write_position +#define wave_flush wave_pulse_flush +#define wave_set_callback_is_output_enabled wave_pulse_set_callback_is_output_enabled +#define wave_test_get_write_buffer wave_pulse_test_get_write_buffer +#define wave_get_remaining_time wave_pulse_get_remaining_time + +// check whether we can connect to PulseAudio +#include <pulse/simple.h> +int is_pulse_running() +{ + pa_sample_spec ss; + ss.format = ESPEAK_FORMAT; + ss.rate = SAMPLE_RATE; + ss.channels = ESPEAK_CHANNEL; + + pa_simple *s = pa_simple_new(NULL, "eSpeak", PA_STREAM_PLAYBACK, NULL, "is_pulse_running", &ss, NULL, NULL, NULL); + if (s) { + pa_simple_free(s); + return 1; + } else + return 0; +} +#endif + static pthread_mutex_t pulse_mutex; static pa_context *context = NULL; @@ -893,8 +926,9 @@ return 0; } -#endif // of USE_PORTAUDIO +#endif // of USE_PULSEAUDIO +#ifndef USE_PORTAUDIO //> //<clock_gettime2, add_time_in_ms @@ -928,6 +962,7 @@ } ts->tv_nsec = (long int)t_ns; } +#endif #endif // USE_ASYNC
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor