]> code.delx.au - pulseaudio/blobdiff - src/pulsecore/proplist-util.c
remap: Change remapping function argument type from void to int16_t / float as approp...
[pulseaudio] / src / pulsecore / proplist-util.c
index d9769bc7c45fb72dd414707ac30aac0befb5866f..473290f4ffd8e1544c3eec78fe5020e45592ed2c 100644 (file)
 
 #include <string.h>
 #include <locale.h>
-#include <dlfcn.h>
+
+#ifdef ENABLE_NLS
+#include <libintl.h>
+#endif
 
 #ifdef __APPLE__
 #include <crt_externs.h>
@@ -118,14 +121,14 @@ void pa_init_proplist(pa_proplist *p) {
             if (pa_startswith(*e, "PULSE_PROP_")) {
                 size_t kl, skip;
                 char *k;
-                pa_bool_t override;
+                bool override;
 
                 if (pa_startswith(*e, "PULSE_PROP_OVERRIDE_")) {
                     skip = 20;
-                    override = TRUE;
+                    override = true;
                 } else {
                     skip = 11;
-                    override = FALSE;
+                    override = false;
                 }
 
                 kl = strcspn(*e+skip, "=");
@@ -186,10 +189,12 @@ void pa_init_proplist(pa_proplist *p) {
     }
 
     if (!pa_proplist_contains(p, PA_PROP_APPLICATION_PROCESS_BINARY)) {
-        char t[PATH_MAX];
-        if (pa_get_binary_name(t, sizeof(t))) {
+        char *t;
+
+        if ((t = pa_get_binary_name_malloc())) {
             char *c = pa_utf8_filter(t);
             pa_proplist_sets(p, PA_PROP_APPLICATION_PROCESS_BINARY, c);
+            pa_xfree(t);
             pa_xfree(c);
         }
     }
@@ -239,3 +244,33 @@ void pa_init_proplist(pa_proplist *p) {
         }
     }
 }
+
+char *pa_proplist_get_stream_group(pa_proplist *p, const char *prefix, const char *cache) {
+    const char *r;
+    char *t;
+
+    if (!p)
+        return NULL;
+
+    if (cache && (r = pa_proplist_gets(p, cache)))
+        return pa_xstrdup(r);
+
+    if (!prefix)
+        prefix = "stream";
+
+    if ((r = pa_proplist_gets(p, PA_PROP_MEDIA_ROLE)))
+        t = pa_sprintf_malloc("%s-by-media-role:%s", prefix, r);
+    else if ((r = pa_proplist_gets(p, PA_PROP_APPLICATION_ID)))
+        t = pa_sprintf_malloc("%s-by-application-id:%s", prefix, r);
+    else if ((r = pa_proplist_gets(p, PA_PROP_APPLICATION_NAME)))
+        t = pa_sprintf_malloc("%s-by-application-name:%s", prefix, r);
+    else if ((r = pa_proplist_gets(p, PA_PROP_MEDIA_NAME)))
+        t = pa_sprintf_malloc("%s-by-media-name:%s", prefix, r);
+    else
+        t = pa_sprintf_malloc("%s-fallback:%s", prefix, r);
+
+    if (cache)
+        pa_proplist_sets(p, cache, t);
+
+    return t;
+}