pulse-input: Fix design flaw where source is not created

When a pulseaudio source is created from existing settings and the
device is not found, then the private data will return NULL, making it
impossible to change the source to use a different device.  NULL should
never be returned when possible, otherwise settings cannot be changed
and properties cannot be displayed.

Closes jp9000/obs-studio#604
This commit is contained in:
Christoph Hohmann 2016-08-28 02:56:59 +02:00 committed by jp9000
parent 7d6bf872e2
commit 43dd63aeaf

View File

@ -183,7 +183,13 @@ static void pulse_source_info(pa_context *c, const pa_source_info *i, int eol,
{
UNUSED_PARAMETER(c);
PULSE_DATA(userdata);
if (eol != 0)
// An error occured
if (eol < 0) {
data->format = PA_SAMPLE_INVALID;
goto skip;
}
// Terminating call for multi instance callbacks
if (eol > 0)
goto skip;
blog(LOG_INFO, "Audio format: %s, %"PRIu32" Hz"
@ -242,6 +248,10 @@ static int_fast32_t pulse_start_recording(struct pulse_data *data)
blog(LOG_ERROR, "Unable to get source info !");
return -1;
}
if (data->format == PA_SAMPLE_INVALID) {
blog(LOG_ERROR, "An error occurred while getting the source info!");
return -1;
}
pa_sample_spec spec;
spec.format = data->format;
@ -507,11 +517,7 @@ static void *pulse_create(obs_data_t *settings, obs_source_t *source)
pulse_init();
pulse_update(data, settings);
if (data->stream)
return data;
pulse_destroy(data);
return NULL;
return data;
}
struct obs_source_info pulse_input_capture = {