From ca33881982e65f5c927cabdde5571ac4b8ce19cb Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Sat, 26 Feb 2022 22:27:18 -0500 Subject: Ensure vox can only start, stop in correct state --- src/vox.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/vox.c b/src/vox.c index 94d41dc..efe5346 100644 --- a/src/vox.c +++ b/src/vox.c @@ -66,7 +66,9 @@ static int vox_start(xas_vox *vox) { snprintf(sample_rate, sizeof(sample_rate)-1, "%zu", vox->format.sample_rate); - (void)vox_stop(vox); + if (vox->flags & XAS_VOX_ACTIVE) { + (void)vox_stop(vox); + } if (pipe(pipe_stdin) < 0) { goto error_pipe_stdin; @@ -203,7 +205,11 @@ void xas_vox_destroy(xas_vox *vox) { } int xas_vox_stop(xas_vox *vox) { - return vox_stop(vox); + if (vox->flags & XAS_VOX_ACTIVE) { + return vox_stop(vox); + } + + return 0; } int xas_vox_active(xas_vox *vox) { @@ -241,7 +247,7 @@ error_riff_open_fd: } int xas_vox_vsayf(xas_vox *vox, const char *format, va_list args) { - if (vox_start(vox) < 0) { + if (!(vox->flags & XAS_VOX_ACTIVE) && vox_start(vox) < 0) { goto error_vox_start; } -- cgit v1.2.3