<div dir="ltr">Hi team<div>I am developing an application that uses Gstreamer for reading audio files. I am using a playbin connected to an appsink to do the reading. I am getting a stall only for MP3 files when I attempt to stop the pipeline i.e. move the state from PLAYING->NULL before I have read until the end of file.The stall happens in the call to:</div><div><br></div><div>gst_element_set_state(element, GST_STATE_NULL);<br></div><div><br></div><div>The traces for the relevant threads are below:</div><div><div>Thread 49 (Thread 0x7f9c2b2a3700 (LWP 59340)):</div><div>#0  syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38</div><div>#1  0x00007f9c87b1d24f in g_cond_wait () from /lib/x86_64-linux-gnu/libglib-2.0.so.0</div><div>#2  0x00007f9c2e25cd66 in gst_app_sink_event (sink=0x23873d30, event=0x21428960) at gstappsink.c:686</div><div>#3  0x00007f9c2e00fd14 in ?? () from /usr/lib/x86_64-linux-gnu/libgstbase-1.0.so.0</div><div>#4  0x00007f9c2e8dd837 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#5  0x00007f9c2e8ddcfe in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#6  0x00007f9c2e8de110 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#7  0x00007f9c2e8dbcff in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#8  0x00007f9c2e8e8061 in gst_pad_push_event () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#9  0x00007f9c2e8e81de in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#10 0x00007f9c2e8e3a7e in gst_pad_forward () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#11 0x00007f9c2e8e3bd3 in gst_pad_event_default () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#12 0x00007f9c2e8dd837 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#13 0x00007f9c2e8ddcfe in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#14 0x00007f9c2e8de110 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#15 0x00007f9c2e8dbcff in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#16 0x00007f9c2e8e8061 in gst_pad_push_event () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#17 0x00007f9c2e02b56d in ?? () from /usr/lib/x86_64-linux-gnu/libgstbase-1.0.so.0</div><div>#18 0x00007f9c2e8dd837 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#19 0x00007f9c2e8ddcfe in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#20 0x00007f9c2e8de110 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#21 0x00007f9c2e8dbcff in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#22 0x00007f9c2e8e8061 in gst_pad_push_event () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#23 0x00007f9c2e02b56d in ?? () from /usr/lib/x86_64-linux-gnu/libgstbase-1.0.so.0</div><div>#24 0x00007f9c2e8dd837 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#25 0x00007f9c2e8ddcfe in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#26 0x00007f9c2e8de110 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#27 0x00007f9c2e8dbcff in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#28 0x00007f9c2e8e8061 in gst_pad_push_event () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#29 0x00007f9c2e02b56d in ?? () from /usr/lib/x86_64-linux-gnu/libgstbase-1.0.so.0</div><div>#30 0x00007f9c2e8dd837 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#31 0x00007f9c2e8ddcfe in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#32 0x00007f9c2e8de110 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#33 0x00007f9c2e8dbcff in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#34 0x00007f9c2e8e8061 in gst_pad_push_event () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#35 0x00007f9c2e8e81de in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#36 0x00007f9c2e8e3a7e in gst_pad_forward () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#37 0x00007f9c2e8e3bd3 in gst_pad_event_default () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#38 0x00007f9c2d985376 in gst_play_sink_convert_bin_sink_event (pad=0x212ed170, parent=0x2146ac60, event=0x21428960) at gstplaysinkconvertbin.c:260</div><div>#39 0x00007f9c2e8dd837 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#40 0x00007f9c2e8ddcfe in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#41 0x00007f9c2e8de110 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#42 0x00007f9c2e8dbcff in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#43 0x00007f9c2e8e8061 in gst_pad_push_event () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#44 0x00007f9c2c910d58 in ?? () from /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstcoreelements.so</div><div>#45 0x00007f9c2e912a21 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#46 0x00007f9c87affdce in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0</div><div>#47 0x00007f9c87aff3d5 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0</div><div>#48 0x00007f9d08468494 in start_thread (arg=0x7f9c2b2a3700) at pthread_create.c:333</div><div>#49 0x00007f9d08766aff in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97</div></div><div><br></div><div><div><br></div><div>Thread 3 (Thread 0x7f77c6454700 (LWP 66663)):</div><div>#0  syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38</div><div>#1  0x00007f779bd3587c in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0</div><div>#2  0x00007f779b1d578c in ?? () from /usr/lib/x86_64-linux-gnu/libgstbase-1.0.so.0</div><div>#3  0x00007f779c26872e in gst_element_change_state () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#4  0x00007f779c268e9f in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#5  0x00007f779c2471ad in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#6  0x00007f779c26872e in gst_element_change_state () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#7  0x00007f779c268e9f in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#8  0x00007f779c2471ad in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#9  0x00007f779990a138 in gst_play_sink_change_state (element=0xe620500, transition=GST_STATE_CHANGE_PLAYING_TO_PAUSED) at gstplaysink.c:4872</div><div>#10 0x00007f779c26872e in gst_element_change_state () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#11 0x00007f779c268e9f in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#12 0x00007f779c2471ad in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#13 0x00007f779c28c73a in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#14 0x00007f77998fb84f in gst_play_bin_change_state (element=0xe61bb10, transition=GST_STATE_CHANGE_PLAYING_TO_PAUSED) at gstplaybin2.c:5768</div><div>#15 0x00007f779c26872e in gst_element_change_state () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div><div>#16 0x00007f779c268e9f in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0</div></div><div>#17 0x00007f779c54a6c8 in (anonymous namespace)::changeElementState (element=0xe61bb10, newState=newState@entry=@0x7f77c64488b0: GST_STATE_NULL, timeToWait=5000000000)<br></div><div><my application specific trace></div><div><br></div><div><br></div><div>This used to work fine on Debian 8. However, on Debian 9 and Ubuntu 16.04 and higher which have Gstreamer versions 1.8 and higher, this happens.</div><div><br></div><div>My application is multi-threaded and below is a brief description:</div><div>Main Thread:</div><div>-> Creates playbin and appsink</div><div>-> Connects them</div><div>-> Runs the pipeline</div><div>-> Stop the pipeline either upon EOF or upon request</div><div><br></div><div>Thread 2:</div><div>--> Pulls samples from the appsink</div><div><br></div><div>I have confirmed that Thread 2 is completely shutdown when the Main thread is attempting to stop the pipeline i.e. there is no situation when I am attempting to change state in the middle of a call to gst_app_sink_pull_sample.</div><div><br></div><div>I attempted to use a pad probe which was recommended when wanting to play only a portion of a media file as per <a href="https://gstreamer.freedesktop.org/documentation/application-development/advanced/pipeline-manipulation.html">https://gstreamer.freedesktop.org/documentation/application-development/advanced/pipeline-manipulation.html</a></div><div><br></div><div>However, I do not believe that this will work for me because I do not know which portion of the media file is to be played in advance i.e. users can stop playback at anytime.</div><div><br></div><div>After I added the probe, I noticed that the frequency of the stalls reduced quite drastically i.e. from everytime to 1 in 500. My pad probe callback is as below:</div><div><br></div><div><div>// If the stopping of the playbin has not been initiated, </div><div>    // then allow the sample to pass through.</div><div>    if( !_isPlaybinToBeStopped )</div><div>    {</div><div>        return GST_PAD_PROBE_PASS;</div><div>    }</div><div><br></div><div>    BOOST_SCOPE_EXIT((&_isPlaybinToBeStopped))</div><div>    {</div><div>        _isPlaybinToBeStopped = false;</div><div>    }</div><div>    BOOST_SCOPE_EXIT_END</div><div><br></div><div>    // Remove the pad probe if the playbin is to be stopped.</div><div>    return GST_PAD_PROBE_REMOVE;</div></div><div><br></div><div>I really do not understand how adding this probe is really helping because it does no action other than pass through OR just remove the probe. Am I just getting lucky?</div><div><br></div><div>Any thoughts? As this happens only for Mp3 files, is this a bug?</div><div><br>Dinesh</div><div><br></div><div><br></div><div><br></div></div>