]> code.delx.au - pulseaudio/blobdiff - src/pulsecore/sink.c
sink: Add a set_formats() API
[pulseaudio] / src / pulsecore / sink.c
index 42a8eb3daea92f01855606048d9f69abf585c84b..62776985812d52f78235072f6fba51e6669cacfe 100644 (file)
@@ -180,6 +180,7 @@ static void reset_callbacks(pa_sink *s) {
     s->update_requested_latency = NULL;
     s->set_port = NULL;
     s->get_formats = NULL;
+    s->set_formats = NULL;
 }
 
 /* Called from main context */
@@ -3428,6 +3429,21 @@ pa_idxset* pa_sink_get_formats(pa_sink *s) {
     return ret;
 }
 
+/* Called from the main thread */
+/* Allows an external source to set what formats a sink supports if the sink
+ * permits this. The function makes a copy of the formats on success. */
+pa_bool_t pa_sink_set_formats(pa_sink *s, pa_idxset *formats) {
+    pa_assert(s);
+    pa_assert(formats);
+
+    if (s->set_formats)
+        /* Sink supports setting formats -- let's give it a shot */
+        return s->set_formats(s, formats);
+    else
+        /* Sink doesn't support setting this -- bail out */
+        return FALSE;
+}
+
 /* Called from the main thread */
 /* Checks if the sink can accept this format */
 pa_bool_t pa_sink_check_format(pa_sink *s, pa_format_info *f)