Browse Source

linux-pulseaudio: Use actual sink device names

Uses the sink device names rather than the "Monitor of" names.

Closes jp9000/obs-studio#990
Christoph Hohmann 8 years ago
parent
commit
5813a4bfbf

+ 7 - 5
plugins/linux-pulseaudio/pulse-input.c

@@ -343,15 +343,15 @@ skip:
 /**
 /**
  * output info callback
  * output info callback
  */
  */
-static void pulse_output_info(pa_context *c, const pa_source_info *i, int eol,
+static void pulse_output_info(pa_context *c, const pa_sink_info *i, int eol,
 	void *userdata)
 	void *userdata)
 {
 {
 	UNUSED_PARAMETER(c);
 	UNUSED_PARAMETER(c);
-	if (eol != 0 || i->monitor_of_sink == PA_INVALID_INDEX)
+	if (eol != 0 || i->monitor_source == PA_INVALID_INDEX)
 		goto skip;
 		goto skip;
 
 
 	obs_property_list_add_string((obs_property_t*) userdata,
 	obs_property_list_add_string((obs_property_t*) userdata,
-		i->description, i->name);
+		i->description, i->monitor_source_name);
 
 
 skip:
 skip:
 	pulse_signal(0);
 	pulse_signal(0);
@@ -368,8 +368,10 @@ static obs_properties_t *pulse_properties(bool input)
 		OBS_COMBO_FORMAT_STRING);
 		OBS_COMBO_FORMAT_STRING);
 
 
 	pulse_init();
 	pulse_init();
-	pa_source_info_cb_t cb = (input) ? pulse_input_info : pulse_output_info;
-	pulse_get_source_info_list(cb, (void *) devices);
+	if (input)
+		pulse_get_source_info_list(pulse_input_info, (void *) devices);
+	else
+		pulse_get_sink_info_list(pulse_output_info, (void *) devices);
 	pulse_unref();
 	pulse_unref();
 
 
 	return props;
 	return props;

+ 22 - 0
plugins/linux-pulseaudio/pulse-wrapper.c

@@ -185,6 +185,28 @@ int_fast32_t pulse_get_source_info_list(pa_source_info_cb_t cb, void* userdata)
 	return 0;
 	return 0;
 }
 }
 
 
+int_fast32_t pulse_get_sink_info_list(pa_sink_info_cb_t cb, void *userdata)
+{
+	if (pulse_context_ready() < 0)
+		return -1;
+
+	pulse_lock();
+
+	pa_operation *op = pa_context_get_sink_info_list(
+		pulse_context, cb, userdata);
+	if (!op) {
+		pulse_unlock();
+		return -1;
+	}
+	while (pa_operation_get_state(op) == PA_OPERATION_RUNNING)
+		pulse_wait();
+	pa_operation_unref(op);
+
+	pulse_unlock();
+
+	return 0;
+}
+
 int_fast32_t pulse_get_source_info(pa_source_info_cb_t cb, const char *name,
 int_fast32_t pulse_get_source_info(pa_source_info_cb_t cb, const char *name,
 	void *userdata)
 	void *userdata)
 {
 {

+ 14 - 0
plugins/linux-pulseaudio/pulse-wrapper.h

@@ -93,6 +93,20 @@ void pulse_accept();
  */
  */
 int_fast32_t pulse_get_source_info_list(pa_source_info_cb_t cb, void *userdata);
 int_fast32_t pulse_get_source_info_list(pa_source_info_cb_t cb, void *userdata);
 
 
+/**
+ * Request sink information
+ *
+ * The function will block until the operation was executed and the mainloop
+ * called the provided callback function.
+ *
+ * @return negative on error
+ *
+ * @note The function will block until the server context is ready.
+ *
+ * @warning call without active locks
+ */
+int_fast32_t pulse_get_sink_info_list(pa_sink_info_cb_t cb, void *userdata);
+
 /**
 /**
  * Request source information from a specific source
  * Request source information from a specific source
  *
  *