From 1cc112d8ef190185c6c08989b97e534a1c3b63f4 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Sun, 27 Feb 2022 17:28:02 -0500 Subject: Save context data when adding scene objects --- examples/spatial.c | 6 ++++-- include/xas/spatial.h | 7 +++++-- src/spatial.c | 4 +++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/examples/spatial.c b/examples/spatial.c index ac467ee..ec606d6 100644 --- a/examples/spatial.c +++ b/examples/spatial.c @@ -135,13 +135,15 @@ int main(int argc, char **argv) { if (xas_spatial_scene_add_object(scene, (xas_spatial_coord){ 5.2, 0.0, 0.0 }, - synth) == NULL) { + synth, + &sine_channels[0]) == NULL) { goto error_spatial_scene_add_object; } if (xas_spatial_scene_add_object(scene, (xas_spatial_coord){ -5.2, 0.0, 0.0 }, - voice) == NULL) { + voice, + vox) == NULL) { goto error_spatial_scene_add_object; } diff --git a/include/xas/spatial.h b/include/xas/spatial.h index df956a8..5323558 100644 --- a/include/xas/spatial.h +++ b/include/xas/spatial.h @@ -38,8 +38,10 @@ struct _xas_spatial_object { ssize_t shift_l, shift_r; - xas_spatial_coord point; xas_audio_stream *source; + void *ctx; + + xas_spatial_coord point; xas_spatial_object *next; }; @@ -86,7 +88,8 @@ int xas_spatial_scene_set_radius(xas_spatial_scene *scene, float radius); xas_spatial_object *xas_spatial_scene_add_object(xas_spatial_scene *scene, xas_spatial_coord point, - xas_audio_stream *source); + xas_audio_stream *source, + void *ctx); void xas_spatial_scene_position_object(xas_spatial_scene *scene, xas_spatial_object *object, diff --git a/src/spatial.c b/src/spatial.c index 2e1c066..98d54aa 100644 --- a/src/spatial.c +++ b/src/spatial.c @@ -376,7 +376,8 @@ int xas_spatial_scene_set_radius(xas_spatial_scene *scene, float radius) { xas_spatial_object *xas_spatial_scene_add_object(xas_spatial_scene *scene, xas_spatial_coord point, - xas_audio_stream *source) { + xas_audio_stream *source, + void *ctx) { xas_spatial_object *object; if (source->format.channels != XAS_AUDIO_MONO) { @@ -391,6 +392,7 @@ xas_spatial_object *xas_spatial_scene_add_object(xas_spatial_scene *scene, object->point = point; object->source = source; + object->ctx = ctx; object->next = NULL; object->delta_l = 0; object->delta_r = 0; -- cgit v1.2.3