Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Steve Lhomme
VLC
Commits
c453158b
Commit
c453158b
authored
Sep 15, 2005
by
Clément Stenac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve random behaviour - Patch by Daniel Straenger. Thanks !
parent
2755833f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
15 deletions
+23
-15
src/playlist/playlist.c
src/playlist/playlist.c
+23
-15
No files found.
src/playlist/playlist.c
View file @
c453158b
...
...
@@ -899,28 +899,36 @@ static playlist_item_t * NextItem( playlist_t *p_playlist )
(
p_playlist
->
request
.
b_request
&&
(
p_playlist
->
request
.
p_item
==
NULL
||
p_playlist
->
request
.
i_skip
==
1
||
p_playlist
->
request
.
i_skip
==
-
1
)
)
)
)
{
srand
(
(
unsigned
int
)
mdate
()
);
i_
new
=
0
;
for
(
i
_count
=
0
;
i
_count
<
p_playlist
->
i_size
-
1
;
i_count
++
)
/* how many items to choose from ? */
i_
count
=
0
;
for
(
i
=
0
;
i
<
p_playlist
->
i_size
;
i
++
)
{
i_new
=
(
int
)((
float
)
p_playlist
->
i_size
*
rand
()
/
(
RAND_MAX
+
1
.
0
));
/* Check if the item has not already been played */
if
(
p_playlist
->
pp_items
[
i_new
]
->
i_nb_played
==
0
)
break
;
if
(
p_playlist
->
pp_items
[
i
]
->
i_nb_played
==
0
)
i_count
++
;
}
if
(
i_count
==
p_playlist
->
i_size
)
/* Nothing left? */
if
(
i_count
==
0
)
{
/* The whole playlist has been played: reset the counters */
while
(
i_count
>
0
)
{
p_playlist
->
pp_items
[
--
i_count
]
->
i_nb_played
=
0
;
}
/* Don't loop? Exit! */
if
(
!
b_loop
)
{
return
NULL
;
/* Otherwise reset the counter */
for
(
i
=
0
;
i
<
p_playlist
->
i_size
;
i
++
)
{
p_playlist
->
pp_items
[
i
]
->
i_nb_played
=
0
;
}
i_count
=
p_playlist
->
i_size
;
}
srand
(
(
unsigned
int
)
mdate
()
);
i
=
rand
()
%
i_count
+
1
;
/* loop thru the list and count down the unplayed items to the selected one */
for
(
i_new
=
0
;
i_new
<
p_playlist
->
i_size
&&
i
>
0
;
i_new
++
)
{
if
(
p_playlist
->
pp_items
[
i_new
]
->
i_nb_played
==
0
)
i
--
;
}
i_new
--
;
p_playlist
->
request
.
i_skip
=
0
;
p_playlist
->
request
.
b_request
=
VLC_FALSE
;
return
p_playlist
->
pp_items
[
i_new
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment