diff options
author | XANTRONIX Development | 2022-02-26 23:36:50 -0500 |
---|---|---|
committer | XANTRONIX Development | 2022-02-26 23:36:50 -0500 |
commit | ab9f3166f07a43fd739262530575f30432d7782a (patch) | |
tree | 260c6a10b3d7fbb35bc092f4fdefd4e2699d3e4f /src | |
parent | 51806621006a9d54d368c7c033e59b2a3818f5ae (diff) | |
download | xas-ab9f3166f07a43fd739262530575f30432d7782a.tar.gz xas-ab9f3166f07a43fd739262530575f30432d7782a.tar.bz2 xas-ab9f3166f07a43fd739262530575f30432d7782a.zip |
Switch to enum type for vox state
Diffstat (limited to 'src')
-rw-r--r-- | src/vox.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -38,7 +38,7 @@ static int vox_stop(xas_vox *vox) { vox->pid = -1; } - vox->flags &= ~XAS_VOX_ACTIVE; + vox->state = XAS_VOX_IDLE; return 0; @@ -83,7 +83,7 @@ static int vox_start(xas_vox *vox) { char sample_rate[40]; - if (vox->flags & XAS_VOX_ACTIVE) { + if (vox->state == XAS_VOX_ACTIVE) { (void)vox_stop(vox); } @@ -155,7 +155,7 @@ error_child: vox->stdin = pipe_stdin[1]; vox->stdout = pipe_stdout[0]; vox->in = fdopen(pipe_stdin[1], "w"); - vox->flags |= XAS_VOX_ACTIVE; + vox->state = XAS_VOX_ACTIVE; return 0; @@ -182,7 +182,7 @@ static ssize_t vox_fill(xas_vox *vox, ssize_t readlen, readcount; - if (!(vox->flags & XAS_VOX_ACTIVE)) { + if (vox->state != XAS_VOX_ACTIVE) { xas_audio_zero(vox->format, samples, 0, count); return count; @@ -224,7 +224,7 @@ xas_vox *xas_vox_new(const char *text2wave_path, vox->format.sample_rate = format.sample_rate; vox->buffer_size = buffer_size; - vox->flags = XAS_VOX_IDLE; + vox->state = XAS_VOX_IDLE; vox->pid = -1; vox->stdin = -1; vox->stdout = -1; @@ -246,7 +246,7 @@ void xas_vox_destroy(xas_vox *vox) { } int xas_vox_stop(xas_vox *vox) { - if (vox->flags & XAS_VOX_ACTIVE) { + if (vox->state == XAS_VOX_ACTIVE) { return vox_stop(vox); } @@ -254,7 +254,7 @@ int xas_vox_stop(xas_vox *vox) { } int xas_vox_active(xas_vox *vox) { - return vox->flags & XAS_VOX_ACTIVE; + return vox->state == XAS_VOX_ACTIVE; } int xas_vox_generate(xas_vox *vox) { @@ -288,7 +288,7 @@ error_riff_open_fd: } int xas_vox_vsayf(xas_vox *vox, const char *format, va_list args) { - if (!(vox->flags & XAS_VOX_ACTIVE) && vox_start(vox) < 0) { + if (vox->state == XAS_VOX_IDLE && vox_start(vox) < 0) { goto error_vox_start; } |