mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 16:11:20 +02:00
Fixes MPV crash when playing next up (#772)
## Description Ensure that MPV is always destroyed before being initialized again. Also, now creating a new player is only done when switching backends which means faster, more efficient playing the next up. ### Related issues Fixes #766
This commit is contained in:
parent
7b8f5c3e63
commit
03871579f5
3 changed files with 29 additions and 28 deletions
|
|
@ -39,17 +39,9 @@ object MPVLib {
|
|||
|
||||
external fun create(appctx: Context)
|
||||
|
||||
fun initialize() {
|
||||
synchronized(this) { init() }
|
||||
}
|
||||
external fun init()
|
||||
|
||||
private external fun init()
|
||||
|
||||
fun tearDown() {
|
||||
synchronized(this) { destroy() }
|
||||
}
|
||||
|
||||
private external fun destroy()
|
||||
external fun destroy()
|
||||
|
||||
external fun attachSurface(surface: Surface)
|
||||
|
||||
|
|
|
|||
|
|
@ -74,6 +74,8 @@ class MpvPlayer(
|
|||
SurfaceHolder.Callback {
|
||||
companion object {
|
||||
private const val DEBUG = false
|
||||
|
||||
private val initLock = Any()
|
||||
}
|
||||
|
||||
private var surface: Surface? = null
|
||||
|
|
@ -131,7 +133,7 @@ class MpvPlayer(
|
|||
MPVLib.setOptionString("demuxer-max-back-bytes", "${cacheMegs * 1024 * 1024}")
|
||||
|
||||
Timber.v("Initializing MPVLib")
|
||||
MPVLib.initialize()
|
||||
MPVLib.init()
|
||||
|
||||
MPVLib.setOptionString("force-window", "no")
|
||||
MPVLib.setOptionString("idle", "yes")
|
||||
|
|
@ -1086,14 +1088,18 @@ class MpvPlayer(
|
|||
}
|
||||
|
||||
MpvCommand.INITIALIZE -> {
|
||||
init()
|
||||
synchronized(initLock) {
|
||||
init()
|
||||
}
|
||||
}
|
||||
|
||||
MpvCommand.DESTROY -> {
|
||||
clearVideoSurfaceView(null)
|
||||
MPVLib.removeLogObserver(mpvLogger)
|
||||
MPVLib.tearDown()
|
||||
Timber.d("MPVLib destroyed")
|
||||
synchronized(initLock) {
|
||||
MPVLib.setPropertyBoolean("pause", true)
|
||||
MPVLib.removeLogObserver(mpvLogger)
|
||||
MPVLib.destroy()
|
||||
Timber.d("MPVLib destroyed")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue