Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-gpu
Commits
8d00d8b7
Commit
8d00d8b7
authored
Mar 06, 2010
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playlist: randomize in a thread-safe manner
parent
f3096f3f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
4 deletions
+5
-4
src/playlist/sort.c
src/playlist/sort.c
+2
-1
src/playlist/thread.c
src/playlist/thread.c
+3
-3
No files found.
src/playlist/sort.c
View file @
8d00d8b7
...
...
@@ -27,6 +27,7 @@
#endif
#include <vlc_common.h>
#include <vlc_rand.h>
#define VLC_INTERNAL_PLAYLIST_SORT_FUNCTIONS
#include "vlc_playlist.h"
#include "playlist_internal.h"
...
...
@@ -146,7 +147,7 @@ void playlist_ItemArraySort( unsigned i_items, playlist_item_t **pp_items,
for
(
i_position
=
i_items
-
1
;
i_position
>
0
;
i_position
--
)
{
i_new
=
rand
(
)
%
(
i_position
+
1
);
i_new
=
((
unsigned
)
vlc_mrand48
()
)
%
(
i_position
+
1
);
p_temp
=
pp_items
[
i_position
];
pp_items
[
i_position
]
=
pp_items
[
i_new
];
pp_items
[
i_new
]
=
p_temp
;
...
...
src/playlist/thread.c
View file @
8d00d8b7
...
...
@@ -32,6 +32,7 @@
#include <vlc_input.h>
#include <vlc_interface.h>
#include <vlc_playlist.h>
#include <vlc_rand.h>
#include "stream_output/stream_output.h"
#include "playlist_internal.h"
...
...
@@ -189,10 +190,9 @@ static void ResetCurrentlyPlaying( playlist_t *p_playlist,
if
(
var_GetBool
(
p_playlist
,
"random"
)
)
{
/* Shuffle the array */
srand
(
(
unsigned
int
)
mdate
()
);
for
(
int
j
=
p_playlist
->
current
.
i_size
-
1
;
j
>
0
;
j
--
)
for
(
unsigned
j
=
p_playlist
->
current
.
i_size
-
1
;
j
>
0
;
j
--
)
{
int
i
=
rand
(
)
%
(
j
+
1
);
/* between 0 and j */
unsigned
i
=
((
unsigned
)
vlc_mrand48
()
)
%
(
j
+
1
);
/* between 0 and j */
playlist_item_t
*
p_tmp
;
/* swap the two items */
p_tmp
=
ARRAY_VAL
(
p_playlist
->
current
,
i
);
...
...
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