fix: preserve app identity through FFmpeg preflight

This commit is contained in:
2026-10-11 02:10:43 +02:00
parent cf24a0fc4f
commit 5f0287f489
7 changed files with 155 additions and 17 deletions
+10 -6
View File
@@ -9,13 +9,17 @@ enum TerebiBootstrap {
if let error = FFmpegRuntime.error(for: app) {
fail(error)
}
let payload = app.appendingPathComponent("Contents/MacOS/terebi-player")
let errorCode = payload.path.withCString { path in
_ = execv(path, CommandLine.unsafeArgv)
return errno
let payload = app.appendingPathComponent("Contents/Frameworks/libterebi-player.dylib")
guard let library = dlopen(payload.path, RTLD_NOW | RTLD_LOCAL) else {
let detail = dlerror().map { String(cString: $0) } ?? "The dynamic loader could not load the player."
fail("Could not load the player: \(detail)\n\nPlayer library: \(payload.path)\nRebuild and reinstall terebi.")
}
let detail = String(cString: strerror(errorCode))
fail("Could not start the player: \(detail)\n\nPlayer executable: \(payload.path)\nRebuild and reinstall terebi.")
guard let entry = dlsym(library, "terebi_app_main") else {
fail("The player library is missing its application entry point. Rebuild and reinstall terebi.")
}
// Keep the declared app executable alive so LaunchServices retains its identity.
typealias PlayerMain = @convention(c) () -> Void
unsafeBitCast(entry, to: PlayerMain.self)()
}
private static func fail(_ message: String) -> Never {