From 7bf2eee07a6c5d2120e62d13e0385e4c8e9c6782 Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Sat, 5 Mar 2011 16:49:58 -0600 Subject: [PATCH] remove experimental alsa support The direct alsa support was experimental and never worked well. It had a setting which was system specific. Also, I feel that it is better to let espeak control the audio processing. --- Makefile.am | 6 --- README | 9 ---- alsa.c | 122 --------------------------------------------------- configure.ac | 6 --- espeak.c | 8 +--- espeakup.h | 5 --- portaudio.c | 20 --------- 7 files changed, 1 insertion(+), 175 deletions(-) delete mode 100644 alsa.c delete mode 100644 portaudio.c diff --git a/Makefile.am b/Makefile.am index 41fcf0b..3afa3ae 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,12 +1,6 @@ bin_PROGRAMS = espeakup espeakup_SOURCES = espeakup.c espeakup.h cli.c espeak.c queue.c queue.h signal.c softsynth.c -if ALSA -espeakup_SOURCES += alsa.c -else -espeakup_SOURCES += portaudio.c -endif - if STANDALONE espeakup_LDFLAGS = -all-static endif diff --git a/README b/README index 13f4a2b..f3cd032 100644 --- a/README +++ b/README @@ -33,15 +33,6 @@ autoreconf -i If this runs successfully, you will have a configure script, so run it then run make. If that completes successfully, run make install. -ALSA SUPPORT -============ - -Chris Brannon contributed the alsa support to this project, and I would -like to thank him for his work on it. - -To build with alsa support, add --with-alsa to the command line when you -run the configure script. - Starting Up =========== diff --git a/alsa.c b/alsa.c deleted file mode 100644 index 35235fc..0000000 --- a/alsa.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * espeakup - interface which allows speakup to use espeak - * - * Copyright (C) 2008 William Hubbs - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* - * File: alsa.c - * Description: Produce audio by calling the ALSA library directly. -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include - -#include "espeakup.h" - -static pthread_mutex_t audio_mutex = PTHREAD_MUTEX_INITIALIZER; - -static snd_pcm_t *handle; -static const unsigned int channels = 1; -static const int soft_resample = 1; -static const unsigned int latency = 25000; - -static void lock_audio_mutex(void) -{ - pthread_mutex_lock(&audio_mutex); -} - -static void unlock_audio_mutex(void) -{ - pthread_mutex_unlock(&audio_mutex); -} - -static int alsa_callback(short *audio, int numsamples, espeak_EVENT * events) -{ - int frames = 0; - int rc = 0; - - lock_audio_mutex(); - if (stop_requested || !should_run) { - unlock_audio_mutex(); - return 1; - } - - while (numsamples > 0 && (!stop_requested && should_run)) { - frames = snd_pcm_writei(handle, audio, numsamples); - if (frames < 0) - frames = snd_pcm_recover(handle, frames, !debug); - if (frames < 0) { - fprintf(stderr, "snd_pcm_writei failed: %s\n", snd_strerror(frames)); - break; - } - if (frames > 0 && frames < numsamples && debug) - fprintf(stderr, "Short write (expected %i, wrote %i)\n", numsamples, frames); - numsamples -= frames; - audio += frames; - } - rc = (stop_requested || !should_run); - unlock_audio_mutex(); - return rc; -} - -void select_audio_mode(void) -{ - audio_mode = AUDIO_OUTPUT_RETRIEVAL; -} - -int init_audio(unsigned int rate) -{ - int err; - - /* Open PCM device for playback. */ - err = snd_pcm_open(&handle, "default", SND_PCM_STREAM_PLAYBACK, 0); - if (err < 0) { - fprintf(stderr, "Playback open error: %s\n", snd_strerror(err)); - return err; - } - - /* Set parameters. */ - err = snd_pcm_set_params(handle, - SND_PCM_FORMAT_S16_LE, - SND_PCM_ACCESS_RW_INTERLEAVED, - channels, - rate, - soft_resample, - latency); - if (err < 0) { - fprintf(stderr, "Playback open error: %s\n", snd_strerror(err)); - return err; - } - - espeak_SetSynthCallback(alsa_callback); - return 0; -} - -void stop_audio(void) -{ - lock_audio_mutex(); - if (snd_pcm_drop(handle) < 0) - fprintf(stderr, "Negative return from snd_pcm_drop!\n"); - snd_pcm_prepare(handle); - unlock_audio_mutex(); -} diff --git a/configure.ac b/configure.ac index 3d9c5c1..084ddb6 100644 --- a/configure.ac +++ b/configure.ac @@ -15,12 +15,6 @@ AC_ARG_ENABLE([standalone], [enable_standalone=no]) AM_CONDITIONAL([STANDALONE], [test x$enable_standalone = xyes]) -AC_ARG_WITH([alsa], - [AS_HELP_STRING([--with-alsa],[build with ALSA support])], - [], - [with_alsa=no]) -AM_CONDITIONAL([ALSA], [test x$with_alsa = xyes]) - # Checks for programs. AC_PROG_CC AC_PROG_INSTALL diff --git a/espeak.c b/espeak.c index b308832..8c0f275 100644 --- a/espeak.c +++ b/espeak.c @@ -136,7 +136,6 @@ static espeak_ERROR stop_speech(void) { espeak_ERROR rc; - stop_audio(); rc = espeak_Cancel(); return rc; } @@ -218,17 +217,12 @@ int initialize_espeak(struct synth_t *s) int rate; /* initialize espeak */ - select_audio_mode(); - rate = espeak_Initialize(audio_mode, 50, NULL, 0); + rate = espeak_Initialize(AUDIO_OUTPUT_PLAYBACK, 50, NULL, 0); if (rate < 0) { fprintf(stderr, "Unable to initialize espeak.\n"); return -1; } - if (init_audio((unsigned int) rate) < 0) { - return -1; - } - /* Setup initial voice parameters */ if (defaultVoice) { set_voice(s, defaultVoice); diff --git a/espeakup.h b/espeakup.h index 3580180..8680ae2 100644 --- a/espeakup.h +++ b/espeakup.h @@ -75,17 +75,12 @@ extern void *espeak_thread(void *arg); extern int open_softsynth(void); extern void close_softsynth(void); extern void *softsynth_thread(void *arg); -extern void select_audio_mode(void); -extern int init_audio(unsigned int rate); -extern void stop_audio(void); extern volatile int should_run; extern volatile int stop_requested; extern int self_pipe_fds[2]; #define PIPE_READ_FD (self_pipe_fds[0]) #define PIPE_WRITE_FD (self_pipe_fds[1]) -extern espeak_AUDIO_OUTPUT audio_mode; - extern pthread_cond_t runner_awake; extern pthread_cond_t stop_acknowledged; extern pthread_mutex_t queue_guard; diff --git a/portaudio.c b/portaudio.c deleted file mode 100644 index 82af6c6..0000000 --- a/portaudio.c +++ /dev/null @@ -1,20 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "espeakup.h" - -void select_audio_mode(void) -{ - audio_mode = AUDIO_OUTPUT_PLAYBACK; -} - -int init_audio(unsigned int rate) -{ - return 0; -} - -void stop_audio(void) -{ - return; -}