Exemplo n.º 1
0
Arquivo: roar.c Projeto: Brijen/cmus
static int op_roar_open(sample_format_t sf, const channel_position_t *channel_map)
{
    struct roar_audio_info info;
    int ret;

    memset(&info, 0, sizeof(info));

    ROAR_DBG("op_roar_open(*) = ?");

    format = sf;

    info.rate = sf_get_rate(sf);
    info.channels = sf_get_channels(sf);
    info.bits = sf_get_bits(sf);

    if (sf_get_bigendian(sf)) {
        if (sf_get_signed(sf)) {
            info.codec = ROAR_CODEC_PCM_S_BE;
        } else {
            info.codec = ROAR_CODEC_PCM_U_BE;
        }
    } else {
        if (sf_get_signed(sf)) {
            info.codec = ROAR_CODEC_PCM_S_LE;
        } else {
            info.codec = ROAR_CODEC_PCM_U_LE;
        }
    }

    ROAR_DBG("op_roar_open(*) = ?");

    if (roar_libroar_set_server(host) == -1) {
        ROAR_DBG("op_roar_open(*) = ?");

        roar_err_to_errno();
        return -OP_ERROR_ERRNO;
    }

    if ( roar_simple_connect2(&con, NULL, "C* Music Player (cmus)", ROAR_ENUM_FLAG_NONBLOCK, 0) == -1 ) {
        ROAR_DBG("op_roar_open(*) = ?");

        roar_err_to_errno();
        return -OP_ERROR_ERRNO;
    }

    vss = roar_vs_new_from_con(&con, &err);
    if (vss == NULL) {
        ROAR_DBG("op_roar_open(*) = ?");

        roar_disconnect(&con);

        _err_to_errno();
        return -OP_ERROR_ERRNO;
    }

    if (roar_vs_stream(vss, &info, ROAR_DIR_PLAY, &err) == -1) {
        ROAR_DBG("op_roar_open(*) = ?");

        roar_disconnect(&con);

        _err_to_errno();
        return -OP_ERROR_ERRNO;
    }

    ROAR_DBG("op_roar_open(*) = ?");

    if (roar_vs_buffer(vss, 2048*8, &err) == -1) {
        roar_vs_close(vss, ROAR_VS_TRUE, NULL);
        roar_disconnect(&con);
        _err_to_errno();
        return -OP_ERROR_ERRNO;
    }

    ROAR_DBG("op_roar_open(*) = ?");

    ret = _set_role();
    if (ret != 0) {
        roar_vs_close(vss, ROAR_VS_TRUE, NULL);
        roar_disconnect(&con);
        _err_to_errno();
        return ret;
    }

    ROAR_DBG("op_roar_open(*) = ?");

    if (roar_vs_blocking(vss, ROAR_VS_FALSE, &err) == -1) {
        /* FIXME: handle this error */
    }

    ROAR_DBG("op_roar_open(*) = 0");

    return 0;
}
Exemplo n.º 2
0
Arquivo: roar.c Projeto: Brijen/cmus
static int op_roar_close(void)
{
    roar_vs_close(vss, ROAR_VS_FALSE, &err);
    roar_disconnect(&con);
    return 0;
}
Exemplo n.º 3
0
static void ra_free(void *data)
{
   roar_t *roar = (roar_t*)data;
   roar_vs_close(roar->vss, ROAR_VS_TRUE, NULL);
   free(data);
}