[PATCH 10/21] sink-input, source-output: Add pa_sink_input/source_output_get_description()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/pulsecore/sink-input.c    | 21 +++++++++++++++++++++
 src/pulsecore/sink-input.h    |  2 ++
 src/pulsecore/source-output.c | 21 +++++++++++++++++++++
 src/pulsecore/source-output.h |  4 +++-
 4 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 8666c60..fab994d 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -32,6 +32,7 @@
 #include <pulse/util.h>
 #include <pulse/internal.h>
 
+#include <pulsecore/i18n.h>
 #include <pulsecore/mix.h>
 #include <pulsecore/core-subscribe.h>
 #include <pulsecore/log.h>
@@ -823,6 +824,26 @@ void pa_sink_input_put(pa_sink_input *i) {
     pa_sink_update_status(i->sink);
 }
 
+/* Called from the main thread. */
+const char *pa_sink_input_get_description(pa_sink_input *i) {
+    const char *description;
+
+    pa_assert(i);
+
+    description = pa_proplist_gets(i->proplist, PA_PROP_MEDIA_NAME);
+
+    /* XXX: It would be nice to be able to assume that PA_PROP_MEDIA_NAME is
+     * always set. It certainly makes sense to require that every stream should
+     * have a description. The problem is that clients can unset the property
+     * with pa_stream_proplist_update(). Perhaps we should check after each
+     * client-side proplist update whether MEDIA_NAME is still set, and if not,
+     * recreate the property automatically? */
+    if (!description)
+        description = _("(unnamed stream)");
+
+    return description;
+}
+
 /* Called from main context */
 void pa_sink_input_kill(pa_sink_input*i) {
     pa_sink_input_assert_ref(i);
diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h
index 47bdaed..2747ff0 100644
--- a/src/pulsecore/sink-input.h
+++ b/src/pulsecore/sink-input.h
@@ -362,6 +362,8 @@ size_t pa_sink_input_get_max_request(pa_sink_input *i);
 
 /* Callable by everyone from main thread*/
 
+const char *pa_sink_input_get_description(pa_sink_input *i);
+
 /* External code may request disconnection with this function */
 void pa_sink_input_kill(pa_sink_input*i);
 
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index 6e56bd3..e50aef2 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -32,6 +32,7 @@
 #include <pulse/util.h>
 #include <pulse/internal.h>
 
+#include <pulsecore/i18n.h>
 #include <pulsecore/mix.h>
 #include <pulsecore/core-subscribe.h>
 #include <pulsecore/log.h>
@@ -684,6 +685,26 @@ void pa_source_output_put(pa_source_output *o) {
     pa_source_update_status(o->source);
 }
 
+/* Called from the main thread. */
+const char *pa_source_output_get_description(pa_source_output *o) {
+    const char *description;
+
+    pa_assert(o);
+
+    description = pa_proplist_gets(o->proplist, PA_PROP_MEDIA_NAME);
+
+    /* XXX: It would be nice to be able to assume that PA_PROP_MEDIA_NAME is
+     * always set. It certainly makes sense to require that every stream should
+     * have a description. The problem is that clients can unset the property
+     * with pa_stream_proplist_update(). Perhaps we should check after each
+     * client-side proplist update whether MEDIA_NAME is still set, and if not,
+     * recreate the property automatically? */
+    if (!description)
+        description = _("(unnamed stream)");
+
+    return description;
+}
+
 /* Called from main context */
 void pa_source_output_kill(pa_source_output*o) {
     pa_source_output_assert_ref(o);
diff --git a/src/pulsecore/source-output.h b/src/pulsecore/source-output.h
index e60430f..fd95c3e 100644
--- a/src/pulsecore/source-output.h
+++ b/src/pulsecore/source-output.h
@@ -305,7 +305,9 @@ int pa_source_output_update_rate(pa_source_output *o);
 
 size_t pa_source_output_get_max_rewind(pa_source_output *o);
 
-/* Callable by everyone */
+/* Callable by everyone from the main thread. */
+
+const char *pa_source_output_get_description(pa_source_output *o);
 
 /* External code may request disconnection with this function */
 void pa_source_output_kill(pa_source_output*o);
-- 
1.8.1.2



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux