提交 cf28a8af 编写于 作者: J jp9000

libobs: Init source mutexes before calling create

Fixes a crash that could happen if any of the mutexes are used in the
create callback, or before the obs_source_init function is called.

I'm not sure how this function order slipped because it seems fairly
obvious that these mutexes should be created before the create callback.

Had this crash happen to me when creating a WASAPI output source, the
create callback of the WASAPI source creates a thread which outputs
audio, and that thread managed to call obs_source_output_audio before
the obs_source_init function was called, which in turn caused it to try
to use a null mutex.
上级 48d5aeaa
......@@ -189,6 +189,9 @@ obs_source_t *obs_source_create(enum obs_source_type type, const char *id,
if (info && info->get_defaults)
info->get_defaults(source->context.settings);
if (!obs_source_init(source, info))
goto fail;
/* allow the source to be created even if creation fails so that the
* user's data doesn't become lost */
if (info)
......@@ -197,9 +200,6 @@ obs_source_t *obs_source_create(enum obs_source_type type, const char *id,
if (!source->context.data)
blog(LOG_ERROR, "Failed to create source '%s'!", name);
if (!obs_source_init(source, info))
goto fail;
blog(LOG_INFO, "source '%s' (%s) created", name, id);
obs_source_dosignal(source, "source_create", NULL);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册