static void connection_unlink(connection *c) { pa_assert(c); if (!c->protocol) return; if (c->options) { pa_simple_options_unref(c->options); c->options = NULL; } if (c->sink_input) { pa_sink_input_unlink(c->sink_input); pa_sink_input_unref(c->sink_input); c->sink_input = NULL; } if (c->source_output) { pa_source_output_unlink(c->source_output); pa_source_output_unref(c->source_output); c->source_output = NULL; } if (c->client) { pa_client_free(c->client); c->client = NULL; } if (c->io) { pa_iochannel_free(c->io); c->io = NULL; } pa_idxset_remove_by_data(c->protocol->connections, c, NULL); c->protocol = NULL; connection_unref(c); }
void pa__done(pa_module*m) { struct userdata *u; pa_assert(m); if (!(u = m->userdata)) return; #if defined(USE_PROTOCOL_SIMPLE) if (u->simple_protocol) { pa_simple_protocol_disconnect(u->simple_protocol, u->module); pa_simple_protocol_unref(u->simple_protocol); } if (u->simple_options) pa_simple_options_unref(u->simple_options); #elif defined(USE_PROTOCOL_CLI) if (u->cli_protocol) { pa_cli_protocol_disconnect(u->cli_protocol, u->module); pa_cli_protocol_unref(u->cli_protocol); } #elif defined(USE_PROTOCOL_HTTP) if (u->http_protocol) { char t[256]; #if defined(USE_TCP_SOCKETS) if (u->socket_server_ipv4) if (pa_socket_server_get_address(u->socket_server_ipv4, t, sizeof(t))) pa_http_protocol_remove_server_string(u->http_protocol, t); #ifdef HAVE_IPV6 if (u->socket_server_ipv6) if (pa_socket_server_get_address(u->socket_server_ipv6, t, sizeof(t))) pa_http_protocol_remove_server_string(u->http_protocol, t); #endif /* HAVE_IPV6 */ #else /* USE_TCP_SOCKETS */ if (u->socket_server_unix) if (pa_socket_server_get_address(u->socket_server_unix, t, sizeof(t))) pa_http_protocol_remove_server_string(u->http_protocol, t); #endif /* USE_PROTOCOL_HTTP */ pa_http_protocol_disconnect(u->http_protocol, u->module); pa_http_protocol_unref(u->http_protocol); } #elif defined(USE_PROTOCOL_NATIVE) if (u->native_protocol) { char t[256]; # if defined(USE_TCP_SOCKETS) if (u->socket_server_ipv4) if (pa_socket_server_get_address(u->socket_server_ipv4, t, sizeof(t))) pa_native_protocol_remove_server_string(u->native_protocol, t); # ifdef HAVE_IPV6 if (u->socket_server_ipv6) if (pa_socket_server_get_address(u->socket_server_ipv6, t, sizeof(t))) pa_native_protocol_remove_server_string(u->native_protocol, t); # endif # else if (u->socket_server_unix) if (pa_socket_server_get_address(u->socket_server_unix, t, sizeof(t))) pa_native_protocol_remove_server_string(u->native_protocol, t); # endif pa_native_protocol_disconnect(u->native_protocol, u->module); pa_native_protocol_unref(u->native_protocol); } if (u->native_options) pa_native_options_unref(u->native_options); #else if (u->esound_protocol) { pa_esound_protocol_disconnect(u->esound_protocol, u->module); pa_esound_protocol_unref(u->esound_protocol); } if (u->esound_options) pa_esound_options_unref(u->esound_options); #endif #if defined(USE_TCP_SOCKETS) if (u->socket_server_ipv4) pa_socket_server_unref(u->socket_server_ipv4); # ifdef HAVE_IPV6 if (u->socket_server_ipv6) pa_socket_server_unref(u->socket_server_ipv6); # endif #else if (u->socket_server_unix) pa_socket_server_unref(u->socket_server_unix); # if defined(USE_PROTOCOL_ESOUND) && !defined(USE_PER_USER_ESOUND_SOCKET) if (u->socket_path) { char *p = pa_parent_dir(u->socket_path); rmdir(p); pa_xfree(p); } # endif pa_xfree(u->socket_path); #endif pa_xfree(u); }