diff options
author | XANTRONIX Development | 2022-03-01 01:49:43 -0500 |
---|---|---|
committer | XANTRONIX Development | 2022-03-01 01:49:43 -0500 |
commit | 91a00438028c9e48d0fffbcc838fe038cc18d7e0 (patch) | |
tree | 2769ce2cc264824024c8fa8e603881dc2dac44a7 | |
parent | 6667ece6e0cec1a515f076f310295a5e691c24c3 (diff) | |
download | xas-91a00438028c9e48d0fffbcc838fe038cc18d7e0.tar.gz xas-91a00438028c9e48d0fffbcc838fe038cc18d7e0.tar.bz2 xas-91a00438028c9e48d0fffbcc838fe038cc18d7e0.zip |
Destroy managed spatial scene objects
-rw-r--r-- | include/xas/spatial.h | 4 | ||||
-rw-r--r-- | src/bank.c | 1 | ||||
-rw-r--r-- | src/spatial.c | 5 | ||||
-rw-r--r-- | src/synth.c | 1 | ||||
-rw-r--r-- | src/vox.c | 1 |
5 files changed, 12 insertions, 0 deletions
diff --git a/include/xas/spatial.h b/include/xas/spatial.h index b9297f8..5287502 100644 --- a/include/xas/spatial.h +++ b/include/xas/spatial.h @@ -3,6 +3,9 @@ #include <xas/audio.h> +#define XAS_SPATIAL_OBJECT_NONE 0 +#define XAS_SPATIAL_OBJECT_MANAGED (1 << 0) + #define XAS_SPATIAL_DEFAULT_OBSERVER_WIDTH 0.18f #define XAS_SPATIAL_DEFAULT_RADIUS 4000.0f /* metres */ #define XAS_SPATIAL_DEFAULT_SPEED 343.0f /* m/s */ @@ -40,6 +43,7 @@ struct _xas_spatial_object { xas_audio_stream *source; void *ctx; + int flags; xas_spatial_coord point; xas_spatial_object *next; @@ -135,6 +135,7 @@ xas_bank_player *xas_bank_player_new(xas_bank *bank) { player->obj.stop = (xas_object_stop_callback)xas_bank_player_stop; player->obj.set_gain = (xas_object_set_gain_callback)set_gain; player->obj.stream_new = (xas_object_stream_new_callback)xas_bank_player_stream_new; + player->obj.destroy = (xas_object_destroy_callback)xas_bank_player_destroy; player->bank = bank; player->status = XAS_BANK_PLAYER_STOPPED; diff --git a/src/spatial.c b/src/spatial.c index 63207fa..9631603 100644 --- a/src/spatial.c +++ b/src/spatial.c @@ -311,6 +311,10 @@ void xas_spatial_scene_destroy(xas_spatial_scene *scene) { while (object) { xas_spatial_object *next = object->next; + if (object->flags & XAS_SPATIAL_OBJECT_MANAGED) { + xas_object_destroy(object->ctx); + } + free(object); object = next; @@ -398,6 +402,7 @@ xas_spatial_object *xas_spatial_scene_add_object(xas_spatial_scene *scene, object->point = point; object->source = source; object->ctx = ctx; + object->flags = XAS_SPATIAL_OBJECT_NONE; object->next = NULL; object->delta_l = 0; object->delta_r = 0; diff --git a/src/synth.c b/src/synth.c index 4956621..6057ce3 100644 --- a/src/synth.c +++ b/src/synth.c @@ -130,6 +130,7 @@ xas_synth *xas_synth_new(xas_audio_format format, synth->obj.stop = (xas_object_stop_callback)synth_stop; synth->obj.set_gain = (xas_object_set_gain_callback)set_gain; synth->obj.stream_new = (xas_object_stream_new_callback)xas_synth_stream_new; + synth->obj.destroy = (xas_object_destroy_callback)xas_synth_destroy; synth->type = type; synth->state = XAS_SYNTH_IDLE; @@ -293,6 +293,7 @@ xas_vox *xas_vox_new_args(xas_audio_format format, vox->obj.stop = (xas_object_stop_callback)xas_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->text2wave_path = text2wave_path; |