1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-13 10:27:12 +00:00

client API: fix broken property/option functions

1. Cannot set option after initialized: it seems that this bug has
   existed since libmpv was introduced first. Maybe just a typo.
2. Crash when setting property with native format: mpv_set_property
   just causes a crash when using a native format. I found an invalid
   casting and fixed it.
3. Wrong error value for mpv_get_property: when an error occurred,
   mpv_get_property always returns wrong format error because every
   error for property except M_PROPERTY_NOT_IMPLEMENTED is just ignored.

Signed-off-by: wm4 <wm4@nowhere>

Closes pull request #593. Does not incldue the first fix, which was not
correct. The underlying bug will be fixed by a later commit.

Commit message extracted from pull request and slightly edited.
This commit is contained in:
xylosper 2014-02-26 22:05:17 +09:00 committed by wm4
parent 9a7a3d125b
commit c176f2be39

View File

@ -510,7 +510,7 @@ int mpv_set_option(mpv_handle *ctx, const char *name, mpv_format format,
if (ctx->mpctx->initialized) {
char prop[100];
snprintf(prop, sizeof(prop), "options/%s", name);
int err = mpv_set_property(ctx, name, format, data);
int err = mpv_set_property(ctx, prop, format, data);
switch (err) {
case MPV_ERROR_PROPERTY_UNAVAILABLE:
case MPV_ERROR_PROPERTY_ERROR:
@ -725,7 +725,7 @@ int mpv_set_property(mpv_handle *ctx, const char *name, mpv_format format,
.mpctx = ctx->mpctx,
.name = name,
.format = format,
.data = *(char **)data,
.data = data,
};
run_locked(ctx, setproperty_fn, &req);
return req.status;
@ -821,7 +821,8 @@ static void getproperty_fn(void *arg)
break;
node.format = MPV_FORMAT_STRING;
node.u.string = s;
}
} else if (err <= 0)
break;
if (req->format == MPV_FORMAT_NODE) {
*(struct mpv_node *)data = node;
} else {