GNOME Bugzilla – Bug 585969
playbin: Position/Duration information mismatch on track change
Last modified: 2013-07-12 07:56:18 UTC
Please describe the problem: When using playbin2 for gapless playback and it is transitioning to another track, there's a period where the duration & position information don't match. Apparently, this is because the duration is being reported for the URI that's being decoded, but the position is being reported from the audiosink's buffers. It'd be nice if the duration reported always corresponded to the URI whose samples are still playing on the audio hardware. Steps to reproduce: Actual results: Expected results: Does this happen every time? Other information:
It would also be useful if there was a signal emitted when the track changes. See: https://bugzilla.gnome.org/show_bug.cgi?id=601524 For an example of where it would be handy (rhythmbox bug)
Hmm, I should have searched a bit harder, and I would have found: https://bugzilla.gnome.org/show_bug.cgi?id=584987
Created attachment 147809 [details] [review] playbin2: Don't handle DURATION queries during group switches During a group switch we shouldn't allow duration queries because it's not clear if the old or new group's duration is returned and if the sinks are already playing new data or old data. See bug #585969.
There's a better solution... patch coming soon ;)
Created attachment 148026 [details] [review] playbin2: Don't handle DURATION queries during group switches During a group switch return the cached duration of the old group because the old group still didn't finish playback. If we have no cached duration return FALSE. See bug #585969.
This now will return the old duration until the old track finished playback. From there on it will report the new duration. commit 922445abd31901da1dad1d7359637d490cb63247 Author: Sebastian Dröge <sebastian.droege@collabora.co.uk> Date: Wed Nov 18 09:22:39 2009 +0100 playbin2: Don't handle DURATION queries during group switches During a group switch return the cached duration of the old group because the old group still didn't finish playback. If we have no cached duration return FALSE. Fixes bug #585969.
Actually I can still reproduce this with latest GIT on some files... output of test7 on two wavpack files: [...] 0:00:04.913886000 / 0:00:06.965986394 0:00:05.412122000 / 0:00:06.965986394 0:00:01.000000000 / 0:00:05.804988662 0:00:00.420986000 / 0:00:05.804988662 0:00:00.921070000 / 0:00:05.804988662 [...]
That actually seems to be caused by f83ea8233bf1661bdab0d4ec6f08169d7c664452 in gstreamer core. Closing this one again...
Created attachment 248409 [details] [review] playbin2: Don't handle DURATION queries during group switches (via stream_start) With commit a0fbf92d43e81452b6cce09ee20d9a8cc4af7b06 group->stream_changed_pending is always null. This broke the previous fix for bug 585969 ([gapless] Position/Duration information mismatch on track change). This reuses both patch in the bugzilla and uses the stream_start message to get close to the switch complete state.
Review of attachment 248409 [details] [review]: Looks good in general ::: gst/playback/gstplaybin2.c @@ -2624,3 @@ if (group->stream_changed_pending_lock.p) { g_mutex_lock (&group->stream_changed_pending_lock); - pending = group->pending || group->stream_changed_pending; Please remove the old stream_changed_pending or reuse it for your uses instead of adding a new field. The old stream_changed_pending is not used anywhere anymore. @@ +3487,3 @@ /* now activate the next group. If the app did not set a uri, this will * fail and we can do EOS */ + setup_next_source (playbin, GST_STATE_PLAYING); Why?
Created attachment 248926 [details] [review] playbin2: Don't handle DURATION queries during group switches (via stream_start) v2 thanks for the review (the playing change was a leftover from a test that I forgot to remove )
commit f174c450c9e6ed2fcbddf0d352016db9e523efaa Author: Alban Browaeys <prahal@yahoo.com> Date: Mon Jul 8 23:49:39 2013 +0200 playbin: Fix logic to detect if a stream-change is currently pending Fixes duration reporting in gapless playback between files. https://bugzilla.gnome.org/show_bug.cgi?id=585969