mirror of
https://github.com/mpv-player/mpv
synced 2024-12-30 11:02:10 +00:00
67689ff6b4
DR (letting the decoder allocate texture memory) requires running the allocation on the render thread. This is rather hard with the render API, because the user controls this thread and when it's entered. It was not possible until now. This commit adds a bunch of infrastructure to make this possible. We add a new optional mode (MPV_RENDER_PARAM_ADVANCED_CONTROL) which basically lets the user's render thread and libmpv agree how this should be done. Misuse would lead to deadlocks. To make this less likely, strictly document thread safety/locking issues. In particular, document which libmpv functions can be called without issues. (The rest has to be assumed unsafe.) The worst issue is destruction of the render context while video is still active. To avoid certain unintended recursive locks (i.e. deadlocks, unless we'd make the locks recursive), make the update callback lock separate. Make "killing" the video chain asynchronous, so we can do extra work while video is being destroyed. Because losing wakeups is a big deal, setting the update callback now triggers a wakeup. (It would have been better if the wakeup callback were a parameter to mpv_render_context_create(), but too late.) This commit does not add DR yet; the following commit does this.
58 lines
2.1 KiB
C
58 lines
2.1 KiB
C
#ifndef MP_CLIENT_H_
|
|
#define MP_CLIENT_H_
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
#include "libmpv/client.h"
|
|
#include "libmpv/stream_cb.h"
|
|
#include "misc/bstr.h"
|
|
|
|
struct MPContext;
|
|
struct mpv_handle;
|
|
struct mp_client_api;
|
|
struct mp_log;
|
|
struct mpv_global;
|
|
|
|
// Includes space for \0
|
|
#define MAX_CLIENT_NAME 64
|
|
|
|
void mp_clients_init(struct MPContext *mpctx);
|
|
void mp_clients_destroy(struct MPContext *mpctx);
|
|
void mp_shutdown_clients(struct MPContext *mpctx);
|
|
bool mp_clients_all_initialized(struct MPContext *mpctx);
|
|
|
|
bool mp_client_exists(struct MPContext *mpctx, const char *client_name);
|
|
void mp_client_broadcast_event(struct MPContext *mpctx, int event, void *data);
|
|
int mp_client_send_event(struct MPContext *mpctx, const char *client_name,
|
|
uint64_t reply_userdata, int event, void *data);
|
|
int mp_client_send_event_dup(struct MPContext *mpctx, const char *client_name,
|
|
int event, void *data);
|
|
bool mp_client_event_is_registered(struct MPContext *mpctx, int event);
|
|
void mp_client_property_change(struct MPContext *mpctx, const char *name);
|
|
|
|
struct mpv_handle *mp_new_client(struct mp_client_api *clients, const char *name);
|
|
void mp_client_set_weak(struct mpv_handle *ctx);
|
|
struct mp_log *mp_client_get_log(struct mpv_handle *ctx);
|
|
struct mpv_global *mp_client_get_global(struct mpv_handle *ctx);
|
|
struct MPContext *mp_client_get_core(struct mpv_handle *ctx);
|
|
struct MPContext *mp_client_api_get_core(struct mp_client_api *api);
|
|
|
|
// m_option.c
|
|
void *node_get_alloc(struct mpv_node *node);
|
|
|
|
// for vo_libmpv.c
|
|
struct osd_state;
|
|
struct mpv_render_context;
|
|
bool mp_set_main_render_context(struct mp_client_api *client_api,
|
|
struct mpv_render_context *ctx, bool active);
|
|
struct mpv_render_context *
|
|
mp_client_api_acquire_render_context(struct mp_client_api *ca);
|
|
void kill_video_async(struct mp_client_api *client_api, void (*fin)(void *ctx),
|
|
void *fin_ctx);
|
|
|
|
bool mp_streamcb_lookup(struct mpv_global *g, const char *protocol,
|
|
void **out_user_data, mpv_stream_cb_open_ro_fn *out_fn);
|
|
|
|
#endif
|