remove unique ptr

This commit is contained in:
Roy Shilkrot 2023-08-22 18:30:17 +03:00
parent 759a79f51e
commit f1a464a64d
2 changed files with 13 additions and 8 deletions

View File

@ -55,16 +55,16 @@ struct transcription_filter_data {
// Text source to output the subtitles // Text source to output the subtitles
obs_weak_source_t *text_source; obs_weak_source_t *text_source;
char *text_source_name; char *text_source_name;
std::unique_ptr<std::mutex> text_source_mutex; std::mutex *text_source_mutex;
// Callback to set the text in the output text source (subtitles) // Callback to set the text in the output text source (subtitles)
std::function<void(const std::string &str)> setTextCallback; std::function<void(const std::string &str)> setTextCallback;
// Use std for thread and mutex // Use std for thread and mutex
std::thread whisper_thread; std::thread whisper_thread;
std::unique_ptr<std::mutex> whisper_buf_mutex; std::mutex *whisper_buf_mutex;
std::unique_ptr<std::mutex> whisper_ctx_mutex; std::mutex *whisper_ctx_mutex;
std::unique_ptr<std::condition_variable> wshiper_thread_cv; std::condition_variable *wshiper_thread_cv;
}; };
// Audio packet info // Audio packet info

View File

@ -138,6 +138,11 @@ void transcription_filter_destroy(void *data)
} }
circlebuf_free(&gf->info_buffer); 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); 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); gf->resampler = audio_resampler_create(&dst, &src);
obs_log(LOG_INFO, "transcription_filter: setup mutexes and condition variables"); obs_log(LOG_INFO, "transcription_filter: setup mutexes and condition variables");
gf->whisper_buf_mutex.reset(new std::mutex()); gf->whisper_buf_mutex = new std::mutex();
gf->whisper_ctx_mutex.reset(new std::mutex()); gf->whisper_ctx_mutex = new std::mutex();
gf->wshiper_thread_cv.reset(new std::condition_variable()); gf->wshiper_thread_cv = new std::condition_variable();
gf->text_source_mutex.reset(new std::mutex()); gf->text_source_mutex = new std::mutex();
gf->text_source = nullptr; gf->text_source = nullptr;
gf->text_source_name = nullptr; gf->text_source_name = nullptr;