]> code.delx.au - pulseaudio/blobdiff - src/pulsecore/proplist-util.c
build-sys: Fix building without NLS
[pulseaudio] / src / pulsecore / proplist-util.c
index 23864bcbf151dfdf2d13d59fa7c89b1b71b3bef7..f4474310b9cddb2d8e77fe50e1f934997db49ddc 100644 (file)
 
 #include <string.h>
 #include <locale.h>
-#include <dlfcn.h>
+
+#ifdef ENABLE_NLS
+#include <libintl.h>
+#endif
 
 #ifdef __APPLE__
 #include <crt_externs.h>
@@ -241,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;
+}