Esempio n. 1
0
static void resource_set_lua_destroy(void *data)
{
    resource_set_lua_t *rset = (resource_set_lua_t *) data;

    mrp_debug("lua destructor for rset %p", rset);

    /* remove resources from the resource set -- they are finally cleaned from
     * their own lua destructors */

    if (rset->resource_set)
        mrp_resource_set_destroy(rset->resource_set);

    if (rset->resources) {
        mrp_debug("deleting htbl at %p", rset->resources);
        mrp_htbl_destroy(rset->resources, TRUE);
        rset->resources = NULL;
    }

    mrp_free(rset->zone);
    mrp_free(rset->application_class);

    if (rset->initialized) {
       n_sets--;

        if (n_sets == 0) {
            mrp_resource_client_destroy(client);
            client = NULL;
        }
    }

    return;
}
Esempio n. 2
0
void resctl_exit(resctl_t *ctl)
{
    if (ctl != NULL) {
        if (ctl->set != NULL)
            mrp_resource_set_destroy(ctl->set);

        if (ctl->client != NULL)
            mrp_resource_client_destroy(ctl->client);

        mrp_free(ctl);
    }
}
Esempio n. 3
0
static void resource_set_lua_destroy(void *data)
{
    resource_set_lua_t *rset = (resource_set_lua_t *) data;

    mrp_debug("> destroy");

    mrp_htbl_destroy(rset->resources, TRUE);

    mrp_resource_set_destroy(rset->resource_set);

    n_sets--;

    if (n_sets == 0) {
        mrp_resource_client_destroy(client);
        client = NULL;
    }

    return;
}
Esempio n. 4
0
resctl_t *resctl_init(void)
{
    resctl_t              *ctl;
    mrp_resource_client_t *client;
    mrp_resource_set_t    *set;
    const char            *zone = "driver";
    const char            *play = "audio_playback";
    const char            *rec  = "audio_recording";
    const char            *cls  = "phone";
    bool                   ar   = false;
    uint32_t               prio = 1;               /* what is this ? */

    ctl    = NULL;
    client = NULL;
    set    = NULL;

    ctl = mrp_allocz(sizeof(*ctl));

    if (ctl == NULL) {
        mrp_log_error("Failed to initialize telephony resource control.");
        goto fail;
    }

    client = mrp_resource_client_create("telephony", ctl);

    if (client == NULL) {
        mrp_log_error("Failed to create telephony resource client.");
        goto fail;
    }

    set = mrp_resource_set_create(client, ar, prio, event_cb, ctl);

    if (set == NULL) {
        mrp_log_error("Failed to create telephony resource set.");
        goto fail;
    }

    if (mrp_resource_set_add_resource(set, play, false, NULL, true) < 0 ||
            mrp_resource_set_add_resource(set, rec , false, NULL, true) < 0) {
        mrp_log_error("Failed to initialize telephony resource set.");
        goto fail;
    }

    if (mrp_application_class_add_resource_set(cls, zone, set, 0) != 0) {
        mrp_log_error("Failed to assign telephony resource set with class.");
        goto fail;
    }

    ctl->client = client;
    ctl->set    = set;
    ctl->seqno  = 1;

    return ctl;

fail:
    if (set != NULL)
        mrp_resource_set_destroy(set);

    if (client != NULL)
        mrp_resource_client_destroy(client);

    mrp_free(ctl);

    return NULL;
}