Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

Commit

Permalink
Fix deadlock in VideoView.uninit method, #11
Browse files Browse the repository at this point in the history
This commit will add locking of the OpenGL context to the VideoView.uninit
method in order to match the order of lock acquisition the ViewLayer.draw
methods use.
  • Loading branch information
low-batt committed Jan 1, 2022
1 parent 7bfa037 commit 09d83aa
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions iina/VideoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,18 @@ class VideoView: NSView {
}

func uninit() {
// Order of locking must match the draw methods in ViewLayer.
player.mpv?.lockAndSetOpenGLContext()
uninitLock.lock()

guard !isUninited else {
defer {
uninitLock.unlock()
return
player.mpv?.unlockOpenGLContext()
}

guard !isUninited else { return }

player.mpv.mpvUninitRendering()
isUninited = true
uninitLock.unlock()
}

deinit {
Expand Down

0 comments on commit 09d83aa

Please sign in to comment.