/* Self-locked. Not multiple-caller safe */
void pa_memimport_free(pa_memimport *i) {
    pa_memexport *e;
    pa_memblock *b;

    pa_assert(i);

    pa_mutex_lock(i->mutex);

    while ((b = pa_hashmap_first(i->blocks)))
        memblock_replace_import(b);

    pa_assert(pa_hashmap_size(i->segments) == 0);

    pa_mutex_unlock(i->mutex);

    pa_mutex_lock(i->pool->mutex);

    /* If we've exported this block further we need to revoke that export */
    for (e = i->pool->exports; e; e = e->next)
        memexport_revoke_blocks(e, i);

    PA_LLIST_REMOVE(pa_memimport, i->pool->imports, i);

    pa_mutex_unlock(i->pool->mutex);

    pa_hashmap_free(i->blocks);
    pa_hashmap_free(i->segments);

    pa_mutex_free(i->mutex);

    pa_xfree(i);
}
/* Remove an IO source for an X11 internal connection */
static void x11_internal_remove(pa_x11_wrapper *w, pa_x11_internal *i) {
    pa_assert(i);

    PA_LLIST_REMOVE(pa_x11_internal, w->internals, i);
    w->core->mainloop->io_free(i->io_event);
    pa_xfree(i);
}
static void register_profile_reply(DBusPendingCall *pending, void *userdata) {
    DBusMessage *r;
    pa_dbus_pending *p;
    pa_bluetooth_backend *b;
    char *profile;

    pa_assert(pending);
    pa_assert_se(p = userdata);
    pa_assert_se(b = p->context_data);
    pa_assert_se(profile = p->call_data);
    pa_assert_se(r = dbus_pending_call_steal_reply(pending));

    if (dbus_message_is_error(r, BLUEZ_ERROR_NOT_SUPPORTED)) {
        pa_log_info("Couldn't register profile %s because it is disabled in BlueZ", profile);
        goto finish;
    }

    if (dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR) {
        pa_log_error(BLUEZ_PROFILE_MANAGER_INTERFACE ".RegisterProfile() failed: %s: %s", dbus_message_get_error_name(r),
                     pa_dbus_get_error_message(r));
        goto finish;
    }

finish:
    dbus_message_unref(r);

    PA_LLIST_REMOVE(pa_dbus_pending, b->pending, p);
    pa_dbus_pending_free(p);

    pa_xfree(profile);
}
Exemple #4
0
static void cleanup_io_events(pa_glib_mainloop *g, int force) {
    pa_io_event *e;

    e = g->io_events;
    while (e) {
        pa_io_event *n = e->next;

        if (!force && g->io_events_please_scan <= 0)
            break;

        if (force || e->dead) {
            PA_LLIST_REMOVE(pa_io_event, g->io_events, e);

            if (e->dead) {
                g_assert(g->io_events_please_scan > 0);
                g->io_events_please_scan--;
            }

            if (e->poll_fd_added)
                g_source_remove_poll(&g->source, &e->poll_fd);

            if (e->destroy_callback)
                e->destroy_callback(&g->api, e, e->userdata);

            pa_xfree(e);
        }

        e = n;
    }

    g_assert(g->io_events_please_scan == 0);
}
Exemple #5
0
static void cleanup_defer_events(pa_glib_mainloop *g, int force) {
    pa_defer_event *e;

    e = g->defer_events;
    while (e) {
        pa_defer_event *n = e->next;

        if (!force && g->defer_events_please_scan <= 0)
            break;

        if (force || e->dead) {
            PA_LLIST_REMOVE(pa_defer_event, g->defer_events, e);

            if (e->dead) {
                g_assert(g->defer_events_please_scan > 0);
                g->defer_events_please_scan--;
            }

            if (!e->dead && e->enabled) {
                g_assert(g->n_enabled_defer_events > 0);
                g->n_enabled_defer_events--;
            }

            if (e->destroy_callback)
                e->destroy_callback(&g->api, e, e->userdata);

            pa_xfree(e);
        }

        e = n;
    }

    g_assert(g->defer_events_please_scan == 0);
}
static void free_subscription(pa_subscription *s) {
    pa_assert(s);
    pa_assert(s->core);

    PA_LLIST_REMOVE(pa_subscription, s->core->subscriptions, s);
    pa_xfree(s);
}
void pa_x11_client_free(pa_x11_client *c) {
    pa_assert(c);
    pa_assert(c->wrapper);
    pa_assert(PA_REFCNT_VALUE(c->wrapper) >= 1);

    PA_LLIST_REMOVE(pa_x11_client, c->wrapper->clients, c);
    pa_xfree(c);
}
Exemple #8
0
void pa_dbus_free_pending_list(pa_dbus_pending **p) {
    pa_dbus_pending *i;

    pa_assert(p);

    while ((i = *p)) {
        PA_LLIST_REMOVE(pa_dbus_pending, *p, i);
        pa_dbus_pending_free(i);
    }
}
static void free_event(pa_subscription_event *s) {
    pa_assert(s);
    pa_assert(s->core);

    if (!s->next)
        s->core->subscription_event_last = s->prev;

    PA_LLIST_REMOVE(pa_subscription_event, s->core->subscription_event_queue, s);
    pa_xfree(s);
}
Exemple #10
0
void pa_memexport_free(pa_memexport *e) {
    pa_assert(e);

    pa_mutex_lock(e->mutex);
    while (e->used_slots)
        pa_memexport_process_release(e, (uint32_t) (e->used_slots - e->slots));
    pa_mutex_unlock(e->mutex);

    pa_mutex_lock(e->pool->mutex);
    PA_LLIST_REMOVE(pa_memexport, e->pool->exports, e);
    pa_mutex_unlock(e->pool->mutex);

    pa_mutex_free(e->mutex);
    pa_xfree(e);
}