summaryrefslogtreecommitdiffstats
path: root/src/vox.c
diff options
context:
space:
mode:
authorXANTRONIX Development2022-03-17 11:33:22 -0400
committerXANTRONIX Development2022-03-17 11:33:22 -0400
commit9708b5b0e2b5de0e60fb6b0ef7925bc9375b85cf (patch)
treeaef908a56c0e77660d5102ba096addb1ff514223 /src/vox.c
parentc424f18c451408aa1adb146008b713eac7669b62 (diff)
downloadxas-9708b5b0e2b5de0e60fb6b0ef7925bc9375b85cf.tar.gz
xas-9708b5b0e2b5de0e60fb6b0ef7925bc9375b85cf.tar.bz2
xas-9708b5b0e2b5de0e60fb6b0ef7925bc9375b85cf.zip
Implement xas_object_call_table
Changes: * Implement xas_object_call_table as a static structure to allow creating a static dispatch table on a per-compilation-unit basis * Refactor xas_object to provide a single pointer to a xas_object_call_table * Refactor all object implementations to use xas_object_call_table
Diffstat (limited to 'src/vox.c')
-rw-r--r--src/vox.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/vox.c b/src/vox.c
index 775aee9..421ac00 100644
--- a/src/vox.c
+++ b/src/vox.c
@@ -277,6 +277,14 @@ static int vox_generate(xas_vox *vox, ...) {
return xas_vox_generate(vox);
}
+static xas_object_call_table call_table = {
+ .start = (xas_object_start_callback)vox_generate,
+ .stop = (xas_object_stop_callback)vox_stop,
+ .set_gain = (xas_object_set_gain_callback)set_gain,
+ .stream_new = (xas_object_stream_new_callback)xas_vox_stream_new,
+ .destroy = (xas_object_destroy_callback)xas_vox_destroy
+};
+
xas_vox *xas_vox_new_args(xas_audio_format format,
size_t buffer_size,
const char *text2wave_path,
@@ -288,11 +296,7 @@ xas_vox *xas_vox_new_args(xas_audio_format format,
goto error_malloc_vox;
}
- vox->obj.start = (xas_object_start_callback)vox_generate;
- vox->obj.stop = (xas_object_stop_callback)vox_stop;
- vox->obj.set_gain = (xas_object_set_gain_callback)set_gain;
- vox->obj.stream_new = (xas_object_stream_new_callback)xas_vox_stream_new;
- vox->obj.destroy = (xas_object_destroy_callback)xas_vox_destroy;
+ vox->obj.table = &call_table;
vox->text2wave_path = text2wave_path;