summaryrefslogtreecommitdiffstats
path: root/mpvcore
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-08-19 00:50:39 +0200
committerwm4 <wm4@nowhere>2013-08-19 01:05:49 +0200
commit4579cce768d0c9c84dc5f318b7189ffb03b49ece (patch)
tree86ddbbbeb92e4e0c78e72d9d393c27c91dcc9580 /mpvcore
parent2508f38a92f8863cfc156b2b7310512863db7d4e (diff)
downloadmpv-4579cce768d0c9c84dc5f318b7189ffb03b49ece.tar.bz2
mpv-4579cce768d0c9c84dc5f318b7189ffb03b49ece.tar.xz
mplayer: reshuffle on every loop if --loop and --shuffle are used
See github issue #194. Unfortunately, this breaks the property that going back in the playlist always works as expected. This changes, because the playlist_prev command will work on the reshuffled playlist, instead of loading the previously played files in order. If this ever becomes an issue, I might revert this commit.
Diffstat (limited to 'mpvcore')
-rw-r--r--mpvcore/mplayer.c4
-rw-r--r--mpvcore/options.c3
-rw-r--r--mpvcore/options.h1
-rw-r--r--mpvcore/parser-mpcmd.c22
4 files changed, 7 insertions, 23 deletions
diff --git a/mpvcore/mplayer.c b/mpvcore/mplayer.c
index ab8ebe3968..fe1d18740b 100644
--- a/mpvcore/mplayer.c
+++ b/mpvcore/mplayer.c
@@ -4473,6 +4473,8 @@ struct playlist_entry *mp_next_file(struct MPContext *mpctx, int direction)
struct playlist_entry *next = playlist_get_next(mpctx->playlist, direction);
if (!next && mpctx->opts->loop_times >= 0) {
if (direction > 0) {
+ if (mpctx->opts->shuffle)
+ playlist_shuffle(mpctx->playlist);
next = mpctx->playlist->first;
if (next && mpctx->opts->loop_times > 0) {
mpctx->opts->loop_times--;
@@ -4733,6 +4735,8 @@ static int mpv_main(int argc, char *argv[])
mpctx->osd = osd_create(opts, mpctx->ass_library);
+ if (opts->shuffle)
+ playlist_shuffle(mpctx->playlist);
mpctx->playlist->current = mpctx->playlist->first;
play_files(mpctx);
diff --git a/mpvcore/options.c b/mpvcore/options.c
index 4a3c067404..727a3313df 100644
--- a/mpvcore/options.c
+++ b/mpvcore/options.c
@@ -322,7 +322,6 @@ const m_option_t mp_opts[] = {
// handled in command line parser (parser-mpcmd.c)
{"playlist", NULL, CONF_TYPE_STRING, CONF_NOCFG | M_OPT_MIN, 1, 0, NULL},
- {"shuffle", NULL, CONF_TYPE_FLAG, CONF_NOCFG, 0, 0, NULL},
{"{", NULL, CONF_TYPE_STORE, CONF_NOCFG, 0, 0, NULL},
{"}", NULL, CONF_TYPE_STORE, CONF_NOCFG, 0, 0, NULL},
@@ -335,6 +334,8 @@ const m_option_t mp_opts[] = {
// handled in mplayer.c (looks at the raw argv[])
{"leak-report", "", CONF_TYPE_STORE, CONF_GLOBAL | CONF_NOCFG },
+ OPT_FLAG("shuffle", shuffle, CONF_GLOBAL | CONF_NOCFG),
+
// ------------------------- common options --------------------
OPT_FLAG("quiet", quiet, CONF_GLOBAL),
{"really-quiet", &verbose, CONF_TYPE_STORE, CONF_GLOBAL|CONF_PRE_PARSE, 0, -10, NULL},
diff --git a/mpvcore/options.h b/mpvcore/options.h
index 9309cc1a85..8487c84cc5 100644
--- a/mpvcore/options.h
+++ b/mpvcore/options.h
@@ -81,6 +81,7 @@ typedef struct MPOpts {
char *stream_capture;
char *stream_dump;
int loop_times;
+ int shuffle;
int ordered_chapters;
int chapter_merge_threshold;
double chapter_seek_threshold;
diff --git a/mpvcore/parser-mpcmd.c b/mpvcore/parser-mpcmd.c
index 9b9d175cf7..55615d950e 100644
--- a/mpvcore/parser-mpcmd.c
+++ b/mpvcore/parser-mpcmd.c
@@ -110,14 +110,6 @@ static bool split_opt(struct parse_state *p)
return false;
}
-static bool parse_flag(bstr name, bstr f)
-{
- struct m_option opt = {NULL, NULL, CONF_TYPE_FLAG, 0, 0, 1, NULL};
- int val = 0;
- m_option_parse(&opt, name, f, &val);
- return !!val;
-}
-
// returns M_OPT_... error code
int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files,
int argc, char **argv)
@@ -125,7 +117,6 @@ int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files,
int ret = M_OPT_UNKNOWN;
int mode = 0;
struct playlist_entry *local_start = NULL;
- bool shuffle = false;
int local_params_count = 0;
struct playlist_param *local_params = 0;
@@ -190,16 +181,6 @@ int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files,
mode = GLOBAL;
m_config_restore_backups(config);
local_start = NULL;
- shuffle = false;
- continue;
- }
-
- if (bstrcmp0(p.arg, "shuffle") == 0) {
- shuffle = parse_flag(p.arg, p.param);
- continue;
- }
- if (bstrcmp0(p.arg, "no-shuffle") == 0) {
- shuffle = false;
continue;
}
@@ -274,9 +255,6 @@ int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files,
goto err_out;
}
- if (shuffle)
- playlist_shuffle(files);
-
ret = 0; // success
err_out: