From 8fc9b19cb314329487a62a15c523e9778298f1d5 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Sat, 28 Feb 2009 23:45:02 +0000 Subject: Don't assume that device reservation is enabled. In the case when the alsa 'device' is not a physical card, it wont have an index and thus the reservation name will be NULL and therefore we will not initialise the reservation system. Fixes #498 --- src/modules/alsa/alsa-sink.c | 2 +- src/modules/alsa/alsa-source.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index 0aef1bd5..708e020c 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -148,7 +148,7 @@ static void reserve_update(struct userdata *u) { const char *description; pa_assert(u); - if (!u->sink) + if (!u->sink || !u->reserve) return; if ((description = pa_proplist_gets(u->sink->proplist, PA_PROP_DEVICE_DESCRIPTION))) diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c index 671df3fe..4321c7ff 100644 --- a/src/modules/alsa/alsa-source.c +++ b/src/modules/alsa/alsa-source.c @@ -146,7 +146,7 @@ static void reserve_update(struct userdata *u) { const char *description; pa_assert(u); - if (!u->source) + if (!u->source || !u->reserve) return; if ((description = pa_proplist_gets(u->source->proplist, PA_PROP_DEVICE_DESCRIPTION))) -- cgit From d293f08442ee750373257dd3f769f14bfbef3432 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Sun, 1 Mar 2009 18:10:35 +0000 Subject: raop: Allow for nice sink descriptions to be set (interpolated from avahi) --- src/modules/module-raop-discover.c | 27 ++++++++++++++++++++++----- src/modules/module-raop-sink.c | 9 +++++++-- 2 files changed, 29 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/modules/module-raop-discover.c b/src/modules/module-raop-discover.c index df393151..7df549ea 100644 --- a/src/modules/module-raop-discover.c +++ b/src/modules/module-raop-discover.c @@ -152,11 +152,18 @@ static void resolver_cb( if (event != AVAHI_RESOLVER_FOUND) pa_log("Resolving of '%s' failed: %s", name, avahi_strerror(avahi_client_errno(u->client))); else { - char *device = NULL, *dname, *vname, *args; + char *device = NULL, *nicename, *dname, *vname, *args; char at[AVAHI_ADDRESS_STR_MAX]; AvahiStringList *l; pa_module *m; + if ((nicename = strstr(name, "@"))) { + ++nicename; + if (strlen(nicename) > 0) { + pa_log_debug("Found RAOP: %s", nicename); + } + } + for (l = txt; l; l = l->next) { char *key, *value; pa_assert_se(avahi_string_list_get_pair(l, &key, &value, NULL) == 0); @@ -190,10 +197,20 @@ static void resolver_cb( "sink_name=%s", avahi_address_snprint(at, sizeof(at), a), port, vname);*/ - args = pa_sprintf_malloc("server=%s " - "sink_name=%s", - avahi_address_snprint(at, sizeof(at), a), - vname); + if (nicename) { + args = pa_sprintf_malloc("server=%s " + "sink_name=%s " + "description=\"%s\"", + avahi_address_snprint(at, sizeof(at), a), + vname, + nicename); + + } else { + args = pa_sprintf_malloc("server=%s " + "sink_name=%s", + avahi_address_snprint(at, sizeof(at), a), + vname); + } pa_log_debug("Loading module-raop-sink with arguments '%s'", args); diff --git a/src/modules/module-raop-sink.c b/src/modules/module-raop-sink.c index da338f5d..88fc6f1e 100644 --- a/src/modules/module-raop-sink.c +++ b/src/modules/module-raop-sink.c @@ -72,6 +72,7 @@ PA_MODULE_VERSION(PACKAGE_VERSION); PA_MODULE_LOAD_ONCE(FALSE); PA_MODULE_USAGE( "sink_name= " + "description= " "server=
" "format= " "channels= " @@ -122,6 +123,7 @@ static const char* const valid_modargs[] = { "format", "channels", "sink_name", + "description", NULL }; @@ -502,7 +504,7 @@ int pa__init(pa_module*m) { struct userdata *u = NULL; pa_sample_spec ss; pa_modargs *ma = NULL; - const char *server; + const char *server, *desc; pa_sink_new_data data; pa_assert(m); @@ -564,7 +566,10 @@ int pa__init(pa_module*m) { pa_sink_new_data_set_name(&data, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME)); pa_sink_new_data_set_sample_spec(&data, &ss); pa_proplist_sets(data.proplist, PA_PROP_DEVICE_STRING, server); - pa_proplist_setf(data.proplist, PA_PROP_DEVICE_DESCRIPTION, "RAOP sink '%s'", server); + if ((desc = pa_modargs_get_value(ma, "description", NULL))) + pa_proplist_sets(data.proplist, PA_PROP_DEVICE_DESCRIPTION, desc); + else + pa_proplist_setf(data.proplist, PA_PROP_DEVICE_DESCRIPTION, "RAOP sink '%s'", server); u->sink = pa_sink_new(m->core, &data, PA_SINK_LATENCY|PA_SINK_NETWORK); pa_sink_new_data_done(&data); -- cgit From b75a4b437a6527c2506a9e19fb9025b2841f90df Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Sun, 1 Mar 2009 18:11:36 +0000 Subject: raop: Log teardown explicitly --- src/modules/raop/raop_client.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/modules/raop/raop_client.c b/src/modules/raop/raop_client.c index 4627545e..0cc67aeb 100644 --- a/src/modules/raop/raop_client.c +++ b/src/modules/raop/raop_client.c @@ -339,9 +339,13 @@ static void rtsp_cb(pa_rtsp_client *rtsp, pa_rtsp_state state, pa_headerlist* he break; case STATE_TEARDOWN: + pa_log_debug("RAOP: TEARDOWN"); + break; + case STATE_SET_PARAMETER: pa_log_debug("RAOP: SET_PARAMETER"); break; + case STATE_DISCONNECTED: pa_assert(c->closed_callback); pa_assert(c->rtsp); -- cgit From 8a00c009439d1c559a2992b2f9f67e2708334d5a Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Sun, 1 Mar 2009 23:17:07 +0000 Subject: raop: Handle the reponse header memory allocation more sensibly. In theory the callback called after reading headers could free our whole object, so we should not take it upon ourselves to free the headers after the call to the callback. --- src/modules/rtp/rtsp_client.c | 56 +++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/modules/rtp/rtsp_client.c b/src/modules/rtp/rtsp_client.c index 9eb3d964..3b077bec 100644 --- a/src/modules/rtp/rtsp_client.c +++ b/src/modules/rtp/rtsp_client.c @@ -101,26 +101,27 @@ pa_rtsp_client* pa_rtsp_client_new(pa_mainloop_api *mainloop, const char* hostna void pa_rtsp_client_free(pa_rtsp_client* c) { - if (c) { - if (c->sc) - pa_socket_client_unref(c->sc); - if (c->ioline) - pa_ioline_close(c->ioline); - else if (c->io) - pa_iochannel_free(c->io); - - pa_xfree(c->hostname); - pa_xfree(c->url); - pa_xfree(c->localip); - pa_xfree(c->session); - pa_xfree(c->transport); - pa_xfree(c->last_header); - if (c->header_buffer) - pa_strbuf_free(c->header_buffer); - if (c->response_headers) - pa_headerlist_free(c->response_headers); - pa_headerlist_free(c->headers); - } + pa_assert(c); + + if (c->sc) + pa_socket_client_unref(c->sc); + if (c->ioline) + pa_ioline_close(c->ioline); + else if (c->io) + pa_iochannel_free(c->io); + + pa_xfree(c->hostname); + pa_xfree(c->url); + pa_xfree(c->localip); + pa_xfree(c->session); + pa_xfree(c->transport); + pa_xfree(c->last_header); + if (c->header_buffer) + pa_strbuf_free(c->header_buffer); + if (c->response_headers) + pa_headerlist_free(c->response_headers); + pa_headerlist_free(c->headers); + pa_xfree(c); } @@ -141,8 +142,6 @@ static void headers_read(pa_rtsp_client *c) { c->transport = pa_xstrdup(pa_headerlist_gets(c->response_headers, "Transport")); if (!c->session || !c->transport) { - pa_headerlist_free(c->response_headers); - c->response_headers = NULL; pa_log("Invalid SETUP response."); return; } @@ -160,8 +159,6 @@ static void headers_read(pa_rtsp_client *c) { } if (0 == c->rtp_port) { /* Error no server_port in response */ - pa_headerlist_free(c->response_headers); - c->response_headers = NULL; pa_log("Invalid SETUP response (no port number)."); return; } @@ -169,9 +166,6 @@ static void headers_read(pa_rtsp_client *c) { /* Call our callback */ c->callback(c, c->state, c->response_headers, c->userdata); - - pa_headerlist_free(c->response_headers); - c->response_headers = NULL; } @@ -201,7 +195,8 @@ static void line_callback(pa_ioline *line, const char *s, void *userdata) { } if (c->waiting && 0 == strcmp("RTSP/1.0 200 OK", s2)) { c->waiting = 0; - pa_assert(!c->response_headers); + if (c->response_headers) + pa_headerlist_free(c->response_headers); c->response_headers = pa_headerlist_new(); goto exit; } @@ -353,9 +348,12 @@ void pa_rtsp_set_callback(pa_rtsp_client *c, pa_rtsp_cb_t callback, void *userda void pa_rtsp_disconnect(pa_rtsp_client *c) { pa_assert(c); - if (c->io) + if (c->ioline) + pa_ioline_close(c->ioline); + else if (c->io) pa_iochannel_free(c->io); c->io = NULL; + c->ioline = NULL; } -- cgit