about summary refs log tree commit diff
path: root/pkgs/applications/video/mpv
diff options
context:
space:
mode:
authorAnderson Torres <torres.anderson.85@protonmail.com>2024-06-08 13:32:43 -0300
committerAnderson Torres <torres.anderson.85@protonmail.com>2024-06-08 13:33:40 -0300
commit6ee4b2de1a5c9c77593a4d3cd23b46a4a1982c22 (patch)
treeaf22fd2b6ef2c1742087d8b067eb9a4af0178d47 /pkgs/applications/video/mpv
parentc14b678b5a4bcac678f866f626e3b2a18054ceec (diff)
mpv: fix build on Darwin (patch by marsam)
Diffstat (limited to 'pkgs/applications/video/mpv')
-rw-r--r--pkgs/applications/video/mpv/0001-fix-darwin-build.patch29
-rw-r--r--pkgs/applications/video/mpv/default.nix8
2 files changed, 35 insertions, 2 deletions
diff --git a/pkgs/applications/video/mpv/0001-fix-darwin-build.patch b/pkgs/applications/video/mpv/0001-fix-darwin-build.patch
new file mode 100644
index 0000000000000..c7e486a3c5d14
--- /dev/null
+++ b/pkgs/applications/video/mpv/0001-fix-darwin-build.patch
@@ -0,0 +1,29 @@
+--- a/osdep/mac/input_helper.swift
++++ b/osdep/mac/input_helper.swift
+@@ -18,6 +18,14 @@
+ import Cocoa
+ import Carbon.HIToolbox
+ 
++extension NSCondition {
++    fileprivate func withLock<T>(_ body: () throws -> T) rethrows -> T {
++        self.lock()
++        defer { self.unlock() }
++        return try body()
++    }
++}
++
+ class InputHelper: NSObject {
+     var option: OptionHelper?
+     var lock = NSCondition()
+--- a/audio/out/ao_avfoundation.m
++++ b/audio/out/ao_avfoundation.m
+@@ -312,7 +312,8 @@
+
++    #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 120000
+     p->observer = [[AVObserver alloc] initWithAO:ao];
+     NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
+     [center addObserver:p->observer selector:@selector(handleRestartNotification:) name:AVSampleBufferAudioRendererOutputConfigurationDidChangeNotification object:p->renderer];
+     [center addObserver:p->observer selector:@selector(handleRestartNotification:) name:AVSampleBufferAudioRendererWasFlushedAutomaticallyNotification object:p->renderer];
+-
++    #endif
+     return CONTROL_OK;
diff --git a/pkgs/applications/video/mpv/default.nix b/pkgs/applications/video/mpv/default.nix
index a1132b594c38b..b5672d7afa46d 100644
--- a/pkgs/applications/video/mpv/default.nix
+++ b/pkgs/applications/video/mpv/default.nix
@@ -88,7 +88,7 @@
   pulseSupport ? config.pulseaudio or stdenv.isLinux,
   rubberbandSupport ? true,
   screenSaverSupport ? true,
-  sdl2Support ? true,
+  sdl2Support ? !stdenv.isDarwin,
   sixelSupport ? false,
   speexSupport ? true,
   swiftSupport ? stdenv.isDarwin,
@@ -152,6 +152,11 @@ stdenv'.mkDerivation (finalAttrs: {
     hash = "sha256-dFajnCpGlNqUv33A8eFEn8kjtzIPkcBY5j0gNVlaiIY=";
   };
 
+  patches = [
+    # Fix build with Darwin SDK 11
+    ./0001-fix-darwin-build.patch
+  ];
+
   postPatch = lib.concatStringsSep "\n" [
     # Don't reference compile time dependencies or create a build outputs cycle
     # between out and dev
@@ -355,7 +360,6 @@ stdenv'.mkDerivation (finalAttrs: {
       mpv is a free and open-source general-purpose video player, based on the
       MPlayer and mplayer2 projects, with great improvements above both.
     '';
-    broken = stdenv.isDarwin; # Yet another SDK incompatibility...
     changelog = "https://github.com/mpv-player/mpv/releases/tag/v${finalAttrs.version}";
     license = lib.licenses.gpl2Plus;
     mainProgram = "mpv";