Connecting to the appsink::new-sample signal causes gst to fail to play.
Describe your issue
Connecting to the appsink::new-sample signal causes gst to fail to play.
When this signal is connected, gst cannot be played, to be precise, it can only be played for a short while. At this point the "Status" is "PLAYING", if the "Status" changes to "PAUSE", the application will block.
Through the gdb bt command, you can observe
#0 syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007ffff69eba04 in g_mutex_lock_slowpath (mutex=0x5555557ef418) at ../glib/gthread-posix.c:1388
#2 0x00007ffff69ec477 in g_mutex_lock (mutex=mutex@entry=0x5555557ef418) at ../glib/gthread-posix.c:1417
#3 0x00007ffff7b0c9ad in gst_base_sink_change_state (element=<optimized out>, transition=<optimized out>) at ../libs/gst/base/gstbasesink.c:5775
Expected Behavior
Observed Behavior
Setup
- Operating System: Linux pc 6.2.12-200.fc37.x86_64
- Device: Computer / flatpak
- GStreamer Version: 1.20.6
Code
self->playbin = gst_element_factory_make( "playbin", "playbin" );
if ( !self->playbin ) {
return;
}
#if 1 //
GstElement* bin = gst_bin_new( "audio_sink_bin" );
g_object_set( self->playbin, "audio-sink", bin, NULL );
GstElement* tee = gst_element_factory_make( "tee", "tee" );
GstAudioInfo* info = gst_audio_info_new();
gst_audio_info_set_format( info, GST_AUDIO_FORMAT_S16, SAMPLE_RATE, 1, NULL );
GstCaps* audio_caps = gst_audio_info_to_caps( info );
GstElement* appsink = gst_element_factory_make( "appsink", "appsink" );
g_object_set( appsink, "caps", audio_caps, NULL );
gst_caps_unref( audio_caps );
gst_audio_info_free( info );
GstElement* spectrum = gst_element_factory_make( "spectrum", "spectrum" );
g_object_set(
G_OBJECT( spectrum ), "threshold", -80, "message-phase", TRUE, "post-messages", TRUE, "bands", 44, NULL );
GstElement* queue1 = gst_element_factory_make( "queue", "audio_queue" );
GstElement* queue2 = gst_element_factory_make( "queue", "appsink_queue" );
GstElement* audio_sink = gst_element_factory_make( "playsink", "audio_sink" );
gst_bin_add_many( GST_BIN( bin ), tee, queue1, queue2, spectrum, audio_sink, appsink, NULL );
if ( !gst_element_link_many( queue1, spectrum, audio_sink, NULL ) ||
!gst_element_link_many( queue2, appsink, NULL ) ) {
g_error( _( "can't link elements\n" ) );
gst_clear_object( &self->playbin );
return;
}
// set bin ghost pad
GstPad* pad = gst_element_get_static_pad( tee, "sink" );
GstPad* ghost_pad = gst_ghost_pad_new( "sink", pad );
gst_pad_set_active( ghost_pad, TRUE );
gst_element_add_pad( bin, ghost_pad );
gst_object_unref( pad );
GstPad* tee_audio_pad = gst_element_request_pad_simple( tee, "src_%u" );
GstPad* tee_app_pad = gst_element_request_pad_simple( tee, "src_%u" );
if ( !gst_element_link_pads( tee, "src_%u", queue1, "sink" ) ||
!gst_element_link_pads( tee, "src_%u", queue2, "sink" ) ) {
gst_clear_object( &self->playbin );
return;
}
#endif
/////////////////////////