static void ra_set_nonblock_state(void *data, bool state) { roar_t *roar = (roar_t*)data; if (roar_vs_blocking(roar->vss, (state) ? ROAR_VS_FALSE : ROAR_VS_TRUE, NULL) < 0) fprintf(stderr, "RetroArch [ERROR]: Can't set nonblocking. Will not be able to fast-forward.\n"); roar->nonblocking = state; }
int roar_vs_blocking (roar_vs_t * vss, int val, int * error) { int old = -1; _ckvss(-1); if ( !(vss->flags & FLAG_STREAM) ) { _seterr(ROAR_ERROR_INVAL); return -1; } old = vss->flags & FLAG_NONBLOCK ? ROAR_VS_FALSE : ROAR_VS_TRUE; _initerr(); switch (val) { case ROAR_VS_TRUE: if ( roar_vio_nonblock(&(vss->vio), ROAR_SOCKET_BLOCK) == -1 ) { _seterrre(); return -1; } vss->flags |= FLAG_NONBLOCK; vss->flags -= FLAG_NONBLOCK; return old; break; case ROAR_VS_FALSE: if ( roar_vio_nonblock(&(vss->vio), ROAR_SOCKET_NONBLOCK) == -1 ) { _seterrre(); return -1; } vss->flags |= FLAG_NONBLOCK; return old; break; case ROAR_VS_TOGGLE: if ( old == ROAR_VS_TRUE ) { return roar_vs_blocking(vss, ROAR_VS_FALSE, error); } else { return roar_vs_blocking(vss, ROAR_VS_TRUE, error); } break; case ROAR_VS_ASK: return old; break; } _seterr(ROAR_ERROR_INVAL); return -1; }
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; }