From 02ff875cd6b043e70df88ee786c41d7c5e9a13e6 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 25 Jun 2021 13:52:50 +0900 Subject: [PATCH] [audio] Add optional on_update output function on_update is for pull-model outpput targets to do periodic synchronous checks (eg, checking that the connection to the actual output device is still alive and reviving it if necessary) --- include/QF/plugin/snd_output.h | 1 + libs/audio/renderer/snd_dma.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/QF/plugin/snd_output.h b/include/QF/plugin/snd_output.h index 840647b0c..d989a1571 100644 --- a/include/QF/plugin/snd_output.h +++ b/include/QF/plugin/snd_output.h @@ -37,6 +37,7 @@ typedef struct snd_output_funcs_s { void (*shutdown) (struct snd_s *snd); int (*get_dma_pos) (struct snd_s *snd); void (*submit) (struct snd_s *snd); + void (*on_update) (struct snd_s *snd); void (*block_sound) (struct snd_s *snd); void (*unblock_sound) (struct snd_s *snd); } snd_output_funcs_t; diff --git a/libs/audio/renderer/snd_dma.c b/libs/audio/renderer/snd_dma.c index 5f995c5e2..390e10524 100644 --- a/libs/audio/renderer/snd_dma.c +++ b/libs/audio/renderer/snd_dma.c @@ -214,6 +214,10 @@ s_update (const vec3_t origin, const vec3_t forward, const vec3_t right, if (!sound_started || (snd_blocked > 0)) return; + if (snd_output_funcs->on_update) { + snd_output_funcs->on_update (&snd); + } + SND_SetListener (&snd, origin, forward, right, up, ambient_sound_level); if (snd_output_data->model == som_push) {