Пример #1
0
/**
 * ca_context_cache_full:
 * @c: The context to use for uploading.
 * @p: The property list for this event sound.
 *
 * Upload the specified sample into the server and attach the
 * specified properties to it. Similar to ca_context_cache() but takes
 * a ca_proplist instead of a variable number of arguments.
 *
 * If the backend doesn't support caching sound samples this function
 * will return CA_ERROR_NOTSUPPORTED.
 *
 * Returns: 0 on success, negative error code on error.
 */
int ca_context_cache_full(ca_context *c, ca_proplist *p) {
    int ret;

    ca_return_val_if_fail(!ca_detect_fork(), CA_ERROR_FORKED);
    ca_return_val_if_fail(c, CA_ERROR_INVALID);
    ca_return_val_if_fail(p, CA_ERROR_INVALID);

    ca_mutex_lock(c->mutex);

    ca_return_val_if_fail_unlock(ca_proplist_contains(p, CA_PROP_EVENT_ID) ||
                                 ca_proplist_contains(c->props, CA_PROP_EVENT_ID), CA_ERROR_INVALID, c->mutex);

    if ((ret = context_open_unlocked(c)) < 0)
        goto finish;

    ca_assert(c->opened);

    ret = driver_cache(c, p);

finish:

    ca_mutex_unlock(c->mutex);

    return ret;
}
Пример #2
0
/**
 * ca_context_set_driver:
 * @c: the context to change the backend driver for
 * @driver: the backend driver to use (e.g. "alsa", "pulse", "null", ...)
 *
 * Specify the backend driver used. This function may not be called again after
 * ca_context_open() suceeded. This function might suceed even when
 * the specified driver backend is not available. Use
 * ca_context_open() to find out whether the backend is available.
 *
 * Returns: 0 on success, negative error code on error.
 */
int ca_context_set_driver(ca_context *c, const char *driver) {
    char *n;
    int ret;

    ca_return_val_if_fail(!ca_detect_fork(), CA_ERROR_FORKED);
    ca_return_val_if_fail(c, CA_ERROR_INVALID);
    ca_mutex_lock(c->mutex);
    ca_return_val_if_fail_unlock(!c->opened, CA_ERROR_STATE, c->mutex);

    if (!driver)
        n = NULL;
    else if (!(n = ca_strdup(driver))) {
        ret = CA_ERROR_OOM;
        goto fail;
    }

    ca_free(c->driver);
    c->driver = n;

    ret = CA_SUCCESS;

fail:
    ca_mutex_unlock(c->mutex);

    return ret;
}
Пример #3
0
int ca_context_play_full(ca_context *c, uint32_t id, ca_proplist *p, ca_finish_callback_t cb, void *userdata) {
    int ret;
    const char *t;
    ca_bool_t enabled = TRUE;

    ca_return_val_if_fail(!ca_detect_fork(), CA_ERROR_FORKED);
    ca_return_val_if_fail(c, CA_ERROR_INVALID);
    ca_return_val_if_fail(p, CA_ERROR_INVALID);
    ca_return_val_if_fail(!userdata || cb, CA_ERROR_INVALID);

    ca_mutex_lock(c->mutex);

    ca_return_val_if_fail_unlock(ca_proplist_contains(p, CA_PROP_EVENT_ID) ||
                                 ca_proplist_contains(c->props, CA_PROP_EVENT_ID) ||
                                 ca_proplist_contains(p, CA_PROP_MEDIA_FILENAME) ||
                                 ca_proplist_contains(c->props, CA_PROP_MEDIA_FILENAME), CA_ERROR_INVALID, c->mutex);

    ca_mutex_lock(c->props->mutex);
    if ((t = ca_proplist_gets_unlocked(c->props, CA_PROP_CANBERRA_ENABLE)))
        enabled = !ca_streq(t, "0");
    ca_mutex_unlock(c->props->mutex);

    ca_mutex_lock(p->mutex);
    if ((t = ca_proplist_gets_unlocked(p, CA_PROP_CANBERRA_ENABLE)))
        enabled = !ca_streq(t, "0");
    ca_mutex_unlock(p->mutex);

    ca_return_val_if_fail_unlock(enabled, CA_ERROR_DISABLED, c->mutex);

    if ((ret = context_open_unlocked(c)) < 0)
        goto finish;

    ca_assert(c->opened);

    ret = driver_play(c, id, p, cb, userdata);
	
	vizaudio_display(p);
finish:

    ca_mutex_unlock(c->mutex);

    return ret;
}
Пример #4
0
/**
 *
 * ca_context_cancel:
 * @c: the context to cancel the sounds on
 * @id: the id that identify the sounds to cancel.
 *
 * Cancel one or more event sounds that have been started via
 * ca_context_play(). If the sound was started with
 * ca_context_play_full() and a callback function was passed this
 * might cause this function to be called with %CA_ERROR_CANCELED as
 * error code.
 *
 * Returns: 0 on success, negative error code on error.
 */
int ca_context_cancel(ca_context *c, uint32_t id)  {
    int ret;

    ca_return_val_if_fail(!ca_detect_fork(), CA_ERROR_FORKED);
    ca_return_val_if_fail(c, CA_ERROR_INVALID);
    ca_mutex_lock(c->mutex);
    ca_return_val_if_fail_unlock(c->opened, CA_ERROR_STATE, c->mutex);

    ret = driver_cancel(c, id);

    ca_mutex_unlock(c->mutex);

    return ret;
}
Пример #5
0
/**
 * ca_context_open:
 * @c: the context to connect.
 *
 * Connect the context to the sound system. This call is implicitly
 * called in ca_context_play() or ca_context_cache() if not called
 * explicitly. It is recommended to initialize application properties
 * with ca_context_change_props() before calling this function.
 *
 * Returns: 0 on success, negative error code on error.
 */
int ca_context_open(ca_context *c) {
    int ret;

    ca_return_val_if_fail(!ca_detect_fork(), CA_ERROR_FORKED);
    ca_return_val_if_fail(c, CA_ERROR_INVALID);
    ca_mutex_lock(c->mutex);
    ca_return_val_if_fail_unlock(!c->opened, CA_ERROR_STATE, c->mutex);

    ret = context_open_unlocked(c);

    ca_mutex_unlock(c->mutex);

    return ret;
}