@@ -134,6 +134,7 @@ static struct cubeb_ops const cbjack_ops = {
134134 .stream_get_latency = cbjack_get_latency,
135135 .stream_get_input_latency = NULL ,
136136 .stream_set_volume = cbjack_stream_set_volume,
137+ .stream_set_name = NULL ,
137138 .stream_get_current_device = cbjack_stream_get_current_device,
138139 .stream_device_destroy = cbjack_stream_device_destroy,
139140 .stream_register_device_changed_callback = NULL ,
@@ -238,6 +239,22 @@ load_jack_lib(cubeb * context)
238239 return CUBEB_OK ;
239240}
240241
242+ static void
243+ cbjack_connect_port_out (cubeb_stream * stream, const size_t out_port, const char * const phys_in_port)
244+ {
245+ const char *src_port = api_jack_port_name (stream->output_ports [out_port]);
246+
247+ api_jack_connect (stream->context ->jack_client , src_port, phys_in_port);
248+ }
249+
250+ static void
251+ cbjack_connect_port_in (cubeb_stream * stream, const char * const phys_out_port, size_t in_port)
252+ {
253+ const char *src_port = api_jack_port_name (stream->input_ports [in_port]);
254+
255+ api_jack_connect (stream->context ->jack_client , phys_out_port, src_port);
256+ }
257+
241258static int
242259cbjack_connect_ports (cubeb_stream * stream)
243260{
@@ -257,10 +274,14 @@ cbjack_connect_ports (cubeb_stream * stream)
257274
258275 // Connect outputs to playback
259276 for (unsigned int c = 0 ; c < stream->out_params .channels && phys_in_ports[c] != NULL ; c++) {
260- const char *src_port = api_jack_port_name (stream->output_ports [c]);
277+ cbjack_connect_port_out (stream, c, phys_in_ports[c]);
278+ }
261279
262- api_jack_connect (stream->context ->jack_client , src_port, phys_in_ports[c]);
280+ // Special case playing mono source in stereo
281+ if (stream->out_params .channels == 1 && phys_in_ports[1 ] != NULL ) {
282+ cbjack_connect_port_out (stream, 0 , phys_in_ports[1 ]);
263283 }
284+
264285 r = CUBEB_OK ;
265286
266287skipplayback:
@@ -269,9 +290,7 @@ cbjack_connect_ports (cubeb_stream * stream)
269290 }
270291 // Connect inputs to capture
271292 for (unsigned int c = 0 ; c < stream->in_params .channels && phys_out_ports[c] != NULL ; c++) {
272- const char *src_port = api_jack_port_name (stream->input_ports [c]);
273-
274- api_jack_connect (stream->context ->jack_client , phys_out_ports[c], src_port);
293+ cbjack_connect_port_in (stream, phys_out_ports[c], c);
275294 }
276295 r = CUBEB_OK ;
277296end:
@@ -381,7 +400,6 @@ cbjack_process(jack_nframes_t nframes, void * arg)
381400 }
382401 }
383402 } else {
384-
385403 // try to lock stream mutex
386404 if (pthread_mutex_trylock (&stm->mutex ) == 0 ) {
387405
0 commit comments