summaryrefslogtreecommitdiffstats
path: root/core/mplayer.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-04-25 19:07:47 +0200
committerwm4 <wm4@nowhere>2013-04-25 20:49:23 +0200
commite1fccfdcd8a9efb2e3ce70cc4b7aba3e0eb91836 (patch)
tree645d3e1c5cf8df4113eb1942c4c3337547a18d01 /core/mplayer.c
parent848542a513b27ae9b2d573b626e06bd96a99ca1d (diff)
downloadmpv-e1fccfdcd8a9efb2e3ce70cc4b7aba3e0eb91836.tar.bz2
mpv-e1fccfdcd8a9efb2e3ce70cc4b7aba3e0eb91836.tar.xz
core: don't let cache pause handling and user pausing conflict
The core pauses and unpauses automatically to wait for the network cache (also known as buffering). This conflicted with user pause control, and was perceived as if the player was unresponsive and/or the cache just overturned the user's decisions. Change it so that the actual pause state and the pause state as intended by the user never conflict. If the user toggles pause, the pause state will be in the expected state as soon as the cache is loaded.
Diffstat (limited to 'core/mplayer.c')
-rw-r--r--core/mplayer.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/core/mplayer.c b/core/mplayer.c
index 1ac2d6eeba..98d0ca6009 100644
--- a/core/mplayer.c
+++ b/core/mplayer.c
@@ -1065,7 +1065,7 @@ static void print_status(struct MPContext *mpctx)
char *line = NULL;
// Playback status
- if (mpctx->paused_for_cache) {
+ if (mpctx->paused_for_cache && !mpctx->paused_user) {
saddf(&line, "(Buffering) ");
} else if (mpctx->paused) {
saddf(&line, "(Paused) ");
@@ -1429,7 +1429,7 @@ static void sadd_osd_status(char **buffer, struct MPContext *mpctx, bool full)
bool fractions = mpctx->opts.osd_fractions;
int sym = mpctx->osd_function;
if (!sym) {
- if (mpctx->paused_for_cache) {
+ if (mpctx->paused_for_cache && !mpctx->paused_user) {
sym = OSD_CLOCK;
} else if (mpctx->paused || mpctx->step_frames) {
sym = OSD_PAUSE;
@@ -2638,12 +2638,15 @@ static double update_video(struct MPContext *mpctx, double endpts)
void pause_player(struct MPContext *mpctx)
{
+ mpctx->paused_user = true;
+
if (mpctx->paused)
return;
mpctx->paused = 1;
mpctx->step_frames = 0;
mpctx->time_frame -= get_relative_time(mpctx);
mpctx->osd_function = 0;
+ mpctx->paused_for_cache = false;
if (mpctx->video_out && mpctx->sh_video && mpctx->video_out->config_ok)
vo_control(mpctx->video_out, VOCTRL_PAUSE, NULL);
@@ -2661,11 +2664,15 @@ void pause_player(struct MPContext *mpctx)
void unpause_player(struct MPContext *mpctx)
{
+ mpctx->paused_user = false;
+
if (!mpctx->paused)
return;
+ // Don't actually unpause while cache is loading.
+ if (mpctx->paused_for_cache)
+ return;
mpctx->paused = 0;
mpctx->osd_function = 0;
- mpctx->paused_for_cache = false;
if (mpctx->ao && mpctx->sh_audio)
ao_resume(mpctx->ao);
@@ -3192,12 +3199,17 @@ static void handle_pause_on_low_cache(struct MPContext *mpctx)
int cache = mp_get_cache_percent(mpctx);
bool idle = mp_get_cache_idle(mpctx);
if (mpctx->paused && mpctx->paused_for_cache) {
- if (cache < 0 || cache >= opts->stream_cache_min_percent || idle)
- unpause_player(mpctx);
- } else if (!mpctx->paused) {
+ if (cache < 0 || cache >= opts->stream_cache_min_percent || idle) {
+ mpctx->paused_for_cache = false;
+ if (!mpctx->paused_user)
+ unpause_player(mpctx);
+ }
+ } else {
if (cache >= 0 && cache <= opts->stream_cache_pause && !idle) {
- mpctx->paused_for_cache = true;
+ bool prev_paused_user = mpctx->paused_user;
pause_player(mpctx);
+ mpctx->paused_for_cache = true;
+ mpctx->paused_user = prev_paused_user;
}
}
}
@@ -4244,6 +4256,9 @@ goto_enable_cache: ;
mpctx->seek = (struct seek_params){ 0 };
get_relative_time(mpctx); // reset current delta
+
+ mpctx->paused = mpctx->paused_user;
+ mpctx->paused_for_cache = false;
// Make sure VO knows current pause state
if (mpctx->sh_video)
vo_control(mpctx->video_out,