mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
0be07e1d86
commit
15581f2209
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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--;
|
||||
|
|
Loading…
Reference in New Issue