From 86dcd10f1981fe59557c58155cd8c92794c2b1a1 Mon Sep 17 00:00:00 2001 From: Shuanglei Tao Date: Mon, 18 Dec 2023 12:03:15 +0800 Subject: [PATCH] fix subtitle menu check status --- src/menu.c | 8 +++++--- src/plugin.c | 14 +++++++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/menu.c b/src/menu.c index 6e28700..ae8c59e 100644 --- a/src/menu.c +++ b/src/menu.c @@ -248,16 +248,18 @@ static bool update_edition_menu(plugin_ctx *ctx, dyn_menu *item) { void *tmp = talloc_new(NULL); + int pos = -1; for (int i = 0; i < list->num_entries; i++) { edition_item *entry = &list->entries[i]; + if (entry->id == ctx->state->edition) pos = i; append_menu( item->hmenu, MIIM_STRING | MIIM_DATA, 0, 0, escape_title(item->talloc_ctx, bstr0(entry->title)), NULL, talloc_asprintf(item->talloc_ctx, "set edition %d", entry->id)); } - if (ctx->state->edition >= 0) - CheckMenuRadioItem(item->hmenu, 0, list->num_entries, - ctx->state->edition, MF_BYPOSITION); + if (pos >= 0) + CheckMenuRadioItem(item->hmenu, 0, list->num_entries, pos, + MF_BYPOSITION); talloc_free(tmp); return true; diff --git a/src/plugin.c b/src/plugin.c index 2a5e450..3c122ed 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -72,6 +72,17 @@ static void handle_property_change(mpv_event *event) { mp_state *state = ctx->state; mpv_event_property *prop = event->data; switch (prop->format) { + case MPV_FORMAT_NONE: + if (strcmp(prop->name, "vid") == 0) { + state->vid = -1; + } else if (strcmp(prop->name, "aid") == 0) { + state->aid = -1; + } else if (strcmp(prop->name, "sid") == 0) { + state->sid = -1; + } else if (strcmp(prop->name, "secondary-sid") == 0) { + state->sid2 = -1; + } + break; case MPV_FORMAT_INT64: if (strcmp(prop->name, "window-id") == 0) { int64_t wid = *(int64_t *)prop->data; @@ -94,7 +105,8 @@ static void handle_property_change(mpv_event *event) { if (strcmp(prop->name, "audio-device") == 0) { if (state->audio_device != NULL) talloc_free(state->audio_device); - state->audio_device = talloc_strdup(state, prop->data); + char *val = *(char **)prop->data; + state->audio_device = talloc_strdup(state, val); } break; case MPV_FORMAT_NODE: