chore(mpv): share desktop startup options and stop forwarding unused Android events

Linux and Windows each wrote the same eleven pre-initialize mpv options
(keep-open, idle, input disabling, OSC, ytdl, audio fallback, and the
audio-only set); ApplyCommonStartupOptions in mpv_player_common.h owns
them once, with the ytdl security rationale kept in one place. Rendering,
windowing, HDR, and log-level options stay per platform.

The Android JNI event thread forwarded every mpv event to Kotlin, where
MpvEvent modelled ten variants but MpvPlayerCore consumes four. The
native switch now forwards only START_FILE, FILE_LOADED, and
PLAYBACK_RESTART (END_FILE keeps its own path), and the unused variants
are gone.
This commit is contained in:
edde746
2026-09-03 11:36:29 +02:00
parent b27cab4510
commit d181bd34ae
6 changed files with 46 additions and 68 deletions
@@ -537,7 +537,6 @@ class MpvPlayerCore private constructor(
delegate?.onEvent("file-loaded", null)
}
is MpvEvent.PlaybackRestart -> delegate?.onEvent("playback-restart", null)
else -> {}
}
}
}
+6 -1
View File
@@ -81,10 +81,15 @@ void* event_thread(void* arg) {
case MPV_EVENT_END_FILE:
sendEndFileToJava(env, mp_event);
break;
default:
case MPV_EVENT_START_FILE:
case MPV_EVENT_FILE_LOADED:
case MPV_EVENT_PLAYBACK_RESTART:
ALOGV("event: %s\n", mpv_event_name(mp_event->event_id));
sendEventToJava(env, mp_event->event_id);
break;
default:
// Nothing on the Kotlin side consumes the remaining ids (MpvEvent.fromId).
break;
}
}
@@ -1,30 +1,18 @@
package com.edde746.plezy.libmpv
sealed interface MpvEvent {
data object Shutdown : MpvEvent
data object StartFile : MpvEvent
data class EndFile(val reason: EndFileReason?) : MpvEvent
data object FileLoaded : MpvEvent
data object VideoReconfig : MpvEvent
data object AudioReconfig : MpvEvent
data object Seek : MpvEvent
data object PlaybackRestart : MpvEvent
data object QueueOverflow : MpvEvent
data class Other(val eventId: Int) : MpvEvent
companion object {
// Mirrors the ids event.cpp forwards; END_FILE arrives via its own JNI path.
internal fun fromId(id: Int): MpvEvent? = when (id) {
1 -> Shutdown
6 -> StartFile
8 -> FileLoaded
17 -> VideoReconfig
18 -> AudioReconfig
20 -> Seek
21 -> PlaybackRestart
24 -> QueueOverflow
// 0=NONE, 2=LOG_MESSAGE, 7=END_FILE, 22=PROPERTY_CHANGE handled separately
0, 2, 7, 22 -> null
else -> Other(id)
else -> null
}
}
}