dep/cubeb: Update to 1d66483
This commit is contained in:
@ -132,7 +132,9 @@ static struct cubeb_ops const cbjack_ops = {
|
||||
.stream_reset_default_device = NULL,
|
||||
.stream_get_position = cbjack_stream_get_position,
|
||||
.stream_get_latency = cbjack_get_latency,
|
||||
.stream_get_input_latency = NULL,
|
||||
.stream_set_volume = cbjack_stream_set_volume,
|
||||
.stream_set_name = NULL,
|
||||
.stream_get_current_device = cbjack_stream_get_current_device,
|
||||
.stream_device_destroy = cbjack_stream_device_destroy,
|
||||
.stream_register_device_changed_callback = NULL,
|
||||
@ -237,6 +239,22 @@ load_jack_lib(cubeb * context)
|
||||
return CUBEB_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
cbjack_connect_port_out (cubeb_stream * stream, const size_t out_port, const char * const phys_in_port)
|
||||
{
|
||||
const char *src_port = api_jack_port_name (stream->output_ports[out_port]);
|
||||
|
||||
api_jack_connect (stream->context->jack_client, src_port, phys_in_port);
|
||||
}
|
||||
|
||||
static void
|
||||
cbjack_connect_port_in (cubeb_stream * stream, const char * const phys_out_port, size_t in_port)
|
||||
{
|
||||
const char *src_port = api_jack_port_name (stream->input_ports[in_port]);
|
||||
|
||||
api_jack_connect (stream->context->jack_client, phys_out_port, src_port);
|
||||
}
|
||||
|
||||
static int
|
||||
cbjack_connect_ports (cubeb_stream * stream)
|
||||
{
|
||||
@ -256,10 +274,14 @@ cbjack_connect_ports (cubeb_stream * stream)
|
||||
|
||||
// Connect outputs to playback
|
||||
for (unsigned int c = 0; c < stream->out_params.channels && phys_in_ports[c] != NULL; c++) {
|
||||
const char *src_port = api_jack_port_name (stream->output_ports[c]);
|
||||
|
||||
api_jack_connect (stream->context->jack_client, src_port, phys_in_ports[c]);
|
||||
cbjack_connect_port_out(stream, c, phys_in_ports[c]);
|
||||
}
|
||||
|
||||
// Special case playing mono source in stereo
|
||||
if (stream->out_params.channels == 1 && phys_in_ports[1] != NULL) {
|
||||
cbjack_connect_port_out(stream, 0, phys_in_ports[1]);
|
||||
}
|
||||
|
||||
r = CUBEB_OK;
|
||||
|
||||
skipplayback:
|
||||
@ -268,9 +290,7 @@ skipplayback:
|
||||
}
|
||||
// Connect inputs to capture
|
||||
for (unsigned int c = 0; c < stream->in_params.channels && phys_out_ports[c] != NULL; c++) {
|
||||
const char *src_port = api_jack_port_name (stream->input_ports[c]);
|
||||
|
||||
api_jack_connect (stream->context->jack_client, phys_out_ports[c], src_port);
|
||||
cbjack_connect_port_in(stream, phys_out_ports[c], c);
|
||||
}
|
||||
r = CUBEB_OK;
|
||||
end:
|
||||
@ -289,9 +309,9 @@ cbjack_xrun_callback(void * arg)
|
||||
cubeb * ctx = (cubeb *)arg;
|
||||
|
||||
float delay = api_jack_get_xrun_delayed_usecs(ctx->jack_client);
|
||||
int fragments = (int)ceilf( ((delay / 1000000.0) * ctx->jack_sample_rate )
|
||||
/ (float)(ctx->jack_buffer_size) );
|
||||
ctx->jack_xruns += fragments;
|
||||
float fragments = ceilf(((delay / 1000000.0) * ctx->jack_sample_rate) / ctx->jack_buffer_size);
|
||||
|
||||
ctx->jack_xruns += (unsigned int)fragments;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -331,9 +351,11 @@ static int
|
||||
cbjack_process(jack_nframes_t nframes, void * arg)
|
||||
{
|
||||
cubeb * ctx = (cubeb *)arg;
|
||||
int t_jack_xruns = ctx->jack_xruns;
|
||||
unsigned int t_jack_xruns = ctx->jack_xruns;
|
||||
int i;
|
||||
|
||||
ctx->jack_xruns = 0;
|
||||
|
||||
for (int j = 0; j < MAX_STREAMS; j++) {
|
||||
cubeb_stream *stm = &ctx->streams[j];
|
||||
float *bufs_out[stm->out_params.channels];
|
||||
@ -343,10 +365,7 @@ cbjack_process(jack_nframes_t nframes, void * arg)
|
||||
continue;
|
||||
|
||||
// handle xruns by skipping audio that should have been played
|
||||
for (i = 0; i < t_jack_xruns; i++) {
|
||||
stm->position += ctx->fragment_size * stm->ratio;
|
||||
}
|
||||
ctx->jack_xruns -= t_jack_xruns;
|
||||
stm->position += t_jack_xruns * ctx->fragment_size * stm->ratio;
|
||||
|
||||
if (!stm->ports_ready)
|
||||
continue;
|
||||
@ -888,10 +907,12 @@ cbjack_stream_init(cubeb * context, cubeb_stream ** stream, char const * stream_
|
||||
}
|
||||
}
|
||||
|
||||
if (cbjack_connect_ports(stm) != CUBEB_OK) {
|
||||
pthread_mutex_unlock(&stm->mutex);
|
||||
cbjack_stream_destroy(stm);
|
||||
return CUBEB_ERROR;
|
||||
if (!input_stream_params->prefs & CUBEB_STREAM_PREF_JACK_NO_AUTO_CONNECT) {
|
||||
if (cbjack_connect_ports(stm) != CUBEB_OK) {
|
||||
pthread_mutex_unlock(&stm->mutex);
|
||||
cbjack_stream_destroy(stm);
|
||||
return CUBEB_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
*stream = stm;
|
||||
|
||||
Reference in New Issue
Block a user