Kaynağa Gözat

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
Christoph Hohmann 9 yıl önce
ebeveyn
işleme
43dd63aeaf
1 değiştirilmiş dosya ile 12 ekleme ve 6 silme
  1. 12 6
      plugins/linux-pulseaudio/pulse-input.c

+ 12 - 6
plugins/linux-pulseaudio/pulse-input.c

@@ -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 = {