swap thread

This commit is contained in:
Roy Shilkrot 2023-08-23 14:26:07 +03:00
parent de346a2897
commit 6ccff434f7
2 changed files with 8 additions and 1 deletions

View File

@ -399,10 +399,12 @@ void *transcription_filter_create(obs_data_t *settings, obs_source_t *filter)
obs_log(LOG_INFO, "transcription_filter: start whisper thread");
// start the thread
gf->whisper_thread = std::thread(whisper_loop, gf);
std::thread new_whisper_thread(whisper_loop, gf);
gf->whisper_thread.swap(new_whisper_thread);
gf->active = true;
obs_log(LOG_INFO, "transcription_filter: filter created.");
return gf;
}

View File

@ -297,6 +297,11 @@ void process_audio_from_buffer(struct transcription_filter_data *gf)
void whisper_loop(void *data)
{
if (data == nullptr) {
obs_log(LOG_ERROR, "whisper_loop: data is null");
return;
}
struct transcription_filter_data *gf =
static_cast<struct transcription_filter_data *>(data);
const size_t segment_size = gf->frames * sizeof(float);