From f1a464a64d5e3e24ef74a92a8bd496fe5272a093 Mon Sep 17 00:00:00 2001 From: Roy Shilkrot Date: Tue, 22 Aug 2023 18:30:17 +0300 Subject: [PATCH] remove unique ptr --- src/transcription-filter-data.h | 8 ++++---- src/transcription-filter.cpp | 13 +++++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/transcription-filter-data.h b/src/transcription-filter-data.h index 92c24a3..cb83d96 100644 --- a/src/transcription-filter-data.h +++ b/src/transcription-filter-data.h @@ -55,16 +55,16 @@ struct transcription_filter_data { // Text source to output the subtitles obs_weak_source_t *text_source; char *text_source_name; - std::unique_ptr text_source_mutex; + std::mutex *text_source_mutex; // Callback to set the text in the output text source (subtitles) std::function setTextCallback; // Use std for thread and mutex std::thread whisper_thread; - std::unique_ptr whisper_buf_mutex; - std::unique_ptr whisper_ctx_mutex; - std::unique_ptr wshiper_thread_cv; + std::mutex *whisper_buf_mutex; + std::mutex *whisper_ctx_mutex; + std::condition_variable *wshiper_thread_cv; }; // Audio packet info diff --git a/src/transcription-filter.cpp b/src/transcription-filter.cpp index bb015f8..11f3324 100644 --- a/src/transcription-filter.cpp +++ b/src/transcription-filter.cpp @@ -138,6 +138,11 @@ void transcription_filter_destroy(void *data) } circlebuf_free(&gf->info_buffer); + delete gf->whisper_buf_mutex; + delete gf->whisper_ctx_mutex; + delete gf->wshiper_thread_cv; + delete gf->text_source_mutex; + bfree(gf); } @@ -330,10 +335,10 @@ void *transcription_filter_create(obs_data_t *settings, obs_source_t *filter) gf->resampler = audio_resampler_create(&dst, &src); obs_log(LOG_INFO, "transcription_filter: setup mutexes and condition variables"); - gf->whisper_buf_mutex.reset(new std::mutex()); - gf->whisper_ctx_mutex.reset(new std::mutex()); - gf->wshiper_thread_cv.reset(new std::condition_variable()); - gf->text_source_mutex.reset(new std::mutex()); + gf->whisper_buf_mutex = new std::mutex(); + gf->whisper_ctx_mutex = new std::mutex(); + gf->wshiper_thread_cv = new std::condition_variable(); + gf->text_source_mutex = new std::mutex(); gf->text_source = nullptr; gf->text_source_name = nullptr;