void pa__done(pa_module*m) {
    struct userdata*u;
    pa_assert(m);

    if (!(u = m->userdata))
        return;

    unpublish_all_services(u);

    if (u->services)
        pa_hashmap_free(u->services);

    if (u->sink_new_slot)
        pa_hook_slot_free(u->sink_new_slot);
    if (u->source_new_slot)
        pa_hook_slot_free(u->source_new_slot);
    if (u->sink_changed_slot)
        pa_hook_slot_free(u->sink_changed_slot);
    if (u->source_changed_slot)
        pa_hook_slot_free(u->source_changed_slot);
    if (u->sink_unlink_slot)
        pa_hook_slot_free(u->sink_unlink_slot);
    if (u->source_unlink_slot)
        pa_hook_slot_free(u->source_unlink_slot);

    if (u->native)
        pa_native_protocol_unref(u->native);

    pa_xfree(u->service_name);
    pa_xfree(u);
}
void pa__done(pa_module*m) {
    pa_assert(m);

    if (m->userdata) {
        pa_native_protocol_disconnect(m->userdata, m);
        pa_native_protocol_unref(m->userdata);
    }
}
void pa__done(pa_module*m) {
    struct userdata*u;
    pa_assert(m);

    if (!(u = m->userdata))
        return;

    if (u->services) {
        struct service *s;

        while ((s = pa_hashmap_first(u->services)))
            service_free(s);

        pa_hashmap_free(u->services, NULL, NULL);
    }

    if (u->sink_new_slot)
        pa_hook_slot_free(u->sink_new_slot);
    if (u->source_new_slot)
        pa_hook_slot_free(u->source_new_slot);
    if (u->sink_changed_slot)
        pa_hook_slot_free(u->sink_changed_slot);
    if (u->source_changed_slot)
        pa_hook_slot_free(u->source_changed_slot);
    if (u->sink_unlink_slot)
        pa_hook_slot_free(u->sink_unlink_slot);
    if (u->source_unlink_slot)
        pa_hook_slot_free(u->source_unlink_slot);

    if (u->main_entry_group)
        avahi_entry_group_free(u->main_entry_group);

    if (u->client)
        avahi_client_free(u->client);

    if (u->avahi_poll)
        pa_avahi_poll_free(u->avahi_poll);

    if (u->native)
        pa_native_protocol_unref(u->native);

    pa_xfree(u->service_name);
    pa_xfree(u);
}
Esempio n. 4
0
void pa__done(pa_module*m) {
    struct userdata*u;

    pa_assert(m);

    if (!(u = m->userdata))
        return;

    if (u->x11_client)
        pa_x11_client_free(u->x11_client);

    if (u->x11_wrapper) {
        char t[256];
        int screen = DefaultScreen(pa_x11_wrapper_get_display(u->x11_wrapper));

        /* Yes, here is a race condition */
        if (!pa_x11_get_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_ID", t, sizeof(t)) || !pa_streq(t, u->id))
            pa_log_warn("PulseAudio information vanished from X11!");
        else {
            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_ID");
            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_SERVER");
            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_SINK");
            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_SOURCE");
            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_COOKIE");
            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_SESSION_ID");
            xcb_flush(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper));
        }

        pa_x11_wrapper_unref(u->x11_wrapper);
    }

    if (u->auth_cookie)
        pa_auth_cookie_unref(u->auth_cookie);

    if (u->hook_slot)
        pa_hook_slot_free(u->hook_slot);

    if (u->protocol)
        pa_native_protocol_unref(u->protocol);

    pa_xfree(u->id);
    pa_xfree(u);
}
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);
}