[vlc-commits] pulse: map media role
Rémi Denis-Courmont
git at videolan.org
Sun Jun 5 11:27:36 CEST 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jun 4 17:53:49 2016 +0300| [9670e5d983aab802bf8410f296cbf44ef47029a4] | committer: Rémi Denis-Courmont
pulse: map media role
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9670e5d983aab802bf8410f296cbf44ef47029a4
---
modules/audio_output/pulse.c | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index 6bc8f37..fb2f6cb 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -673,6 +673,19 @@ static int StreamMove(audio_output_t *aout, const char *name)
static void Stop(audio_output_t *);
+static int strcmp_void(const void *a, const void *b)
+{
+ const char *const *entry = b;
+ return strcmp(a, *entry);
+}
+
+static const char *str_map(const char *key, const char *const table[][2],
+ size_t n)
+{
+ const char **r = bsearch(key, table, n, sizeof (*table), strcmp_void);
+ return (r != NULL) ? r[1] : NULL;
+}
+
/**
* Create a PulseAudio playback stream, a.k.a. a sink input.
*/
@@ -845,8 +858,28 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
/* Create a playback stream */
pa_proplist *props = pa_proplist_new();
if (likely(props != NULL))
+ {
/* TODO: set other stream properties */
- pa_proplist_sets (props, PA_PROP_MEDIA_ROLE, "video");
+ char *str = var_InheritString(aout, "role");
+ if (str != NULL)
+ {
+ static const char *const role_map[][2] = {
+ { "accessibility", "a11y" },
+ { "animation", "animation" },
+ { "communication", "phone" },
+ { "game", "game" },
+ { "music", "music" },
+ { "notification", "event" },
+ { "production", "production" },
+ { "test", "test" },
+ { "video", "video" },
+ };
+ const char *role = str_map(str, role_map, ARRAY_SIZE(role_map));
+ if (role != NULL)
+ pa_proplist_sets(props, PA_PROP_MEDIA_ROLE, role);
+ free(str);
+ }
+ }
pa_threaded_mainloop_lock(sys->mainloop);
pa_stream *s = pa_stream_new_extended(sys->context, "audio stream",
More information about the vlc-commits
mailing list