mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-10 13:29:58 -05:00
proplist: Add internal API to get stream group
This moves out code from module-stream-restore and makes an internal API out of it to get a "stream group" for a given sink input or source output. This is factored out for reuse in module-filter-*. The stream group basically provides some means of attaching a logical identification to the stream (by role, application id, etc.).
This commit is contained in:
parent
c30a68ebbd
commit
1798c653db
3 changed files with 44 additions and 37 deletions
|
|
@ -241,3 +241,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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,5 +25,6 @@
|
|||
#include <pulse/proplist.h>
|
||||
|
||||
void pa_init_proplist(pa_proplist *p);
|
||||
char *pa_proplist_get_stream_group(pa_proplist *pl, const char *prefix, const char *cache);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue