mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 07:47:17 +00:00
appsink: also clear preroll buffer in _pull_sample
If someone calls gst_app_sink_try_pull_sample they are probably no longer interested in any preroll samples. Useful if the user has not registered a preroll appsink callback. Also added unit test 'test_do_not_care_preroll' make elements/appsink.check that fails without this patch. https://bugzilla.gnome.org/show_bug.cgi?id=786740
This commit is contained in:
parent
68518acb53
commit
7b1056b946
2 changed files with 27 additions and 0 deletions
|
@ -1556,6 +1556,7 @@ gst_app_sink_try_pull_sample (GstAppSink * appsink, GstClockTime timeout)
|
|||
priv = appsink->priv;
|
||||
|
||||
g_mutex_lock (&priv->mutex);
|
||||
gst_buffer_replace (&priv->preroll_buffer, NULL);
|
||||
|
||||
while (TRUE) {
|
||||
GST_DEBUG_OBJECT (appsink, "trying to grab a buffer");
|
||||
|
|
|
@ -528,6 +528,31 @@ GST_START_TEST (test_pull_preroll)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_do_not_care_preroll)
|
||||
{
|
||||
GstElement *sink = NULL;
|
||||
GstBuffer *buffer = NULL;
|
||||
GstSample *pulled_sample = NULL;
|
||||
|
||||
sink = setup_appsink ();
|
||||
|
||||
ASSERT_SET_STATE (sink, GST_STATE_PLAYING, GST_STATE_CHANGE_ASYNC);
|
||||
|
||||
buffer = gst_buffer_new_and_alloc (4);
|
||||
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
|
||||
|
||||
pulled_sample = gst_app_sink_pull_sample (GST_APP_SINK (sink));
|
||||
fail_unless (pulled_sample);
|
||||
gst_sample_unref (pulled_sample);
|
||||
|
||||
fail_if (gst_app_sink_try_pull_preroll (GST_APP_SINK (sink), 0));
|
||||
|
||||
ASSERT_SET_STATE (sink, GST_STATE_NULL, GST_STATE_CHANGE_SUCCESS);
|
||||
cleanup_appsink (sink);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
static Suite *
|
||||
appsink_suite (void)
|
||||
{
|
||||
|
@ -546,6 +571,7 @@ appsink_suite (void)
|
|||
tcase_add_test (tc_chain, test_segment);
|
||||
tcase_add_test (tc_chain, test_pull_with_timeout);
|
||||
tcase_add_test (tc_chain, test_pull_preroll);
|
||||
tcase_add_test (tc_chain, test_do_not_care_preroll);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue