summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/client-api-changes.rst1
-rw-r--r--libmpv/client.h10
-rw-r--r--player/command.c9
-rw-r--r--player/core.h2
-rw-r--r--player/loadfile.c16
-rw-r--r--player/main.c6
-rw-r--r--player/playloop.c4
7 files changed, 26 insertions, 22 deletions
diff --git a/DOCS/client-api-changes.rst b/DOCS/client-api-changes.rst
index 2c0c393125..b1a61fe865 100644
--- a/DOCS/client-api-changes.rst
+++ b/DOCS/client-api-changes.rst
@@ -33,6 +33,7 @@ API changes
::
--- mpv 0.33.0 ---
+ 1.108 - Deprecate MPV_EVENT_IDLE
1.107 - Remove the deprecated qthelper.hpp. This was obviously not part of the
libmpv API, only an "additionally" provided helper, thus this is not
considered an API change. If you are maintaining a project that relies
diff --git a/libmpv/client.h b/libmpv/client.h
index ce880e1012..8d3af89249 100644
--- a/libmpv/client.h
+++ b/libmpv/client.h
@@ -232,7 +232,7 @@ extern "C" {
* relational operators (<, >, <=, >=).
*/
#define MPV_MAKE_VERSION(major, minor) (((major) << 16) | (minor) | 0UL)
-#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(1, 107)
+#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(1, 108)
/**
* The API user is allowed to "#define MPV_ENABLE_DEPRECATED 0" before
@@ -1328,15 +1328,19 @@ typedef enum mpv_event_id {
* and might be removed in the far future.
*/
MPV_EVENT_TRACK_SWITCHED = 10,
-#endif
/**
* Idle mode was entered. In this mode, no file is played, and the playback
* core waits for new commands. (The command line player normally quits
* instead of entering idle mode, unless --idle was specified. If mpv
* was started with mpv_create(), idle mode is enabled by default.)
+ *
+ * @deprecated This is equivalent to using mpv_observe_property() on the
+ * "idle-active" property. The event is redundant, and might be
+ * removed in the far future. As a further warning, this event
+ * is not necessarily sent at the right point anymore (at the
+ * start of the program), while the property behaves correctly.
*/
MPV_EVENT_IDLE = 11,
-#if MPV_ENABLE_DEPRECATED
/**
* Playback was paused. This indicates the user pause state.
*
diff --git a/player/command.c b/player/command.c
index 73c6d86712..938d9fa988 100644
--- a/player/command.c
+++ b/player/command.c
@@ -80,8 +80,6 @@ struct command_ctx {
// All properties, terminated with a {0} item.
struct m_property *properties;
- bool is_idle;
-
double last_seek_time;
double last_seek_pts;
double marked_pts;
@@ -1310,8 +1308,7 @@ static int mp_property_idle(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
- struct command_ctx *cmd = mpctx->command_ctx;
- return m_property_flag_ro(action, arg, cmd->is_idle);
+ return m_property_flag_ro(action, arg, mpctx->stop_play == PT_STOP);
}
static int mp_property_eof_reached(void *ctx, struct m_property *prop,
@@ -6036,10 +6033,6 @@ static void command_event(struct MPContext *mpctx, int event, void *arg)
ctx->marked_pts = MP_NOPTS_VALUE;
}
- if (event == MPV_EVENT_IDLE)
- ctx->is_idle = true;
- if (event == MPV_EVENT_START_FILE)
- ctx->is_idle = false;
if (event == MPV_EVENT_END_FILE || event == MPV_EVENT_FILE_LOADED) {
// Update chapters - does nothing if something else is visible.
set_osd_bar_chapters(mpctx, OSD_BAR_SEEK);
diff --git a/player/core.h b/player/core.h
index 0dbf56d2b1..5161b07799 100644
--- a/player/core.h
+++ b/player/core.h
@@ -43,7 +43,7 @@ enum stop_play_reason {
// also returned on unrecoverable playback errors
PT_NEXT_ENTRY, // prepare to play next entry in playlist
PT_CURRENT_ENTRY, // prepare to play mpctx->playlist->current
- PT_STOP, // stop playback, or transient state when going to next
+ PT_STOP, // stop playback / idle mode
PT_QUIT, // stop playback, quit player
PT_ERROR, // play next playlist entry (due to an error)
};
diff --git a/player/loadfile.c b/player/loadfile.c
index baedfbbcb7..8a8094c3e3 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -1378,7 +1378,7 @@ static void play_current_file(struct MPContext *mpctx)
mpctx->stop_play = 0;
process_hooks(mpctx, "on_before_start_file");
- if (mpctx->stop_play)
+ if (mpctx->stop_play || !mpctx->playlist->current)
return;
mp_notify(mpctx, MPV_EVENT_START_FILE, NULL);
@@ -1777,25 +1777,29 @@ void mp_play_files(struct MPContext *mpctx)
prepare_playlist(mpctx, mpctx->playlist);
for (;;) {
- assert(mpctx->stop_play);
idle_loop(mpctx);
+
if (mpctx->stop_play == PT_QUIT)
break;
- play_current_file(mpctx);
+ if (mpctx->playlist->current)
+ play_current_file(mpctx);
+
if (mpctx->stop_play == PT_QUIT)
break;
- struct playlist_entry *new_entry = mpctx->playlist->current;
+ struct playlist_entry *new_entry = NULL;
if (mpctx->stop_play == PT_NEXT_ENTRY || mpctx->stop_play == PT_ERROR ||
- mpctx->stop_play == AT_END_OF_FILE || mpctx->stop_play == PT_STOP)
+ mpctx->stop_play == AT_END_OF_FILE)
{
new_entry = mp_next_file(mpctx, +1, false, true);
+ } else if (mpctx->stop_play == PT_CURRENT_ENTRY) {
+ new_entry = mpctx->playlist->current;
}
mpctx->playlist->current = new_entry;
mpctx->playlist->current_was_replaced = false;
- mpctx->stop_play = PT_STOP;
+ mpctx->stop_play = new_entry ? PT_NEXT_ENTRY : PT_STOP;
if (!mpctx->playlist->current && mpctx->opts->player_idle_mode < 2)
break;
diff --git a/player/main.c b/player/main.c
index f3d591ecae..b0150b2b80 100644
--- a/player/main.c
+++ b/player/main.c
@@ -267,7 +267,7 @@ struct MPContext *mp_create(void)
.dispatch = mp_dispatch_create(mpctx),
.playback_abort = mp_cancel_new(mpctx),
.thread_pool = mp_thread_pool_create(mpctx, 0, 1, 30),
- .stop_play = PT_STOP,
+ .stop_play = PT_NEXT_ENTRY,
.play_dir = 1,
};
@@ -407,6 +407,10 @@ int mp_initialize(struct MPContext *mpctx, char **options)
if (opts->force_vo == 2 && handle_force_window(mpctx, false) < 0)
return -1;
+ // Needed to properly enter _initial_ idle mode if playlist empty.
+ if (mpctx->opts->player_idle_mode && !mpctx->playlist->num_entries)
+ mpctx->stop_play = PT_STOP;
+
MP_STATS(mpctx, "end init");
return 0;
diff --git a/player/playloop.c b/player/playloop.c
index f2ccf94410..f581e92f28 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -1253,9 +1253,7 @@ void idle_loop(struct MPContext *mpctx)
{
// ================= idle loop (STOP state) =========================
bool need_reinit = true;
- while (mpctx->opts->player_idle_mode && !mpctx->playlist->current
- && mpctx->stop_play != PT_QUIT)
- {
+ while (mpctx->opts->player_idle_mode && mpctx->stop_play == PT_STOP) {
if (need_reinit) {
uninit_audio_out(mpctx);
handle_force_window(mpctx, true);