mirror of
https://github.com/occ-ai/obs-localvocal
synced 2024-11-07 18:57:14 +00:00
safeguards on file name
This commit is contained in:
parent
6f157c8f78
commit
e22fb28f96
@ -177,7 +177,7 @@ void acquire_weak_text_source_ref(struct transcription_filter_data *gf)
|
|||||||
|
|
||||||
void set_text_callback(struct transcription_filter_data *gf, const std::string &str)
|
void set_text_callback(struct transcription_filter_data *gf, const std::string &str)
|
||||||
{
|
{
|
||||||
if (gf->output_file_path != "") {
|
if (gf->output_file_path != "" && !gf->text_source_name) {
|
||||||
// Write to file, do not append
|
// Write to file, do not append
|
||||||
std::ofstream output_file(gf->output_file_path, std::ios::out | std::ios::trunc);
|
std::ofstream output_file(gf->output_file_path, std::ios::out | std::ios::trunc);
|
||||||
output_file << str;
|
output_file << str;
|
||||||
@ -226,7 +226,8 @@ void transcription_filter_update(void *data, obs_data_t *s)
|
|||||||
const char *new_text_source_name = obs_data_get_string(s, "subtitle_sources");
|
const char *new_text_source_name = obs_data_get_string(s, "subtitle_sources");
|
||||||
obs_weak_source_t *old_weak_text_source = NULL;
|
obs_weak_source_t *old_weak_text_source = NULL;
|
||||||
|
|
||||||
if (strcmp(new_text_source_name, "none") == 0 ||
|
if (new_text_source_name == nullptr ||
|
||||||
|
strcmp(new_text_source_name, "none") == 0 ||
|
||||||
strcmp(new_text_source_name, "(null)") == 0 ||
|
strcmp(new_text_source_name, "(null)") == 0 ||
|
||||||
strcmp(new_text_source_name, "text_file") == 0 || strlen(new_text_source_name) == 0) {
|
strcmp(new_text_source_name, "text_file") == 0 || strlen(new_text_source_name) == 0) {
|
||||||
// new selected text source is not valid, release the old one
|
// new selected text source is not valid, release the old one
|
||||||
@ -266,6 +267,11 @@ void transcription_filter_update(void *data, obs_data_t *s)
|
|||||||
old_weak_text_source = gf->text_source;
|
old_weak_text_source = gf->text_source;
|
||||||
gf->text_source = nullptr;
|
gf->text_source = nullptr;
|
||||||
}
|
}
|
||||||
|
if (gf->text_source_name) {
|
||||||
|
// free the old text source name
|
||||||
|
bfree(gf->text_source_name);
|
||||||
|
gf->text_source_name = nullptr;
|
||||||
|
}
|
||||||
gf->text_source_name = bstrdup(new_text_source_name);
|
gf->text_source_name = bstrdup(new_text_source_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -413,6 +419,7 @@ void *transcription_filter_create(obs_data_t *settings, obs_source_t *filter)
|
|||||||
gf->text_source_mutex = new std::mutex();
|
gf->text_source_mutex = new std::mutex();
|
||||||
gf->text_source = nullptr;
|
gf->text_source = nullptr;
|
||||||
gf->text_source_name = bstrdup(obs_data_get_string(settings, "subtitle_sources"));
|
gf->text_source_name = bstrdup(obs_data_get_string(settings, "subtitle_sources"));
|
||||||
|
gf->output_file_path = std::string("");
|
||||||
|
|
||||||
obs_log(gf->log_level, "transcription_filter: run update");
|
obs_log(gf->log_level, "transcription_filter: run update");
|
||||||
// get the settings updated on the filter data struct
|
// get the settings updated on the filter data struct
|
||||||
|
Loading…
Reference in New Issue
Block a user