Commit graph

94 commits

Author SHA1 Message Date
Charlie Turner
96c6f581ae streamsynchronizer: avoid pad destruction races.
Due to the use of {set/get}-element_private methods being used to store
the GstSyncStream in the src and sink pads, and the racey nature of pad
destruction, there are numerous ways we can be bitten by race conditions
in the stream synchronizer. Fix that by tying the pads toghether with
references.
2019-09-24 20:09:09 +00:00
Edward Hervey
5efa8e1f89 streamsynchronizer: Properly propagate seqnum on EOS event 2018-06-05 17:29:53 +02:00
Haihua Hu
6749e81ce2 streamsynchronizer: every stream need keep their own send_gap_event flag
When a clip has video audio and subtitle, if need send gap event
to audio and subtitle, we should make sure all has been sent, so
need every stream keep one send_gap_event.

https://bugzilla.gnome.org/show_bug.cgi?id=780429
2017-03-23 12:55:57 +02:00
Sebastian Dröge
0c151f6bb2 streamsynchronizer: Correctly calculate group start times in reverse playback mode
We have to calculate from the segment.stop, not the segment.start, as
playback goes from stop to start. This fix works around another race
condition in streamsynchronizer in my testcase.

See https://bugzilla.gnome.org/show_bug.cgi?id=771479
2016-09-20 15:13:52 -04:00
Vineeth TM
44b70ca3a1 base: use new gst_element_class_add_static_pad_template()
https://bugzilla.gnome.org/show_bug.cgi?id=763075
2016-03-24 14:25:41 +02:00
Mathieu Duponchelle
2717f4a86f streamsynchronizer: Ignore flushing streams [..]
[..] when resetting group start time. In GES, we are usually connected
to the streamsynchronizer on one audio and one video pad.

When seeking the timeline, both nlecompositions often output their flush_start
before any of them has output its flush_stop.

The current code, when receiving the first flush stop was using the
running time of the start of the second composition, which could
be pretty much anything, and means nothing at that point.

This patch is thread-safe, as STREAM_SYNCHRONIZER_LOCK is taken
both when setting flushing and when checking it.

https://bugzilla.gnome.org/show_bug.cgi?id=750013
2016-01-16 11:05:13 +01:00
Edward Hervey
c79bf13bc2 streamsynchronizer: Rename GstStream => GstSyncStream
Avoid clashes with future GstStream from core
2015-12-02 16:37:41 +01:00
Song Bing
d2e942ac02 streamsynchronizer: Unblock EOS wait when track switching.
sink_event () will blocked on EOS event. which will cause can't
send event when switch EOS track to non-EOS one.

https://bugzilla.gnome.org/show_bug.cgi?id=750761
2015-06-23 15:28:49 +02:00
Sebastian Dröge
bd508a343f streamsynchronizer: Don't wait for sparse streams when doing stream switches
Their stream-start event might come a bit later, like just before the first
buffer... and queues might run full before that happens.
2015-06-22 20:54:18 +02:00
Sebastian Dröge
152534611d streamsynchronizer: Add some more debug output 2015-06-22 20:29:52 +02:00
Sebastian Dröge
203b635d0c streamsynchronizer: Reset group start time when flushing
We reset the group start time to the running time of the start of the other
streams that are not flushed. This fixes seeking in gapless mode after the
first track has played.

https://bugzilla.gnome.org/show_bug.cgi?id=750013
2015-06-22 20:17:56 +02:00
Sebastian Dröge
a73631a29d streamsynchronizer: Don't override segment.base from upstream with 0
Upstream might want to use it to properly map timestamps to running/stream
times, if we just override it with 0 synchronization will be just wrong.

For this we remove some old 0.10 code related to segment accumulation, and
remove some more code that is useless now, and accumulate the group start time
(aka segment.base offset) manually now.

https://bugzilla.gnome.org/show_bug.cgi?id=635701
2015-05-05 15:35:46 +02:00
Thiago Santos
b0b0ae1f24 streamsynchronizer: fix deadlock condition
The variables could have changed when the lock was released
to push a gap event. Streamsynchronizer needs to check them
again before going to sleep.

Bonus: fix a comment typo
2015-03-14 18:14:07 +00:00
Song Bing
7ce97c723c streamsynchronizer: Remove unnecessary ERROR message.
Remove unnecessary ERROR message.
Push GAP will fail as flushing. Needn't ERROR message.

https://bugzilla.gnome.org/show_bug.cgi?id=736655
2015-03-11 15:48:42 +00:00
Song Bing
fb9ca25f7f streamsynchronizer: Use the same waiting function for EOS and stream switches
Also improve the waiting condition for stream switches, which was assuming
before that the condition variable will only stop waiting once when it is
signaled. But the documentation says that there might be spurious wakeups.

https://bugzilla.gnome.org/show_bug.cgi?id=736655
2015-02-16 14:34:35 +02:00
Song Bing
2614f80309 streamsynchronizer: Send GAP events from the pads' streaming threads
Change the GAP events that are currently sent from the chain function of
the current pad to all other EOS pads. They should instead be sent from
their own streaming threads.

https://bugzilla.gnome.org/show_bug.cgi?id=736655
2015-02-16 14:12:28 +02:00
Song Bing
9f81931716 streamsynchronizer: Send GAP event to finish preroll when change state from PLAYING to PAUSED
Wait in the event function when EOS is received until all pads are EOS
and then forward the EOS event from each pads own event function.

Also send a new GAP event for EOS pads from the event function whenever
going from PLAYING->PAUSED by shortly waking up the GCond. This is needed
to allow sinks to pre-roll again, as they did not receive EOS yet because
we blocked that, but also will never get data again.

https://bugzilla.gnome.org/show_bug.cgi?id=736655
2015-02-16 14:09:43 +02:00
Mohammed Sameer
b34e0ba91c streamsynchronizer: don't unset DISCONT flag
Unsetting DISCONT flag means we need to copy the buffer. This copy operation
mandates that all GstMemory should be copy-able which is not always the case

https://bugzilla.gnome.org/show_bug.cgi?id=727409
2014-08-01 14:23:07 +02:00
Sebastian Dröge
b22f046cbc streamsynchronizer: Set proxy flags on the pads and use default event handler for simplicity
https://bugzilla.gnome.org//show_bug.cgi?id=705555
2013-08-12 13:02:15 +02:00
Edward Hervey
9dd0e6cccc ext/gst: Ensure default query/event handlers are used
And in some cases, just remove our implementation that does nothing
2013-07-26 16:08:35 +02:00
Sebastian Dröge
2465895266 streamsynchronizer: Implement grouping of streams via the group-id
https://bugzilla.gnome.org/show_bug.cgi?id=704427
https://bugzilla.gnome.org/show_bug.cgi?id=704408
2013-07-22 15:24:13 +02:00
Sebastian Dröge
043c1888f3 streamsynchronizer: Non-TIME segment streams are not waiting automatically
This was leftover code from porting to 1.0 and fixes the playbin
unit test.

https://bugzilla.gnome.org/show_bug.cgi?id=701943
2013-07-10 13:00:21 +02:00
Sebastian Dröge
9c5c0ca878 streamsynchronizer: Fix check for belonging to another stream
https://bugzilla.gnome.org/show_bug.cgi?id=697820
2013-04-24 11:11:41 +02:00
Sebastian Dröge
d77f76049e streamsynchronizer: Don't consider a stream added for an already running one as "new"
Fixes enabling visualizations after disabling them after they were enabled already.
2013-04-23 13:54:49 +02:00
Sebastian Dröge
2e017bd595 streamsynchronizer: If a stream belongs to an already running stream, don't wait
This fixes enabling visualizations after the audio stream already started.

https://bugzilla.gnome.org/show_bug.cgi?id=697820
2013-04-23 13:19:38 +02:00
Wim Taymans
34eea4d5f2 streamsynchronizer: update position for reverse
When doing reverse playback the positino advances from timestamp_end to
timestamp.
2013-03-31 12:57:35 +02:00
Tim-Philipp Müller
7c89a7298a streamsynchronizer: don't send gap events with huge bogus durations when advancing EOS streams
When the input buffers for a stream don't have a duration set,
timestamp_end might still be GST_CLOCK_TIME_NONE. When advancing
EOSed streams via GAP events (with other streams not yet EOS), we
would then use the invalid timestamp_end to calculate the duration
of the gap. This in turn would make baseaudiosink abort, because it
would try to allocate memory for a trizillion samples.

So if buffers don't have a duration set, assume a duration of
one second for stream catch-up purposes, just so we can still
continue to catch up in those cases. And make sure that
timestamp_end is valid before doing calculations with it.

http://bugzilla.gnome.org/show_bug.cgi?id=678530
2012-11-26 19:03:38 +00:00
Tim-Philipp Müller
601aabdf9c streamsynchronizer: reduce debug log spam a bit
Log locking/unlocking with TRACE debug level.
2012-11-25 18:07:04 +00:00
Sebastian Dröge
4f480612e9 streamsynchronizer: Make the element public
https://bugzilla.gnome.org/show_bug.cgi?id=688240
2012-11-21 10:29:44 +01:00
Tim-Philipp Müller
5f59b4f7ee Fix FSF address
https://bugzilla.gnome.org/show_bug.cgi?id=687520
2012-11-03 23:05:09 +00:00
Sebastian Dröge
b9d4d0cd29 streamsynchronizer: Also send a GAP event to let audio sinks start their clock in case they did not have enough data yet 2012-10-24 13:34:15 +02:00
Sebastian Dröge
6a31051feb streamsynchronizer: Use correct timestamp/duration for the GAP events 2012-10-24 13:29:45 +02:00
Sebastian Dröge
52d48109bc streamsynchronizer: Send GAP events to advance streams 2012-10-24 13:25:19 +02:00
Sebastian Dröge
7b12afa4cb streamsynchronizer: Create a GAP event with a sensible timestamp 2012-10-24 11:19:06 +02:00
Sebastian Dröge
356579157e streamsynchronizer: Also propagate return value of pushing GAP event upstream 2012-10-23 18:21:32 +02:00
Sebastian Dröge
120c7be970 streamsynchronizer: Return TRUE from the EOS handler 2012-10-23 17:38:43 +02:00
Tim-Philipp Müller
082cedef79 streamsynchronizer: don't shadow function parameter 2012-09-14 00:39:09 +01:00
Edward Hervey
b5090d2aca streamsynchronizer: Don't wait on non-time streams
streams with non-TIME segments will not have timestamps ...
... and therefore will never unblock the other streams.

Fixes blocking issue when using playbin suburi feature
2012-09-11 16:29:21 +02:00
Mark Nauwelaerts
782adaf3ab streamsynchronizer: do not leak EOS events 2012-09-06 15:03:49 +02:00
Wim Taymans
b26f35c3a4 streamsync: only remove DISCONT when needed
Check if the buffer is DISCONT before making a potentially expensive copy to
unset the DISCONT flag.
2012-09-06 13:37:11 +02:00
Mark Nauwelaerts
d3a0269695 streamsynchronizer: use GAP event to trigger preroll
... rather than an empty buffer
2012-09-05 16:59:12 +02:00
Wim Taymans
f3158569c6 streamsync: unblock gcond on flush-stop
See https://bugzilla.gnome.org/show_bug.cgi?id=680441
2012-09-04 11:09:50 +02:00
Edward Hervey
d86f6132ed streamsynchronizer: Handle stream switching
* Update outgoing segment.base with accumulated time, ensuring all
  streams are synchronized.
* Only consider streams as "new" is they have a STREAM_START event
  with a different seqnum.
* Use GstStream segment.base instead of separate variable to store
  the past running time.
* Disable passthrough
* Switch to glib 2.32 GMutex/GCond
* Avoid getting pad parent the expensive way
* Minor other fixes
2012-08-14 18:56:30 +02:00
Sebastian Dröge
628bc44ca5 streamsynchronizer: Unblock streams on FLUSH_START events 2012-07-27 12:59:20 +02:00
Edward Hervey
f72f4c09c9 streamsynchronizer: Re-enable stream update
Not 100% perfect yet, but allows people to test
2012-07-19 16:12:22 +02:00
Edward Hervey
a0fbf92d43 playback: Remove custom stream-change event
Applications can now use the STREAM_START message to know if a new
stream has started
2012-07-12 09:51:35 +02:00
Tim-Philipp Müller
3c6a3ad629 Use new gst_element_class_set_static_metadata() 2012-04-10 00:45:16 +01:00
Sebastian Dröge
68c0790817 Merge branch 'master' into 0.11
Conflicts:
	gst-libs/gst/interfaces/propertyprobe.c
	sys/xvimage/xvimagesink.c
2012-01-25 11:50:54 +01:00
Mark Nauwelaerts
71f70c98ef streamsynchronizer: avoid unlikely NULL dereference 2012-01-19 16:43:40 +01:00
Wim Taymans
3d42f0f6ed port to new glib thread API 2012-01-19 11:36:17 +01:00