libmpv: add mpv_del_property() convenience function

This commit is contained in:
rcombs 2022-12-16 15:21:35 -06:00
parent 04241ab731
commit 2cfaa820e5
3 changed files with 18 additions and 1 deletions

View File

@ -33,6 +33,7 @@ API changes
::
--- mpv 0.35.0 ---
2.1 - add mpv_del_property()
2.0 - remove headers/functions of the obsolete opengl_cb API
- remove mpv_opengl_init_params.extra_exts field
- remove deprecated mpv_detach_destroy. Use mpv_destroy instead.

View File

@ -240,7 +240,7 @@ extern "C" {
* relational operators (<, >, <=, >=).
*/
#define MPV_MAKE_VERSION(major, minor) (((major) << 16) | (minor) | 0UL)
#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(2, 0)
#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(2, 1)
/**
* The API user is allowed to "#define MPV_ENABLE_DEPRECATED 0" before
@ -1068,6 +1068,16 @@ MPV_EXPORT int mpv_set_property(mpv_handle *ctx, const char *name, mpv_format fo
*/
MPV_EXPORT int mpv_set_property_string(mpv_handle *ctx, const char *name, const char *data);
/**
* Convenience function to delete a property.
*
* This is equivalent to running the command "del [name]".
*
* @param name The property name. See input.rst for a list of properties.
* @return error code
*/
MPV_EXPORT int mpv_del_property(mpv_handle *ctx, const char *name);
/**
* Set a property asynchronously. You will receive the result of the operation
* as MPV_EVENT_SET_PROPERTY_REPLY event. The mpv_event.error field will contain

View File

@ -1337,6 +1337,12 @@ int mpv_set_property(mpv_handle *ctx, const char *name, mpv_format format,
return req.status;
}
int mpv_del_property(mpv_handle *ctx, const char *name)
{
const char* args[] = { "del", name, NULL };
return mpv_command(ctx, args);
}
int mpv_set_property_string(mpv_handle *ctx, const char *name, const char *data)
{
return mpv_set_property(ctx, name, MPV_FORMAT_STRING, &data);