From: <wt...@ke...> - 2006-06-01 20:27:24
|
CVS Root: /cvs/gstreamer Module: gstreamer Changes by: wtay Date: Thu Jun 01 2006 09:02:35 UTC Log message: Patch by: Alessandro Decina <alessandro at nnva dot org> * libs/gst/base/gstcollectpads.c: (gst_collect_pads_stop): Make sure the EOS flag is cleared from pads after a flush or stop. Fixes #343538. * tests/check/libs/collectpads.c: (GST_START_TEST), (gst_collect_pads_suite): Added test for collectpads reusage after EOS. Modified files: . : ChangeLog libs/gst/base : gstcollectpads.c tests/check/libs: collectpads.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/ChangeLog.diff?r1=1.2560&r2=1.2561 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/libs/gst/base/gstcollectpads.c.diff?r1=1.39&r2=1.40 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/tests/check/libs/collectpads.c.diff?r1=1.1&r2=1.2 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gstreamer/ChangeLog,v retrieving revision 1.2560 retrieving revision 1.2561 diff -u -d -r1.2560 -r1.2561 --- ChangeLog 30 May 2006 20:25:03 -0000 1.2560 +++ ChangeLog 1 Jun 2006 09:02:23 -0000 1.2561 @@ -1,3 +1,15 @@ +2006-06-01 Wim Taymans <wi...@fl...> + + Patch by: Alessandro Decina <alessandro at nnva dot org> + * libs/gst/base/gstcollectpads.c: (gst_collect_pads_stop): + Make sure the EOS flag is cleared from pads after a flush + or stop. Fixes #343538. + * tests/check/libs/collectpads.c: (GST_START_TEST), + (gst_collect_pads_suite): + Added test for collectpads reusage after EOS. 2006-05-30 Sebastien Moutte <seb...@mo...> * gst/gst.c: Index: gstcollectpads.c RCS file: /cvs/gstreamer/gstreamer/libs/gst/base/gstcollectpads.c,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- gstcollectpads.c 30 May 2006 15:55:19 -0000 1.39 +++ gstcollectpads.c 1 Jun 2006 09:02:23 -0000 1.40 @@ -515,6 +515,8 @@ /* Stop collect pads */ pads->started = FALSE; + pads->eospads = 0; + pads->queuedpads = 0; /* loop over the master pad list and flush buffers */ collected = pads->abidata.ABI.pad_list; @@ -527,9 +529,8 @@ buffer_p = &data->buffer; gst_buffer_replace (buffer_p, NULL); data->pos = 0; - /* one less pad with queued data now */ - pads->queuedpads--; } + data->abidata.ABI.eos = FALSE; } GST_COLLECT_PADS_PAD_UNLOCK (pads); Index: collectpads.c RCS file: /cvs/gstreamer/gstreamer/tests/check/libs/collectpads.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- collectpads.c 30 May 2006 09:42:09 -0000 1.1 +++ collectpads.c 1 Jun 2006 09:02:23 -0000 1.2 @@ -24,6 +24,15 @@ #include <gst/check/gstcheck.h> #include <gst/base/gstcollectpads.h> +#define fail_unless_collected(expected) \ +G_STMT_START { \ + g_mutex_lock (lock); \ + while (expected == TRUE && collected == FALSE) \ + g_cond_wait (cond, lock); \ + fail_unless_equals_int (collected, expected); \ + g_mutex_unlock (lock); \ +} G_STMT_END; typedef struct { char foo; @@ -157,18 +166,14 @@ data1->buffer = buf1; thread1 = g_thread_create (push_buffer, data1, TRUE, NULL); /* here thread1 is blocked and srcpad1 has a queued buffer */ - fail_unless (collected == FALSE); + fail_unless_collected (FALSE); data2->pad = srcpad2; data2->buffer = buf2; thread2 = g_thread_create (push_buffer, data2, TRUE, NULL); /* now both pads have a buffer */ - g_mutex_lock (lock); - while (collected == FALSE) - g_cond_wait (cond, lock); - fail_unless (collected == TRUE); - g_mutex_unlock (lock); + fail_unless_collected (TRUE); tmp = gst_collect_pads_pop (collect, (GstCollectData *) data1); fail_unless (tmp == buf1); @@ -211,17 +216,13 @@ data2->event = gst_event_new_eos (); thread2 = g_thread_create (push_event, data2, TRUE, NULL); /* now sinkpad1 has a buffer and sinkpad2 has EOS */ @@ -241,6 +242,91 @@ GST_END_TEST; +GST_START_TEST (test_collect_twice) +{ + GstBuffer *buf1, *buf2, *tmp; + GThread *thread1, *thread2; + data1 = (TestData *) gst_collect_pads_add_pad (collect, + sinkpad1, sizeof (TestData)); + fail_unless (data1 != NULL); + data2 = (TestData *) gst_collect_pads_add_pad (collect, + sinkpad2, sizeof (TestData)); + fail_unless (data2 != NULL); + buf1 = gst_buffer_new (); + /* start collect pads */ + gst_collect_pads_start (collect); + /* queue a buffer */ + data1->pad = srcpad1; + data1->buffer = buf1; + thread1 = g_thread_create (push_buffer, data1, TRUE, NULL); + /* here thread1 is blocked and srcpad1 has a queued buffer */ + /* push EOS on the other pad */ + data2->pad = srcpad2; + data2->event = gst_event_new_eos (); + thread2 = g_thread_create (push_event, data2, TRUE, NULL); + /* one of the pads has a buffer, the other has EOS */ + tmp = gst_collect_pads_pop (collect, (GstCollectData *) data1); + fail_unless (tmp == buf1); + /* there's nothing to pop from the one which received EOS */ + tmp = gst_collect_pads_pop (collect, (GstCollectData *) data2); + fail_unless (tmp == NULL); + /* these will return immediately as at this point the threads have been + * unlocked and are finished */ + g_thread_join (thread1); + g_thread_join (thread2); + gst_collect_pads_stop (collect); + collected = FALSE; + buf2 = gst_buffer_new (); + /* push buffers on the pads */ + data2->buffer = buf2; + thread2 = g_thread_create (push_buffer, data2, TRUE, NULL); + /* now both pads have a buffer */ + fail_unless (tmp == buf2); + gst_buffer_unref (buf1); + gst_buffer_unref (buf2); +} +GST_END_TEST; static Suite * gst_collect_pads_suite () @@ -254,6 +340,7 @@ tcase_add_test (general, test_pad_add_remove); tcase_add_test (general, test_collect); tcase_add_test (general, test_collect_eos); + tcase_add_test (general, test_collect_twice); return suite; } |