summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkemi <der.richter@gmx.de>2018-03-13 21:14:27 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-03-14 23:59:03 -0700
commit749f5c8d65056763398aad5e9eb786fe52b8fede (patch)
treea571ec46be6b39726b252c7ef7f448c203e4cbd2
parent12b90e744dd220a3386a8977138fba28708c8d21 (diff)
downloadmpv-749f5c8d65056763398aad5e9eb786fe52b8fede.tar.bz2
mpv-749f5c8d65056763398aad5e9eb786fe52b8fede.tar.xz
cocoa-cb: fix crash with forced iGPU on some multi GPU systems
there were actually a few small problems. the fatalError() function wasn't supposed to be called there and caused an "Illegal instruction". this was replaced by a print and exit() call. the second problem was that cocoa returns a kCGLBadPixelFormat instead of a kCGLBadAttribute error, which broke our check, immediately exited our loop and no working pixel format was ever created. the third problem was that macOS 10.12 didn't return any errors but also didn't return a pixel format, that also broke our check. now the code checks for both cases. Fixes #5631
-rw-r--r--video/out/cocoa-cb/video_layer.swift8
1 files changed, 5 insertions, 3 deletions
diff --git a/video/out/cocoa-cb/video_layer.swift b/video/out/cocoa-cb/video_layer.swift
index 8cdb692ae5..51d14f84a3 100644
--- a/video/out/cocoa-cb/video_layer.swift
+++ b/video/out/cocoa-cb/video_layer.swift
@@ -166,7 +166,7 @@ class VideoLayer: CAOpenGLLayer {
for index in stride(from: glAttributes.count-2, through: 4, by: -1) {
err = CGLChoosePixelFormat(glAttributes, &pix, &npix)
- if err == kCGLBadAttribute {
+ if err == kCGLBadAttribute || err == kCGLBadPixelFormat || pix == nil {
glAttributes.remove(at: index)
} else {
break verLoop
@@ -174,8 +174,10 @@ class VideoLayer: CAOpenGLLayer {
}
}
- if err != kCGLNoError {
- fatalError("Couldn't create CGL pixel format: \(CGLErrorString(err)) (\(err))")
+ if err != kCGLNoError || pix == nil {
+ let errS = String(cString: CGLErrorString(err))
+ print("Couldn't create CGL pixel format: \(errS) (\(err.rawValue))")
+ exit(1)
}
return pix!
}