Skip to content

Commit

Permalink
player: make deprecated track/chapter/metadata events internal
Browse files Browse the repository at this point in the history
We still need these to track or notify of modifications to certain properties,
but they're now gone from the libmpv ABI.
  • Loading branch information
sfan5 committed Dec 15, 2021
1 parent dfcd561 commit f9fd50c
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 65 deletions.
3 changes: 2 additions & 1 deletion DOCS/client-api-changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ API changes
- remove mpv_opengl_init_params.extra_exts field
- remove deprecated mpv_detach_destroy. Use mpv_destroy instead.
- remove obsolete mpv_suspend and mpv_resume
- remove deprecated SCRIPT_INPUT_DISPATCH, PAUSE and UNPAUSE events
- remove deprecated SCRIPT_INPUT_DISPATCH, PAUSE and UNPAUSE, TRACKS_CHANGED
TRACK_SWITCHED, METADATA_UPDATE, CHAPTER_CHANGE events
--- mpv 0.33.0 ---
1.109 - add MPV_RENDER_API_TYPE_SW and related (software rendering API)
- inactivate the opengl_cb API (always fails to initialize now)
Expand Down
6 changes: 2 additions & 4 deletions DOCS/man/input.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1600,10 +1600,8 @@ This list uses the event name field value, and the C API symbol in brackets:
``data``
The new value of the property.

The following events also happen, but are deprecated: ``tracks-changed``,
``track-switched``, ``metadata-update``, ``idle``,
``tick``, ``chapter-change``. Use ``mpv_observe_property()``
(Lua: ``mp.observe_property()``) instead.
The following events also happen, but are deprecated: ``idle``, ``tick``
Use ``mpv_observe_property()`` (Lua: ``mp.observe_property()``) instead.

Hooks
~~~~~
Expand Down
40 changes: 0 additions & 40 deletions libmpv/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -1265,24 +1265,6 @@ typedef enum mpv_event_id {
*/
MPV_EVENT_FILE_LOADED = 8,
#if MPV_ENABLE_DEPRECATED
/**
* The list of video/audio/subtitle tracks was changed. (E.g. a new track
* was found. This doesn't necessarily indicate a track switch; for this,
* MPV_EVENT_TRACK_SWITCHED is used.)
*
* @deprecated This is equivalent to using mpv_observe_property() on the
* "track-list" property. The event is redundant, and might
* be removed in the far future.
*/
MPV_EVENT_TRACKS_CHANGED = 9,
/**
* A video/audio/subtitle track was switched on or off.
*
* @deprecated This is equivalent to using mpv_observe_property() on the
* "vid", "aid", and "sid" properties. The event is redundant,
* and might be removed in the far future.
*/
MPV_EVENT_TRACK_SWITCHED = 10,
/**
* 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
Expand Down Expand Up @@ -1331,18 +1313,6 @@ typedef enum mpv_event_id {
* because there is no such thing as audio output embedding.
*/
MPV_EVENT_AUDIO_RECONFIG = 18,
#if MPV_ENABLE_DEPRECATED
/**
* Happens when metadata (like file tags) is possibly updated. (It's left
* unspecified whether this happens on file start or only when it changes
* within a file.)
*
* @deprecated This is equivalent to using mpv_observe_property() on the
* "metadata" property. The event is redundant, and might
* be removed in the far future.
*/
MPV_EVENT_METADATA_UPDATE = 19,
#endif
/**
* Happens when a seek was initiated. Playback stops. Usually it will
* resume with MPV_EVENT_PLAYBACK_RESTART as soon as the seek is finished.
Expand All @@ -1360,16 +1330,6 @@ typedef enum mpv_event_id {
* See also mpv_event and mpv_event_property.
*/
MPV_EVENT_PROPERTY_CHANGE = 22,
#if MPV_ENABLE_DEPRECATED
/**
* Happens when the current chapter changes.
*
* @deprecated This is equivalent to using mpv_observe_property() on the
* "chapter" property. The event is redundant, and might
* be removed in the far future.
*/
MPV_EVENT_CHAPTER_CHANGE = 23,
#endif
/**
* Happens if the internal per-mpv_handle ringbuffer overflows, and at
* least 1 event had to be dropped. This can happen if the client doesn't
Expand Down
8 changes: 0 additions & 8 deletions player/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -847,12 +847,8 @@ int mp_client_send_event_dup(struct MPContext *mpctx, const char *client_name,
}

const static bool deprecated_events[] = {
[MPV_EVENT_TRACKS_CHANGED] = true,
[MPV_EVENT_TRACK_SWITCHED] = true,
[MPV_EVENT_IDLE] = true,
[MPV_EVENT_TICK] = true,
[MPV_EVENT_METADATA_UPDATE] = true,
[MPV_EVENT_CHAPTER_CHANGE] = true,
};

int mpv_request_event(mpv_handle *ctx, mpv_event_id event, int enable)
Expand Down Expand Up @@ -2078,18 +2074,14 @@ static const char *const event_table[] = {
[MPV_EVENT_START_FILE] = "start-file",
[MPV_EVENT_END_FILE] = "end-file",
[MPV_EVENT_FILE_LOADED] = "file-loaded",
[MPV_EVENT_TRACKS_CHANGED] = "tracks-changed",
[MPV_EVENT_TRACK_SWITCHED] = "track-switched",
[MPV_EVENT_IDLE] = "idle",
[MPV_EVENT_TICK] = "tick",
[MPV_EVENT_CLIENT_MESSAGE] = "client-message",
[MPV_EVENT_VIDEO_RECONFIG] = "video-reconfig",
[MPV_EVENT_AUDIO_RECONFIG] = "audio-reconfig",
[MPV_EVENT_METADATA_UPDATE] = "metadata-update",
[MPV_EVENT_SEEK] = "seek",
[MPV_EVENT_PLAYBACK_RESTART] = "playback-restart",
[MPV_EVENT_PROPERTY_CHANGE] = "property-change",
[MPV_EVENT_CHAPTER_CHANGE] = "chapter-change",
[MPV_EVENT_QUEUE_OVERFLOW] = "event-queue-overflow",
[MPV_EVENT_HOOK] = "hook",
};
Expand Down
10 changes: 5 additions & 5 deletions player/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ static int parse_node_chapters(struct MPContext *mpctx,
}
}

mp_notify(mpctx, MPV_EVENT_CHAPTER_CHANGE, NULL);
mp_notify(mpctx, MP_EVENT_CHAPTER_CHANGE, NULL);
mp_notify_property(mpctx, "chapter-list");

return M_PROPERTY_OK;
Expand Down Expand Up @@ -3770,8 +3770,8 @@ static const char *const *const mp_event_property_change[] = {
E(MPV_EVENT_END_FILE, "*"),
E(MPV_EVENT_FILE_LOADED, "*"),
E(MP_EVENT_CHANGE_ALL, "*"),
E(MPV_EVENT_TRACKS_CHANGED, "track-list", "current-tracks"),
E(MPV_EVENT_TRACK_SWITCHED, "track-list", "current-tracks"),
E(MP_EVENT_TRACKS_CHANGED, "track-list", "current-tracks"),
E(MP_EVENT_TRACK_SWITCHED, "track-list", "current-tracks"),
E(MPV_EVENT_IDLE, "*"),
E(MPV_EVENT_TICK, "time-pos", "audio-pts", "stream-pos", "avsync",
"percent-pos", "time-remaining", "playtime-remaining", "playback-time",
Expand All @@ -3794,8 +3794,8 @@ static const char *const *const mp_event_property_change[] = {
"audio-out-params", "volume-max", "mixer-active"),
E(MPV_EVENT_SEEK, "seeking", "core-idle", "eof-reached"),
E(MPV_EVENT_PLAYBACK_RESTART, "seeking", "core-idle", "eof-reached"),
E(MPV_EVENT_METADATA_UPDATE, "metadata", "filtered-metadata", "media-title"),
E(MPV_EVENT_CHAPTER_CHANGE, "chapter", "chapter-metadata"),
E(MP_EVENT_METADATA_UPDATE, "metadata", "filtered-metadata", "media-title"),
E(MP_EVENT_CHAPTER_CHANGE, "chapter", "chapter-metadata"),
E(MP_EVENT_CACHE_UPDATE,
"demuxer-cache-duration", "demuxer-cache-idle", "paused-for-cache",
"demuxer-cache-time", "cache-buffering-state", "cache-speed",
Expand Down
4 changes: 4 additions & 0 deletions player/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ enum {
MP_EVENT_CORE_IDLE,
MP_EVENT_DURATION_UPDATE,
MP_EVENT_INPUT_PROCESSED,
MP_EVENT_TRACKS_CHANGED,
MP_EVENT_TRACK_SWITCHED,
MP_EVENT_METADATA_UPDATE,
MP_EVENT_CHAPTER_CHANGE,
};

bool mp_hook_test_completion(struct MPContext *mpctx, char *type);
Expand Down
12 changes: 6 additions & 6 deletions player/loadfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ void update_demuxer_properties(struct MPContext *mpctx)
}
talloc_free(mpctx->filtered_tags);
mpctx->filtered_tags = info;
mp_notify(mpctx, MPV_EVENT_METADATA_UPDATE, NULL);
mp_notify(mpctx, MP_EVENT_METADATA_UPDATE, NULL);
}
if (events & DEMUX_EVENT_DURATION)
mp_notify(mpctx, MP_EVENT_DURATION_UPDATE, NULL);
Expand Down Expand Up @@ -429,7 +429,7 @@ static struct track *add_stream_track(struct MPContext *mpctx,
};
MP_TARRAY_APPEND(mpctx, mpctx->tracks, mpctx->num_tracks, track);

mp_notify(mpctx, MPV_EVENT_TRACKS_CHANGED, NULL);
mp_notify(mpctx, MP_EVENT_TRACKS_CHANGED, NULL);

return track;
}
Expand Down Expand Up @@ -686,7 +686,7 @@ void mp_switch_track_n(struct MPContext *mpctx, int order, enum stream_type type
reinit_sub(mpctx, track);
}

mp_notify(mpctx, MPV_EVENT_TRACK_SWITCHED, NULL);
mp_notify(mpctx, MP_EVENT_TRACK_SWITCHED, NULL);
mp_wakeup_core(mpctx);

talloc_free(mpctx->track_layout_hash);
Expand Down Expand Up @@ -752,7 +752,7 @@ bool mp_remove_track(struct MPContext *mpctx, struct track *track)
if (!in_use)
demux_cancel_and_free(d);

mp_notify(mpctx, MPV_EVENT_TRACKS_CHANGED, NULL);
mp_notify(mpctx, MP_EVENT_TRACKS_CHANGED, NULL);

return true;
}
Expand Down Expand Up @@ -1358,7 +1358,7 @@ static int reinit_complex_filters(struct MPContext *mpctx, bool force_uninit)
reselect_demux_stream(mpctx, mpctx->tracks[n], false);
}

mp_notify(mpctx, MPV_EVENT_TRACKS_CHANGED, NULL);
mp_notify(mpctx, MP_EVENT_TRACKS_CHANGED, NULL);

return success ? 1 : -1;
}
Expand Down Expand Up @@ -1721,7 +1721,7 @@ static void play_current_file(struct MPContext *mpctx)
talloc_free(mpctx->filtered_tags);
mpctx->filtered_tags = NULL;

mp_notify(mpctx, MPV_EVENT_TRACKS_CHANGED, NULL);
mp_notify(mpctx, MP_EVENT_TRACKS_CHANGED, NULL);

if (encode_lavc_didfail(mpctx->encode_lavc_ctx))
mpctx->stop_play = PT_ERROR;
Expand Down
2 changes: 1 addition & 1 deletion player/playloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ static void handle_chapter_change(struct MPContext *mpctx)
int chapter = get_current_chapter(mpctx);
if (chapter != mpctx->last_chapter) {
mpctx->last_chapter = chapter;
mp_notify(mpctx, MPV_EVENT_CHAPTER_CHANGE, NULL);
mp_notify(mpctx, MP_EVENT_CHAPTER_CHANGE, NULL);
}
}

Expand Down

0 comments on commit f9fd50c

Please sign in to comment.