summaryrefslogtreecommitdiffstats
path: root/command.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2008-11-29 08:09:57 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2008-12-09 04:31:07 +0200
commit77c709ad31ebe997dbd824506c145a0ac24581d0 (patch)
tree9a5b2ddde33191d6f47d1f424a7d9017a4e32d6e /command.c
parent6fa90873ccc8006e479061afdd0edfbfdadf17ec (diff)
downloadmpv-77c709ad31ebe997dbd824506c145a0ac24581d0.tar.bz2
mpv-77c709ad31ebe997dbd824506c145a0ac24581d0.tar.xz
Start pause handling changes
Add separate pause_player() / unpause_player functions(), move some pausing-related state into explicit variables and make commands while paused not unpause. Not everything works properly while paused yet (no screen updates etc).
Diffstat (limited to 'command.c')
-rw-r--r--command.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/command.c b/command.c
index 9d4c38726b..e642944ada 100644
--- a/command.c
+++ b/command.c
@@ -2,6 +2,7 @@
#include <inttypes.h>
#include <unistd.h>
#include <string.h>
+#include <stdbool.h>
#include "config.h"
#include "command.h"
@@ -559,10 +560,27 @@ static int mp_property_metadata(m_option_t *prop, int action, void *arg,
return M_PROPERTY_NOT_IMPLEMENTED;
}
-static int mp_property_pause(m_option_t * prop, int action, void *arg,
- MPContext * mpctx)
+static int mp_property_pause(m_option_t *prop, int action, void *arg,
+ void *ctx)
{
- return m_property_flag_ro(prop, action, arg, mpctx->osd_function == OSD_PAUSE);
+ MPContext *mpctx = ctx;
+
+ switch (action) {
+ case M_PROPERTY_SET:
+ if (!arg)
+ return M_PROPERTY_ERROR;
+ if (mpctx->paused == (bool)*(int *) arg)
+ return M_PROPERTY_OK;
+ case M_PROPERTY_STEP_UP:
+ case M_PROPERTY_STEP_DOWN:
+ if (mpctx->paused)
+ unpause_player(mpctx);
+ else
+ pause_player(mpctx);
+ return M_PROPERTY_OK;
+ default:
+ return m_property_flag(prop, action, arg, &mpctx->paused);
+ }
}
@@ -2212,6 +2230,7 @@ static struct {
{ "loop", MP_CMD_LOOP, 0, 0, -1, MSGTR_LoopStatus },
{ "chapter", MP_CMD_SEEK_CHAPTER, 0, 0, -1, NULL },
{ "angle", MP_CMD_SWITCH_ANGLE, 0, 0, -1, NULL },
+ { "pause", MP_CMD_PAUSE, 0, 0, -1, NULL },
// audio
{ "volume", MP_CMD_VOLUME, 0, OSD_VOLUME, -1, MSGTR_Volume },
{ "mute", MP_CMD_MUTE, 1, 0, -1, MSGTR_MuteStatus },
@@ -2503,9 +2522,8 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
} break;
case MP_CMD_FRAME_STEP:
- case MP_CMD_PAUSE:
- cmd->pausing = 1;
- brk_cmd = 1;
+ mpctx->step_frames++;
+ unpause_player(mpctx);
break;
case MP_CMD_FILE_FILTER:
@@ -3215,18 +3233,14 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
switch (cmd->pausing) {
case 1: // "pausing"
- mpctx->osd_function = OSD_PAUSE;
+ pause_player(mpctx);
break;
case 3: // "pausing_toggle"
- mpctx->was_paused = !mpctx->was_paused;
- if (mpctx->was_paused)
- mpctx->osd_function = OSD_PAUSE;
- else if (mpctx->osd_function == OSD_PAUSE)
- mpctx->osd_function = OSD_PLAY;
+ if (mpctx->paused)
+ unpause_player(mpctx);
+ else
+ pause_player(mpctx);
break;
- case 2: // "pausing_keep"
- if (mpctx->was_paused)
- mpctx->osd_function = OSD_PAUSE;
}
return brk_cmd;
}