jackaudiosink incompatible with Pipewire
Description of Problem:
A pipeline using a "jackaudiosink" element will not be able to play any sound, most of the time.
Steps to Reproduce:
- Run a pipeline like
gst-launch-1.0 audiotestsrc ! audioconvert ! audioresample ! jackaudiosink
Output:
Setting pipeline to PAUSED ...
ERROR: from element /GstPipeline:pipeline0/GstJackAudioSink:jackaudiosink0: Resource not found.
Additional debug info:
../gstreamer/subprojects/gst-plugins-good/ext/jack/gstjackaudiosink.c(308): jack_shutdown_cb (): /GstPipeline:pipeline0/GstJackAudioSink:jackaudiosink0:
Jack server shutdown
ERROR: pipeline doesn't want to preroll.
Pipeline is PREROLLING ...
Redistribute latency...
Redistribute latency...
0:00:00.0 / 99:99:99.
Debugging
This issue similar to this: pipewire/pipewire#2324 (closed)
Here's a bt of the jack_shutdown_cb()
function getting called:
#0 jack_shutdown_cb (arg=arg@entry=0x55555581b470) at ../gstreamer/subprojects/gst-plugins-good/ext/jack/gstjackaudioclient.c:206
#1 0x00007ffff76933d0 in jack_sample_rate_cb (nframes=<optimized out>, arg=arg@entry=0x55555581b470) at ../gstreamer/subprojects/gst-plugins-good/ext/jack/gstjackaudioclient.c:237
#2 0x00007ffff7142e0a in jack_set_sample_rate_callback (client=client@entry=0x55555585e260, srate_callback=srate_callback@entry=0x7ffff76933c0 <jack_sample_rate_cb>, arg=arg@entry=0x55555581b470) at ../pipewire/pipewire-jack/src/pipewire-jack.c:4546
#3 0x00007ffff7693724 in gst_jack_audio_make_connection (status=0x7fffffffd674, jclient=<optimized out>, server=0x0, id=0x5555555697f0 "gst-launch-1.0") at ../gstreamer/subprojects/gst-plugins-good/ext/jack/gstjackaudioclient.c:320
#4 gst_jack_audio_get_connection (status=0x7fffffffd674, jclient=<optimized out>, server=0x0, id=0x5555555697f0 "gst-launch-1.0") at ../gstreamer/subprojects/gst-plugins-good/ext/jack/gstjackaudioclient.c:375
#5 gst_jack_audio_client_new
(id=0x5555555697f0 "gst-launch-1.0", server=0x0, jclient=<optimized out>, type=type@entry=GST_JACK_CLIENT_SINK, shutdown=shutdown@entry=0x7ffff76946c0 <jack_shutdown_cb>, process=process@entry=0x7ffff7695bc0 <jack_process_cb>, buffer_size=0x7ffff7694570 <jack_buffer_size_cb>, sample_rate=0x7ffff7694420 <jack_sample_rate_cb>, user_data=0x5555558782d0, status=0x7fffffffd674) at ../gstreamer/subprojects/gst-plugins-good/ext/jack/gstjackaudioclient.c:514
#6 0x00007ffff7694e70 in gst_jack_ring_buffer_open_device (buf=0x5555558782d0 [GstAudioRingBuffer|jackaudiosinkringbuffer0]) at ../gstreamer/subprojects/gst-plugins-good/ext/jack/gstjackaudiosink.c:342
#7 0x00007ffff764a167 in gst_audio_ring_buffer_open_device (buf=0x5555558782d0 [GstAudioRingBuffer|jackaudiosinkringbuffer0]) at ../gstreamer/subprojects/gst-plugins-base/gst-libs/gst/audio/gstaudioringbuffer.c:469
#8 gst_audio_ring_buffer_open_device (buf=0x5555558782d0 [GstAudioRingBuffer|jackaudiosinkringbuffer0]) at ../gstreamer/subprojects/gst-plugins-base/gst-libs/gst/audio/gstaudioringbuffer.c:449
#9 0x00007ffff76316a6 in gst_audio_base_sink_change_state (element=0x5555558751a0 [GstElement|jackaudiosink0], transition=GST_STATE_CHANGE_NULL_TO_READY) at ../gstreamer/subprojects/gst-plugins-base/gst-libs/gst/audio/gstaudiobasesink.c:2415
#10 0x00007ffff7e9c6ef in gst_element_change_state (element=element@entry=0x5555558751a0 [GstElement|jackaudiosink0], transition=transition@entry=GST_STATE_CHANGE_NULL_TO_READY) at ../gstreamer/subprojects/gstreamer/gst/gstelement.c:3093
#11 0x00007ffff7e9cfb6 in gst_element_set_state_func (element=0x5555558751a0 [GstElement|jackaudiosink0], state=GST_STATE_READY) at ../gstreamer/subprojects/gstreamer/gst/gstelement.c:3047
#12 0x00007ffff7e74534 in gst_bin_element_set_state (next=<optimized out>, current=<optimized out>, start_time=0 [0:00:00.000000000], base_time=0 [0:00:00.000000000], element=0x5555558751a0 [GstElement|jackaudiosink0], bin=<optimized out>)
at ../gstreamer/subprojects/gstreamer/gst/gstbin.c:2582
#13 gst_bin_change_state_func (element=0x555555876030 [GstElement|pipeline0], transition=GST_STATE_CHANGE_NULL_TO_READY) at ../gstreamer/subprojects/gstreamer/gst/gstbin.c:2931
#14 0x00007ffff7e9c6ef in gst_element_change_state (element=element@entry=0x555555876030 [GstElement|pipeline0], transition=transition@entry=GST_STATE_CHANGE_NULL_TO_READY) at ../gstreamer/subprojects/gstreamer/gst/gstelement.c:3093
#15 0x00007ffff7e9cfb6 in gst_element_set_state_func (element=0x555555876030 [GstElement|pipeline0], state=GST_STATE_PAUSED) at ../gstreamer/subprojects/gstreamer/gst/gstelement.c:3047
#16 0x00005555555598bb in real_main (argc=<optimized out>, argv=<optimized out>) at ../gstreamer/subprojects/gstreamer/tools/gst-launch.c:1278
#17 0x00007ffff7ac6cd0 in __libc_start_call_main (main=main@entry=0x555555557020 <main>, argc=argc@entry=8, argv=argv@entry=0x7fffffffdd98) at ../sysdeps/nptl/libc_start_call_main.h:58
#18 0x00007ffff7ac6d8a in __libc_start_main_impl (main=0x555555557020 <main>, argc=8, argv=0x7fffffffdd98, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffdd88) at ../csu/libc-start.c:360
#19 0x0000555555557055 in _start ()
Pipewire seem to call the jack_sample_rate_cb
callback immediately, here pipewire-jack.c#L4530.
From the jackaudiosink
docs, changes in the buffer size and/or sample-rate are not supported.
And from the code here: gstjackaudioclient.c#L337 we can see that the client is closed if that happens.
It would be nice if GStreamer was able to properly handle this callbacks instead :)