[vlc-devel] random play does not work as expected
vlc at schmaller.de
Tue Sep 13 23:38:12 CEST 2005
The random function as implemented does not work correctly.
Let's assume we have a playlist with 3 items and the first and second
one has been played. thus the loop runs 2 (p_playlist->i_size-1) cycles.
now it's not improbable, that only played items (1st and 2nd) are
randomly chosen both times.
Then the counters are reset, although not every item has been played.
In my patched code, the next item is only chosen from the ones which
have not been played. An extra loop over all items is needed to count
the unplayed items. I know, there are several other solutions:
* building a ring (continue at the first after the last) of the
playlist and return the 'rand(size)'th unplayed object
* choose a random start point in the playlist and return the next
* keep a list of the unplayed items and return a random element of the
I've decided for my solution as it returns the best results, doesn't
need more memory and has a passable higher cpu consumption.
PS: does anybody know about the status of my last
patch (m3u_AllInOne_parsing). I didn't receive any feedback :-(
PPS: the patch also includes extra highlighting for the current playlist
item in wxWidgets interface, because there's hardly a difference between
font(normal) and font(bold) in my environment.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the vlc-devel