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.
This commit is contained in:
jp9000 2015-04-15 16:13:37 -07:00
parent 48d5aeaae5
commit cf28a8af22

View File

@ -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);