From a048f5848e6d57098d4524cb8b97853ef8329854 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Tue, 1 Feb 2022 15:39:16 -0500 Subject: hmm...getting more refined here --- src/vox.c | 79 ++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 38 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/vox.c b/src/vox.c index 502d79b..047200a 100644 --- a/src/vox.c +++ b/src/vox.c @@ -4,24 +4,24 @@ #include -static void voice_cleanup(xas_vox_voice *voice, xas_audio_stream *stream) { +static void vox_cleanup(xas_vox *vox, xas_audio_stream *stream) { int status; - if (voice->flags & XAS_VOX_VOICE_ACTIVE) { - if (voice->pid >= 0) { - (void)waitpid(voice->pid, &status, 0); + if (vox->flags & XAS_VOX_ACTIVE) { + if (vox->pid >= 0) { + (void)waitpid(vox->pid, &status, 0); } - if (voice->stdout >= 0) { - (void)close(voice->stdout); + if (vox->stdout >= 0) { + (void)close(vox->stdout); } } } -static ssize_t voice_fill(xas_vox_voice *voice, - int16_t *samples, - size_t count, - xas_audio_stream *stream) { +static ssize_t vox_fill(xas_vox *vox, + int16_t *samples, + size_t count, + xas_audio_stream *stream) { size_t i; for (i=0; itext2wave_path = text2wave_path; - voice->sample_size = sample_size; - voice->sample_rate = sample_rate; - voice->ctx = ctx; - voice->flags = XAS_VOX_VOICE_IDLE; + vox->text2wave_path = text2wave_path; + vox->sample_size = sample_size; + vox->sample_rate = sample_rate; + vox->buffer_size = buffer_size; + vox->ctx = ctx; + vox->flags = XAS_VOX_IDLE; - voice->pid = -1; - voice->stdout = -1; + vox->pid = -1; + vox->stdout = -1; - if ((stream = xas_audio_stream_new_source((xas_audio_fill)voice_fill, - (xas_audio_cleanup)voice_cleanup, - voice, - sample_size, - sample_rate, - XAS_AUDIO_STREAM_MONO, - buffer_size)) == NULL) { - goto error_audio_stream_new_source; - } - - return stream; - -error_audio_stream_new_source: - free(voice); + return vox; -error_malloc_voice: +error_malloc_vox: return NULL; } + +xas_audio_stream *xas_vox_stream_new(xas_vox *vox) { + return xas_audio_stream_new_source((xas_audio_fill)vox_fill, + (xas_audio_cleanup)vox_cleanup, + vox, + vox->sample_size, + vox->sample_rate, + XAS_AUDIO_STREAM_MONO, + vox->buffer_size); +} -- cgit v1.2.3