aboutsummaryrefslogtreecommitdiffhomepage
path: root/player
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2015-07-08 21:31:31 +0200
committerGravatar wm4 <wm4@nowhere>2015-07-08 21:31:31 +0200
commit15581f2209898bdd1747d4a32f57a00ba5098fdd (patch)
tree6462bf49695bb931d726a0937ad4c974d2006e05 /player
parent0be07e1d86c4817a3889196de1ae59ae7130fc35 (diff)
player: never overwrite stop_play field
This is a real pain: if a quit command is received, it's set to PT_QUIT. And then other code could overwrite it, making it not quit. The annoying bit is that stop_play is written and read in many places. Just not overwriting it unconditionally seems to be the best course of action.
Diffstat (limited to 'player')
-rw-r--r--player/command.c18
-rw-r--r--player/loadfile.c6
-rw-r--r--player/misc.c3
-rw-r--r--player/playloop.c5
-rw-r--r--player/video.c2
5 files changed, 21 insertions, 13 deletions
diff --git a/player/command.c b/player/command.c
index 9e6063ff85..fb06cf1b33 100644
--- a/player/command.c
+++ b/player/command.c
@@ -678,7 +678,8 @@ static int mp_property_disc_title(void *ctx, struct m_property *prop,
title = *(int*)arg;
if (demux_stream_control(d, STREAM_CTRL_SET_CURRENT_TITLE, &title) < 0)
return M_PROPERTY_NOT_IMPLEMENTED;
- mpctx->stop_play = PT_RELOAD_FILE;
+ if (!mpctx->stop_play)
+ mpctx->stop_play = PT_RELOAD_FILE;
return M_PROPERTY_OK;
}
return M_PROPERTY_NOT_IMPLEMENTED;
@@ -757,7 +758,8 @@ static int mp_property_chapter(void *ctx, struct m_property *prop,
if (mpctx->opts->keep_open) {
seek_to_last_frame(mpctx);
} else {
- mpctx->stop_play = PT_NEXT_ENTRY;
+ if (!mpctx->stop_play)
+ mpctx->stop_play = PT_NEXT_ENTRY;
}
} else {
mp_seek_chapter(mpctx, chapter);
@@ -837,7 +839,8 @@ static int mp_property_edition(void *ctx, struct m_property *prop,
edition = *(int *)arg;
if (edition != demuxer->edition) {
opts->edition_id = edition;
- mpctx->stop_play = PT_RELOAD_FILE;
+ if (!mpctx->stop_play)
+ mpctx->stop_play = PT_RELOAD_FILE;
}
return M_PROPERTY_OK;
}
@@ -2846,7 +2849,7 @@ static int mp_property_dvb_channel(void *ctx, struct m_property *prop,
case M_PROPERTY_SET:
mpctx->last_dvb_step = 1;
r = prop_stream_ctrl(mpctx, STREAM_CTRL_DVB_SET_CHANNEL, arg);
- if (r == M_PROPERTY_OK)
+ if (r == M_PROPERTY_OK && !mpctx->stop_play)
mpctx->stop_play = PT_RELOAD_FILE;
return r;
case M_PROPERTY_SWITCH: {
@@ -2854,7 +2857,7 @@ static int mp_property_dvb_channel(void *ctx, struct m_property *prop,
int dir = sa->inc >= 0 ? 1 : -1;
mpctx->last_dvb_step = dir;
r = prop_stream_ctrl(mpctx, STREAM_CTRL_DVB_STEP_CHANNEL, &dir);
- if (r == M_PROPERTY_OK)
+ if (r == M_PROPERTY_OK && !mpctx->stop_play)
mpctx->stop_play = PT_RELOAD_FILE;
return r;
}
@@ -4509,7 +4512,7 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
if (!e)
return -1;
// Can't play a removed entry
- if (mpctx->playlist->current == e)
+ if (mpctx->playlist->current == e && !mpctx->stop_play)
mpctx->stop_play = PT_CURRENT_ENTRY;
playlist_remove(mpctx->playlist, e);
mp_notify_property(mpctx, "playlist");
@@ -4535,7 +4538,8 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
case MP_CMD_STOP:
playlist_clear(mpctx->playlist);
- mpctx->stop_play = PT_STOP;
+ if (!mpctx->stop_play)
+ mpctx->stop_play = PT_STOP;
break;
case MP_CMD_SHOW_PROGRESS:
diff --git a/player/loadfile.c b/player/loadfile.c
index 3b972f5ffc..dfcb4a547e 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -1207,7 +1207,8 @@ reopen_file:
MP_VERBOSE(mpctx, "Starting playback...\n");
if (mpctx->max_frames == 0) {
- mpctx->stop_play = PT_NEXT_ENTRY;
+ if (!mpctx->stop_play)
+ mpctx->stop_play = PT_NEXT_ENTRY;
mpctx->error_playing = 0;
goto terminate_playback;
}
@@ -1415,5 +1416,6 @@ void mp_set_playlist_entry(struct MPContext *mpctx, struct playlist_entry *e)
assert(!e || playlist_entry_to_index(mpctx->playlist, e) >= 0);
mpctx->playlist->current = e;
mpctx->playlist->current_was_replaced = false;
- mpctx->stop_play = PT_CURRENT_ENTRY;
+ if (!mpctx->stop_play)
+ mpctx->stop_play = PT_CURRENT_ENTRY;
}
diff --git a/player/misc.c b/player/misc.c
index 613b475365..3d54d36ff7 100644
--- a/player/misc.c
+++ b/player/misc.c
@@ -192,7 +192,8 @@ void error_on_track(struct MPContext *mpctx, struct track *track)
(!mpctx->current_track[0][STREAM_AUDIO] &&
!mpctx->current_track[0][STREAM_VIDEO]))
{
- mpctx->stop_play = PT_ERROR;
+ if (!mpctx->stop_play)
+ mpctx->stop_play = PT_ERROR;
if (mpctx->error_playing >= 0)
mpctx->error_playing = MPV_ERROR_NOTHING_TO_PLAY;
}
diff --git a/player/playloop.c b/player/playloop.c
index 65bdf54252..9cf19630b2 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -798,7 +798,7 @@ static void handle_sstep(struct MPContext *mpctx)
}
if (mpctx->video_status >= STATUS_EOF) {
- if (mpctx->max_frames >= 0)
+ if (mpctx->max_frames >= 0 && !mpctx->stop_play)
mpctx->stop_play = AT_END_OF_FILE; // force EOF even if audio left
if (mpctx->step_frames > 0 && !mpctx->paused)
pause_player(mpctx);
@@ -991,7 +991,8 @@ static void handle_segment_switch(struct MPContext *mpctx, bool end_is_new_segme
.amount = mpctx->timeline[new_part].start
}, true);
} else {
- mpctx->stop_play = AT_END_OF_FILE;
+ if (!mpctx->stop_play)
+ mpctx->stop_play = AT_END_OF_FILE;
}
}
}
diff --git a/player/video.c b/player/video.c
index 87e6a8fb60..ccdac3b042 100644
--- a/player/video.c
+++ b/player/video.c
@@ -926,7 +926,7 @@ void write_video(struct MPContext *mpctx, double endpts)
if (!mpctx->step_frames && !opts->pause)
pause_player(mpctx);
}
- if (mpctx->max_frames == 0)
+ if (mpctx->max_frames == 0 && !mpctx->stop_play)
mpctx->stop_play = AT_END_OF_FILE;
if (mpctx->max_frames > 0)
mpctx->max_frames--;