From e2872d8bcc82122e3dd32211bb08d02ab984b691 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Mon, 24 Feb 2025 21:19:31 +0100 Subject: Voice processor: merge init and setup methods This ensures we are never in an uninitialized state when processing audio data --- plugins/rtp/src/voice_processor.vala | 2 -- plugins/rtp/src/voice_processor_native.cpp | 11 +++-------- 2 files changed, 3 insertions(+), 10 deletions(-) (limited to 'plugins') diff --git a/plugins/rtp/src/voice_processor.vala b/plugins/rtp/src/voice_processor.vala index a522a6ce..064684c5 100644 --- a/plugins/rtp/src/voice_processor.vala +++ b/plugins/rtp/src/voice_processor.vala @@ -99,7 +99,6 @@ public class Dino.Plugins.Rtp.VoiceProcessor : Audio.Filter { } private static extern void* init_native(int stream_delay); - private static extern void setup_native(void* native); private static extern void destroy_native(void* native); private static extern void analyze_reverse_stream(void* native, Audio.Info info, Buffer buffer); private static extern void process_stream(void* native, Audio.Info info, Buffer buffer); @@ -115,7 +114,6 @@ public class Dino.Plugins.Rtp.VoiceProcessor : Audio.Filter { period_samples = info.rate / 100; // 10ms buffers period_size = period_samples * info.bpf; adapter.clear(); - setup_native(native); return true; } diff --git a/plugins/rtp/src/voice_processor_native.cpp b/plugins/rtp/src/voice_processor_native.cpp index 39fbf1dc..7440765d 100644 --- a/plugins/rtp/src/voice_processor_native.cpp +++ b/plugins/rtp/src/voice_processor_native.cpp @@ -33,19 +33,13 @@ extern "C" void *dino_plugins_rtp_adjust_to_running_time(GstBaseTransform *trans extern "C" void *dino_plugins_rtp_voice_processor_init_native(gint stream_delay) { auto *native = new _DinoPluginsRtpVoiceProcessorNative(); -#ifdef WEBRTC0 + native->stream_delay = stream_delay; +#if defined(WEBRTC0) webrtc::Config config; config.Set(new webrtc::ExtendedFilter(true)); config.Set(new webrtc::ExperimentalAgc(true, 85)); native->apm = webrtc::AudioProcessing::Create(config); -#endif - native->stream_delay = stream_delay; - return native; -} -extern "C" void dino_plugins_rtp_voice_processor_setup_native(void *native_ptr) { - auto *native = (_DinoPluginsRtpVoiceProcessorNative *) native_ptr; -#if defined(WEBRTC0) webrtc::AudioProcessing *apm = native->apm; webrtc::ProcessingConfig pconfig; pconfig.streams[webrtc::ProcessingConfig::kInputStream] = @@ -90,6 +84,7 @@ extern "C" void dino_plugins_rtp_voice_processor_setup_native(void *native_ptr) #endif apm->ApplyConfig(config); #endif + return native; } extern "C" void -- cgit v1.3