summaryrefslogtreecommitdiffstats
path: root/player/playloop.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-02-10 21:01:35 +0100
committerwm4 <wm4@nowhere>2014-02-10 21:01:35 +0100
commit88ae914b1ef2b76362c527985bd459b0d8226d45 (patch)
treefbab27d01347c98fd36348821fafc47037193810 /player/playloop.c
parentc6166ff448432dc74c300933e5c93838d06c420a (diff)
downloadmpv-88ae914b1ef2b76362c527985bd459b0d8226d45.tar.bz2
mpv-88ae914b1ef2b76362c527985bd459b0d8226d45.tar.xz
Add a client API
Add a client API, which is intended to be a stable API to get some rough control over the player. Basically, it reflects what can be done with input.conf commands or the old slavemode. It will replace the old slavemode (and enable the implementation of a new slave protocol).
Diffstat (limited to 'player/playloop.c')
-rw-r--r--player/playloop.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/player/playloop.c b/player/playloop.c
index e28d387801..d97fedccbc 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -34,6 +34,7 @@
#include "input/input.h"
#include "osdep/terminal.h"
+#include "osdep/threads.h"
#include "osdep/timer.h"
#include "audio/mixer.h"
@@ -50,6 +51,7 @@
#include "core.h"
#include "screenshot.h"
#include "command.h"
+#include "libmpv/client.h"
#define WAKEUP_PERIOD 0.5
@@ -79,7 +81,7 @@ static const char av_desync_help_text[] =
void pause_player(struct MPContext *mpctx)
{
- mp_notify_property(mpctx, "pause");
+ mp_notify(mpctx, MPV_EVENT_PAUSE, NULL);
mpctx->opts->pause = 1;
@@ -110,7 +112,7 @@ void pause_player(struct MPContext *mpctx)
void unpause_player(struct MPContext *mpctx)
{
- mp_notify_property(mpctx, "pause");
+ mp_notify(mpctx, MPV_EVENT_UNPAUSE, NULL);
mpctx->opts->pause = 0;
@@ -749,12 +751,14 @@ static void handle_input_and_seek_coalesce(struct MPContext *mpctx)
mp_cmd_t *cmd;
while ((cmd = mp_input_get_cmd(mpctx->input, 0, 1)) != NULL) {
+ mp_dispatch_queue_process(mpctx->dispatch, 0);
cmd = mp_input_get_cmd(mpctx->input, 0, 0);
run_command(mpctx, cmd);
mp_cmd_free(cmd);
if (mpctx->stop_play)
break;
}
+ mp_dispatch_queue_process(mpctx->dispatch, 0);
}
void add_frame_pts(struct MPContext *mpctx, double pts)
@@ -1166,9 +1170,14 @@ void run_playloop(struct MPContext *mpctx)
screenshot_flip(mpctx);
new_frame_shown = true;
+ mp_notify(mpctx, MPV_EVENT_TICK, NULL);
+
break;
} // video
+ if (!video_left || mpctx->paused)
+ mp_notify(mpctx, MPV_EVENT_TICK, NULL);
+
video_left &= mpctx->sync_audio_to_video; // force no-video semantics
if (mpctx->d_audio && (mpctx->restart_playback ? !video_left :
@@ -1308,6 +1317,7 @@ void run_playloop(struct MPContext *mpctx)
void idle_loop(struct MPContext *mpctx)
{
// ================= idle loop (STOP state) =========================
+ mp_notify(mpctx, MPV_EVENT_IDLE, NULL);
bool need_reinit = true;
while (mpctx->opts->player_idle_mode && !mpctx->playlist->current
&& mpctx->stop_play != PT_QUIT)
@@ -1331,6 +1341,7 @@ void idle_loop(struct MPContext *mpctx)
run_command(mpctx, cmd);
mp_cmd_free(cmd);
mp_flush_events(mpctx);
+ mp_dispatch_queue_process(mpctx->dispatch, 0);
if (mpctx->opts->use_terminal)
getch2_poll();
}