After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 585969 - playbin: Position/Duration information mismatch on track change
playbin: Position/Duration information mismatch on track change
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
0.10.23
Other All
: Normal minor
: 1.1.3
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on: 584987 679544
Blocks:
 
 
Reported: 2009-06-16 11:09 UTC by Christopher Halse Rogers
Modified: 2013-07-12 07:56 UTC
See Also:
GNOME target: ---
GNOME version: 2.27/2.28


Attachments
playbin2: Don't handle DURATION queries during group switches (3.87 KB, patch)
2009-11-15 18:45 UTC, Sebastian Dröge (slomo)
rejected Details | Review
playbin2: Don't handle DURATION queries during group switches (6.73 KB, patch)
2009-11-18 08:25 UTC, Sebastian Dröge (slomo)
committed Details | Review
playbin2: Don't handle DURATION queries during group switches (via stream_start) (3.19 KB, patch)
2013-07-04 19:47 UTC, Alban Browaeys
needs-work Details | Review
playbin2: Don't handle DURATION queries during group switches (via stream_start) v2 (3.79 KB, patch)
2013-07-11 13:36 UTC, Alban Browaeys
committed Details | Review

Description Christopher Halse Rogers 2009-06-16 11:09:41 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:
Comment 1 Andy Owen 2009-11-14 06:14:35 UTC
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)
Comment 2 Andy Owen 2009-11-14 06:17:54 UTC
Hmm, I should have searched a bit harder, and I would have found:

https://bugzilla.gnome.org/show_bug.cgi?id=584987
Comment 3 Sebastian Dröge (slomo) 2009-11-15 18:45:44 UTC
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.
Comment 4 Sebastian Dröge (slomo) 2009-11-17 14:25:36 UTC
There's a better solution... patch coming soon ;)
Comment 5 Sebastian Dröge (slomo) 2009-11-18 08:25:06 UTC
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.
Comment 6 Sebastian Dröge (slomo) 2009-11-18 15:40:10 UTC
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.
Comment 7 Sebastian Dröge (slomo) 2009-11-19 11:21:37 UTC
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
[...]
Comment 8 Sebastian Dröge (slomo) 2009-11-19 15:51:16 UTC
That actually seems to be caused by f83ea8233bf1661bdab0d4ec6f08169d7c664452 in gstreamer core. Closing this one again...
Comment 9 Alban Browaeys 2013-07-04 19:47:37 UTC
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.
Comment 10 Sebastian Dröge (slomo) 2013-07-05 08:35:48 UTC
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?
Comment 11 Alban Browaeys 2013-07-11 13:36:51 UTC
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 )
Comment 12 Sebastian Dröge (slomo) 2013-07-12 07:55:34 UTC
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