#include #include #include #include static void voice_cleanup(xas_vox_voice *voice, xas_audio_stream *stream) { int status; if (voice->flags & XAS_VOX_VOICE_ACTIVE) { if (voice->pid >= 0) { (void)waitpid(voice->pid, &status, 0); } if (voice->stdout >= 0) { (void)close(voice->stdout); } } } static ssize_t voice_fill(xas_vox_voice *voice, 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; voice->pid = -1; voice->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); error_malloc_voice: return NULL; }