From 61299cad17aa10808e14ea782cf92e3a492f9cf2 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 30 Jun 2015 17:07:45 +0200 Subject: [PATCH 1/2] module-tunnel: export application properties Makes them configurable via module arguments. Useful if you wish to identify particular PulseAudio servers. Signed-off-by: Pierre Ossman --- src/modules/module-tunnel-sink-new.c | 40 ++++++++++++++++++++++++++++++---- src/modules/module-tunnel-source-new.c | 40 ++++++++++++++++++++++++++++++---- src/modules/module-tunnel.c | 37 +++++++++++++++++++++++++++---- 3 files changed, 105 insertions(+), 12 deletions(-) diff --git a/src/modules/module-tunnel-sink-new.c b/src/modules/module-tunnel-sink-new.c index 7f83543..7c8f089 100644 --- a/src/modules/module-tunnel-sink-new.c +++ b/src/modules/module-tunnel-sink-new.c @@ -49,6 +49,10 @@ PA_MODULE_LOAD_ONCE(false); PA_MODULE_USAGE( "server=
" "sink= " + "app_name= " + "app_id= " + "app_version= " + "app_icon= " "sink_name= " "sink_properties= " "format= " @@ -85,6 +89,11 @@ struct userdata { char *cookie_file; char *remote_server; char *remote_sink_name; + + char *app_name; + char *app_id; + char *app_version; + char *app_icon; }; static const char* const valid_modargs[] = { @@ -92,6 +101,10 @@ static const char* const valid_modargs[] = { "sink_properties", "server", "sink", + "app_name", + "app_id", + "app_version", + "app_icon", "format", "channels", "rate", @@ -132,9 +145,14 @@ static void reset_bufferattr(pa_buffer_attr *bufferattr) { static pa_proplist* tunnel_new_proplist(struct userdata *u) { pa_proplist *proplist = pa_proplist_new(); pa_assert(proplist); - pa_proplist_sets(proplist, PA_PROP_APPLICATION_NAME, "PulseAudio"); - pa_proplist_sets(proplist, PA_PROP_APPLICATION_ID, "org.PulseAudio.PulseAudio"); - pa_proplist_sets(proplist, PA_PROP_APPLICATION_VERSION, PACKAGE_VERSION); + if (u->app_name[0]) + pa_proplist_sets(proplist, PA_PROP_APPLICATION_NAME, u->app_name); + if (u->app_id[0]) + pa_proplist_sets(proplist, PA_PROP_APPLICATION_ID, u->app_id); + if (u->app_version[0]) + pa_proplist_sets(proplist, PA_PROP_APPLICATION_VERSION, u->app_version); + if (u->app_icon[0]) + pa_proplist_sets(proplist, PA_PROP_APPLICATION_ICON_NAME, u->app_icon); pa_init_proplist(proplist); return proplist; @@ -150,7 +168,7 @@ static void thread_func(void *userdata) { proplist = tunnel_new_proplist(u); u->context = pa_context_new_with_proplist(u->thread_mainloop_api, - "PulseAudio", + u->app_name, proplist); pa_proplist_free(proplist); @@ -496,6 +514,11 @@ int pa__init(pa_module *m) { u->cookie_file = pa_xstrdup(pa_modargs_get_value(ma, "cookie", NULL)); u->remote_sink_name = pa_xstrdup(pa_modargs_get_value(ma, "sink", NULL)); + u->app_name = pa_xstrdup(pa_modargs_get_value(ma, "app_name", "PulseAudio"));; + u->app_id = pa_xstrdup(pa_modargs_get_value(ma, "app_id", "org.PulseAudio.PulseAudio"));; + u->app_version = pa_xstrdup(pa_modargs_get_value(ma, "app_version", PACKAGE_VERSION));; + u->app_icon = pa_xstrdup(pa_modargs_get_value(ma, "app_icon", ""));; + u->thread_mq = pa_xnew0(pa_thread_mq, 1); pa_thread_mq_init_thread_mainloop(u->thread_mq, m->core->mainloop, u->thread_mainloop_api); @@ -591,6 +614,15 @@ void pa__done(pa_module *m) { if (u->remote_sink_name) pa_xfree(u->remote_sink_name); + if (u->app_name) + pa_xfree(u->app_name); + if (u->app_id) + pa_xfree(u->app_id); + if (u->app_version) + pa_xfree(u->app_version); + if (u->app_icon) + pa_xfree(u->app_icon); + if (u->remote_server) pa_xfree(u->remote_server); diff --git a/src/modules/module-tunnel-source-new.c b/src/modules/module-tunnel-source-new.c index 0f72dbf..50dd3f0 100644 --- a/src/modules/module-tunnel-source-new.c +++ b/src/modules/module-tunnel-source-new.c @@ -49,6 +49,10 @@ PA_MODULE_LOAD_ONCE(false); PA_MODULE_USAGE( "server=
" "source= " + "app_name= " + "app_id= " + "app_version= " + "app_icon= " "source_name= " "source_properties= " "format= " @@ -83,6 +87,11 @@ struct userdata { char *cookie_file; char *remote_server; char *remote_source_name; + + char *app_name; + char *app_id; + char *app_version; + char *app_icon; }; static const char* const valid_modargs[] = { @@ -90,6 +99,10 @@ static const char* const valid_modargs[] = { "source_properties", "server", "source", + "app_name", + "app_id", + "app_version", + "app_icon", "format", "channels", "rate", @@ -121,9 +134,14 @@ static void reset_bufferattr(pa_buffer_attr *bufferattr) { static pa_proplist* tunnel_new_proplist(struct userdata *u) { pa_proplist *proplist = pa_proplist_new(); pa_assert(proplist); - pa_proplist_sets(proplist, PA_PROP_APPLICATION_NAME, "PulseAudio"); - pa_proplist_sets(proplist, PA_PROP_APPLICATION_ID, "org.PulseAudio.PulseAudio"); - pa_proplist_sets(proplist, PA_PROP_APPLICATION_VERSION, PACKAGE_VERSION); + if (u->app_name[0]) + pa_proplist_sets(proplist, PA_PROP_APPLICATION_NAME, u->app_name); + if (u->app_id[0]) + pa_proplist_sets(proplist, PA_PROP_APPLICATION_ID, u->app_id); + if (u->app_version[0]) + pa_proplist_sets(proplist, PA_PROP_APPLICATION_VERSION, u->app_version); + if (u->app_icon[0]) + pa_proplist_sets(proplist, PA_PROP_APPLICATION_ICON_NAME, u->app_icon); pa_init_proplist(proplist); return proplist; @@ -199,7 +217,7 @@ static void thread_func(void *userdata) { proplist = tunnel_new_proplist(u); u->context = pa_context_new_with_proplist(u->thread_mainloop_api, - "PulseAudio", + u->app_name, proplist); pa_proplist_free(proplist); @@ -495,6 +513,11 @@ int pa__init(pa_module *m) { u->cookie_file = pa_xstrdup(pa_modargs_get_value(ma, "cookie", NULL)); u->remote_source_name = pa_xstrdup(pa_modargs_get_value(ma, "source", NULL)); + u->app_name = pa_xstrdup(pa_modargs_get_value(ma, "app_name", "PulseAudio"));; + u->app_id = pa_xstrdup(pa_modargs_get_value(ma, "app_id", "org.PulseAudio.PulseAudio"));; + u->app_version = pa_xstrdup(pa_modargs_get_value(ma, "app_version", PACKAGE_VERSION));; + u->app_icon = pa_xstrdup(pa_modargs_get_value(ma, "app_icon", ""));; + u->thread_mq = pa_xnew0(pa_thread_mq, 1); pa_thread_mq_init_thread_mainloop(u->thread_mq, m->core->mainloop, u->thread_mainloop_api); @@ -588,6 +611,15 @@ void pa__done(pa_module *m) { if (u->remote_source_name) pa_xfree(u->remote_source_name); + if (u->app_name) + pa_xfree(u->app_name); + if (u->app_id) + pa_xfree(u->app_id); + if (u->app_version) + pa_xfree(u->app_version); + if (u->app_icon) + pa_xfree(u->app_icon); + if (u->remote_server) pa_xfree(u->remote_server); diff --git a/src/modules/module-tunnel.c b/src/modules/module-tunnel.c index 833423a..bd88165 100644 --- a/src/modules/module-tunnel.c +++ b/src/modules/module-tunnel.c @@ -81,6 +81,10 @@ PA_MODULE_USAGE( "auto= " "server=
" "sink= " + "app_name= " + "app_id= " + "app_version= " + "app_icon= " "cookie= " "format= " "channels= " @@ -94,6 +98,10 @@ PA_MODULE_USAGE( "auto= " "server=
" "source= " + "app_name= " + "app_id= " + "app_version= " + "app_icon= " "cookie= " "format= " "channels= " @@ -121,6 +129,10 @@ static const char* const valid_modargs[] = { "source_properties", "source", #endif + "app_name", + "app_id", + "app_version", + "app_icon", "channel_map", NULL, }; @@ -211,6 +223,11 @@ struct userdata { pa_mcalign *mcalign; #endif + char *app_name; + char *app_id; + char *app_version; + char *app_icon; + pa_auth_cookie *auth_cookie; uint32_t version; @@ -1626,13 +1643,21 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t if (u->version >= 13) { pa_proplist *pl; pl = pa_proplist_new(); - pa_proplist_sets(pl, PA_PROP_APPLICATION_ID, "org.PulseAudio.PulseAudio"); - pa_proplist_sets(pl, PA_PROP_APPLICATION_VERSION, PACKAGE_VERSION); + if (u->app_name[0]) + pa_proplist_sets(pl, PA_PROP_APPLICATION_NAME, u->app_name); + if (u->app_id[0]) + pa_proplist_sets(pl, PA_PROP_APPLICATION_ID, u->app_id); + if (u->app_version[0]) + pa_proplist_sets(pl, PA_PROP_APPLICATION_VERSION, u->app_version); + if (u->app_icon[0]) + pa_proplist_sets(pl, PA_PROP_APPLICATION_ICON_NAME, u->app_icon); pa_init_proplist(pl); pa_tagstruct_put_proplist(reply, pl); pa_proplist_free(pl); - } else - pa_tagstruct_puts(reply, "PulseAudio"); + } else { + if (u->app_name[0]) + pa_tagstruct_puts(reply, u->app_name); + } pa_pstream_send_tagstruct(u->pstream, reply); /* We ignore the server's reply here */ @@ -1951,6 +1976,10 @@ int pa__init(pa_module*m) { u->source_name = pa_xstrdup(pa_modargs_get_value(ma, "source", NULL));; u->source = NULL; #endif + u->app_name = pa_xstrdup(pa_modargs_get_value(ma, "app_name", "PulseAudio"));; + u->app_id = pa_xstrdup(pa_modargs_get_value(ma, "app_id", "org.PulseAudio.PulseAudio"));; + u->app_version = pa_xstrdup(pa_modargs_get_value(ma, "app_version", PACKAGE_VERSION));; + u->app_icon = pa_xstrdup(pa_modargs_get_value(ma, "app_icon", ""));; u->smoother = pa_smoother_new( PA_USEC_PER_SEC, PA_USEC_PER_SEC*2, -- 2.4.3