From 4763e052eee665618f9fb5e2d26314bf3cfa52aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Thu, 26 Oct 2023 02:07:06 +0200 Subject: [PATCH] ci --- audio/out/ao_wasapi.h | 2 +- input/input.c | 2 +- input/ipc-win.c | 2 +- meson.build | 79 +- osdep/apple_utils.c | 39 - osdep/apple_utils.h | 28 - osdep/language-apple.c | 45 - osdep/macOS_swift_bridge.h | 57 -- osdep/macos/libmpv_helper.swift | 250 ------ osdep/macos/log_helper.swift | 47 - osdep/macos/mpv_helper.swift | 156 ---- osdep/macos/precise_timer.swift | 153 ---- osdep/macos/remote_command_center.swift | 194 ---- osdep/macos/swift_compat.swift | 70 -- osdep/macos/swift_extensions.swift | 89 -- osdep/macosx_application.h | 55 -- osdep/macosx_application.m | 380 -------- osdep/macosx_application_objc.h | 40 - osdep/macosx_compat.h | 63 -- osdep/macosx_events.h | 36 - osdep/macosx_events.m | 410 --------- osdep/macosx_events_objc.h | 45 - osdep/macosx_menubar.h | 30 - osdep/macosx_menubar.m | 835 ------------------ osdep/macosx_menubar_objc.h | 25 - osdep/macosx_touchbar.h | 46 - osdep/macosx_touchbar.m | 334 ------- osdep/macosx_versions.h | 33 - osdep/main-fn-cocoa.c | 10 - osdep/meson.build | 118 +-- osdep/path-darwin.c | 77 -- osdep/path-macosx.m | 34 - osdep/semaphore.h | 59 -- osdep/semaphore_osx.c | 123 --- osdep/terminal-dummy.c | 35 - osdep/timer-darwin.c | 48 - osdep/{language-posix.c => unix/language.c} | 0 osdep/{main-fn-unix.c => unix/main-fn.c} | 0 osdep/{path-unix.c => unix/path.c} | 0 osdep/{ => unix}/poll_wrapper.c | 0 osdep/{ => unix}/poll_wrapper.h | 0 .../{subprocess-posix.c => unix/subprocess.c} | 0 osdep/{terminal-unix.c => unix/terminal.c} | 2 +- osdep/{timer-linux.c => unix/timer.c} | 3 +- osdep/{path-uwp.c => uwp/path.c} | 0 .../console.c} | 0 osdep/{glob-win.c => win32/glob.c} | 0 osdep/{w32_keyboard.c => win32/keyboard.c} | 2 +- osdep/{w32_keyboard.h => win32/keyboard.h} | 0 osdep/{language-win.c => win32/language.c} | 0 osdep/{main-fn-win.c => win32/main-fn.c} | 0 osdep/win32/meson.build | 0 osdep/{ => win32}/mpv.exe.manifest | 0 osdep/{ => win32}/mpv.rc | 0 osdep/{path-win.c => win32/path.c} | 0 .../{subprocess-win.c => win32/subprocess.c} | 2 +- osdep/{terminal-win.c => win32/terminal.c} | 4 +- osdep/{timer-win32.c => win32/timer.c} | 2 +- osdep/{windows_utils.c => win32/utils.c} | 2 +- osdep/{windows_utils.h => win32/utils.h} | 0 player/main.c | 2 +- player/meson.build | 2 +- test/meson.build | 2 +- video/d3d.c | 2 +- video/filter/vf_d3d11vpp.c | 2 +- video/out/cocoa/events_view.m | 2 +- video/out/cocoa/video_view.m | 2 +- video/out/cocoa/window.m | 4 +- video/out/cocoa_common.m | 8 +- video/out/d3d11/context.c | 2 +- video/out/d3d11/hwdec_d3d11va.c | 2 +- video/out/d3d11/hwdec_dxva2dxgi.c | 2 +- video/out/d3d11/ra_d3d11.c | 2 +- video/out/drm_common.c | 4 +- video/out/gpu/d3d11_helpers.c | 2 +- video/out/gpu_next/context.c | 2 +- video/out/opengl/context_angle.c | 2 +- video/out/opengl/context_cocoa.c | 2 +- video/out/opengl/context_dxinterop.c | 2 +- video/out/opengl/hwdec_d3d11egl.c | 2 +- video/out/opengl/hwdec_dxva2egl.c | 2 +- video/out/opengl/hwdec_dxva2gldx.c | 2 +- video/out/vo_gpu_next.c | 2 +- video/out/w32_common.c | 2 +- video/out/wayland_common.c | 2 +- video/out/win32/droptarget.c | 2 +- video/out/x11_common.c | 2 +- 87 files changed, 144 insertions(+), 3986 deletions(-) delete mode 100644 osdep/apple_utils.c delete mode 100644 osdep/apple_utils.h delete mode 100644 osdep/language-apple.c delete mode 100644 osdep/macOS_swift_bridge.h delete mode 100644 osdep/macos/libmpv_helper.swift delete mode 100644 osdep/macos/log_helper.swift delete mode 100644 osdep/macos/mpv_helper.swift delete mode 100644 osdep/macos/precise_timer.swift delete mode 100644 osdep/macos/remote_command_center.swift delete mode 100644 osdep/macos/swift_compat.swift delete mode 100644 osdep/macos/swift_extensions.swift delete mode 100644 osdep/macosx_application.h delete mode 100644 osdep/macosx_application.m delete mode 100644 osdep/macosx_application_objc.h delete mode 100644 osdep/macosx_compat.h delete mode 100644 osdep/macosx_events.h delete mode 100644 osdep/macosx_events.m delete mode 100644 osdep/macosx_events_objc.h delete mode 100644 osdep/macosx_menubar.h delete mode 100644 osdep/macosx_menubar.m delete mode 100644 osdep/macosx_menubar_objc.h delete mode 100644 osdep/macosx_touchbar.h delete mode 100644 osdep/macosx_touchbar.m delete mode 100644 osdep/macosx_versions.h delete mode 100644 osdep/main-fn-cocoa.c delete mode 100644 osdep/path-darwin.c delete mode 100644 osdep/path-macosx.m delete mode 100644 osdep/semaphore.h delete mode 100644 osdep/semaphore_osx.c delete mode 100644 osdep/terminal-dummy.c delete mode 100644 osdep/timer-darwin.c rename osdep/{language-posix.c => unix/language.c} (100%) rename osdep/{main-fn-unix.c => unix/main-fn.c} (100%) rename osdep/{path-unix.c => unix/path.c} (100%) rename osdep/{ => unix}/poll_wrapper.c (100%) rename osdep/{ => unix}/poll_wrapper.h (100%) rename osdep/{subprocess-posix.c => unix/subprocess.c} (100%) rename osdep/{terminal-unix.c => unix/terminal.c} (99%) rename osdep/{timer-linux.c => unix/timer.c} (98%) rename osdep/{path-uwp.c => uwp/path.c} (100%) rename osdep/{win32-console-wrapper.c => win32/console.c} (100%) rename osdep/{glob-win.c => win32/glob.c} (100%) rename osdep/{w32_keyboard.c => win32/keyboard.c} (99%) rename osdep/{w32_keyboard.h => win32/keyboard.h} (100%) rename osdep/{language-win.c => win32/language.c} (100%) rename osdep/{main-fn-win.c => win32/main-fn.c} (100%) create mode 100644 osdep/win32/meson.build rename osdep/{ => win32}/mpv.exe.manifest (100%) rename osdep/{ => win32}/mpv.rc (100%) rename osdep/{path-win.c => win32/path.c} (100%) rename osdep/{subprocess-win.c => win32/subprocess.c} (99%) rename osdep/{terminal-win.c => win32/terminal.c} (99%) rename osdep/{timer-win32.c => win32/timer.c} (99%) rename osdep/{windows_utils.c => win32/utils.c} (99%) rename osdep/{windows_utils.h => win32/utils.h} (100%) diff --git a/audio/out/ao_wasapi.h b/audio/out/ao_wasapi.h index 17b8f7a6d7c2f..24a9aa2cb37eb 100644 --- a/audio/out/ao_wasapi.h +++ b/audio/out/ao_wasapi.h @@ -31,7 +31,7 @@ #include #include "common/msg.h" -#include "osdep/windows_utils.h" +#include #include "internal.h" #include "ao.h" diff --git a/input/input.c b/input/input.c index 9d50abb50d8fa..4e62f1a31e1bd 100644 --- a/input/input.c +++ b/input/input.c @@ -51,7 +51,7 @@ #include "common/common.h" #if HAVE_COCOA -#include "osdep/macosx_events.h" +#include "events.h" #endif #define input_lock(ictx) pthread_mutex_lock(&ictx->mutex) diff --git a/input/ipc-win.c b/input/ipc-win.c index aec754a281f9e..eccbd01c3cded 100644 --- a/input/ipc-win.c +++ b/input/ipc-win.c @@ -20,7 +20,7 @@ #include "osdep/io.h" #include "osdep/threads.h" -#include "osdep/windows_utils.h" +#include #include "common/common.h" #include "common/global.h" diff --git a/meson.build b/meson.build index 2e4acb78eaf16..da79f3bf5a252 100644 --- a/meson.build +++ b/meson.build @@ -246,7 +246,7 @@ sources = files( ## osdep 'osdep/io.c', - 'osdep/semaphore_osx.c', + 'osdep/darwin/semaphore.c', 'osdep/subprocess.c', 'osdep/threads.c', 'osdep/timer.c', @@ -395,13 +395,13 @@ cocoa = dependency('appleframeworks', modules: ['Cocoa', 'IOKit', 'QuartzCore'], features += {'cocoa': cocoa.found()} if features['cocoa'] dependencies += cocoa - sources += files('osdep/apple_utils.c', - 'osdep/language-apple.c', - 'osdep/macosx_application.m', - 'osdep/macosx_events.m', - 'osdep/macosx_menubar.m', - 'osdep/main-fn-cocoa.c', - 'osdep/path-macosx.m', + sources += files('osdep/darwin/utils.c', + 'osdep/darwin/language.c', + 'osdep/darwin/application.m', + 'osdep/darwin/events.m', + 'osdep/darwin/menubar.m', + 'osdep/darwin/main-fn.c', + 'osdep/darwin/path.m', 'video/out/cocoa_common.m', 'video/out/cocoa/events_view.m', 'video/out/cocoa/video_view.m', @@ -409,26 +409,26 @@ if features['cocoa'] endif if posix - path_source = files('osdep/path-unix.c') - subprocess_source = files('osdep/subprocess-posix.c') + path_source = files('osdep/unix/path.c') + subprocess_source = files('osdep/unix/subprocess.c') sources += files('input/ipc-unix.c', - 'osdep/poll_wrapper.c', - 'osdep/terminal-unix.c', + 'osdep/unix/poll_wrapper.c', + 'osdep/unix/terminal.c', 'sub/filter_regex.c') endif if posix and not features['cocoa'] - sources += files('osdep/main-fn-unix.c', - 'osdep/language-posix.c') + sources += files('osdep/unix/main-fn.c', + 'osdep/unix/language.c') endif if darwin - path_source = files('osdep/path-darwin.c') - timer_source = files('osdep/timer-darwin.c') + path_source = files('osdep/darwin/path.c') + timer_source = files('osdep/darwin/timer.c') endif if posix and not darwin - timer_source = files('osdep/timer-linux.c') + timer_source = files('osdep/unix/timer.c') endif features += {'ppoll': cc.has_function('ppoll', args: '-D_GNU_SOURCE', @@ -479,15 +479,15 @@ uwp = cc.find_library('windowsapp', required: uwp_opt) features += {'uwp': uwp.found()} if features['uwp'] dependencies += uwp - path_source = files('osdep/path-uwp.c') + path_source = files('osdep/uwp/path.c') subprocess_source = [] endif features += {'win32-executable': win32 and get_option('cplayer')} if win32 - timer_source = files('osdep/timer-win32.c') - sources += files('osdep/w32_keyboard.c', - 'osdep/windows_utils.c') + timer_source = files('osdep/win32/timer.c') + sources += files('osdep/win32/keyboard.c', + 'osdep/win32/utils.c') endif features += {'win32-desktop': win32 and not uwp.found()} @@ -501,12 +501,12 @@ if features['win32-desktop'] cc.find_library('version'), cc.find_library('winmm')] dependencies += win32_desktop_libs - path_source = files('osdep/path-win.c') - subprocess_source = files('osdep/subprocess-win.c') + path_source = files('osdep/win32/path.c') + subprocess_source = files('osdep/win32/subprocess.c') sources += files('input/ipc-win.c', - 'osdep/language-win.c', - 'osdep/main-fn-win.c', - 'osdep/terminal-win.c', + 'osdep/win32/language.c', + 'osdep/win32/main-fn.c', + 'osdep/win32/terminal.c', 'video/out/w32_common.c', 'video/out/win32/displayconfig.c', 'video/out/win32/droptarget.c') @@ -519,12 +519,12 @@ endif features += {'glob-posix': cc.has_function('glob', prefix: '#include ')} -features += {'glob-win32': win32 and not posix} +features += {'glob-win32': win32 and not features['glob-posix']} if features['glob-win32'] - sources += files('osdep/glob-win.c') + sources += files('osdep/win32/glob.c') endif -features += {'glob': features['glob-posix'] or features['glob-win32']} +features += {'glob': features['glob-posix']} features += {'vt.h': cc.has_header_symbol('sys/vt.h', 'VT_GETMODE')} @@ -589,6 +589,9 @@ if darwin subdir(join_paths('TOOLS', 'osxbundle')) endif +if win32 + subdir('osdep' / 'win32') +endif # misc dependencies features += {'av-channel-layout': libavutil.version().version_compare('>= 57.24.100')} @@ -1530,12 +1533,12 @@ features += {'swift': swift.allowed()} swift_sources = [] if features['cocoa'] and features['swift'] - swift_sources += files('osdep/macos/libmpv_helper.swift', - 'osdep/macos/log_helper.swift', - 'osdep/macos/mpv_helper.swift', - 'osdep/macos/precise_timer.swift', - 'osdep/macos/swift_compat.swift', - 'osdep/macos/swift_extensions.swift', + swift_sources += files('osdep/darwin/libmpv_helper.swift', + 'osdep/darwin/log_helper.swift', + 'osdep/darwin/mpv_helper.swift', + 'osdep/darwin/precise_timer.swift', + 'osdep/darwin/swift_compat.swift', + 'osdep/darwin/swift_extensions.swift', 'video/out/mac/common.swift', 'video/out/mac/title_bar.swift', 'video/out/mac/view.swift', @@ -1563,7 +1566,7 @@ macos_media_player = get_option('macos-media-player').require( ) features += {'macos-media-player': macos_media_player.allowed()} if features['macos-media-player'] - swift_sources += files('osdep/macos/remote_command_center.swift') + swift_sources += files('osdep/darwin/remote_command_center.swift') endif if features['swift'] and swift_sources.length() > 0 @@ -1703,9 +1706,9 @@ if win32 'etc/mpv-icon-8bit-64x64.png', 'etc/mpv-icon-8bit-128x128.png', 'etc/mpv-icon.ico', - 'osdep/mpv.exe.manifest'] + 'osdep/win32/mpv.exe.manifest'] - sources += windows.compile_resources('osdep/mpv.rc', args: res_flags, depend_files: resources, + sources += windows.compile_resources('osdep/win32/mpv.rc', args: res_flags, depend_files: resources, depends: version_h, include_directories: res_includes) endif diff --git a/osdep/apple_utils.c b/osdep/apple_utils.c deleted file mode 100644 index 02cdfaa95abb9..0000000000000 --- a/osdep/apple_utils.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Apple-specific utility functions - * - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -#include "apple_utils.h" - -#include "mpv_talloc.h" - -CFStringRef cfstr_from_cstr(const char *str) -{ - return CFStringCreateWithCString(NULL, str, kCFStringEncodingUTF8); -} - -char *cfstr_get_cstr(const CFStringRef cfstr) -{ - if (!cfstr) - return NULL; - CFIndex size = - CFStringGetMaximumSizeForEncoding( - CFStringGetLength(cfstr), kCFStringEncodingUTF8) + 1; - char *buffer = talloc_zero_size(NULL, size); - CFStringGetCString(cfstr, buffer, size, kCFStringEncodingUTF8); - return buffer; -} diff --git a/osdep/apple_utils.h b/osdep/apple_utils.h deleted file mode 100644 index 166937e1ea3e7..0000000000000 --- a/osdep/apple_utils.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Apple-specific utility functions - * - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -#ifndef MPV_APPLE_UTILS -#define MPV_APPLE_UTILS - -#include - -CFStringRef cfstr_from_cstr(const char *str); -char *cfstr_get_cstr(const CFStringRef cfstr); - -#endif /* MPV_APPLE_UTILS */ diff --git a/osdep/language-apple.c b/osdep/language-apple.c deleted file mode 100644 index dc83fb545a264..0000000000000 --- a/osdep/language-apple.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * User language lookup for Apple platforms - * - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -#include "misc/language.h" - -#include "apple_utils.h" -#include "mpv_talloc.h" - -char **mp_get_user_langs(void) -{ - CFArrayRef arr = CFLocaleCopyPreferredLanguages(); - if (!arr) - return NULL; - CFIndex count = CFArrayGetCount(arr); - if (!count) - return NULL; - - char **ret = talloc_array_ptrtype(NULL, ret, count + 1); - - for (CFIndex i = 0; i < count; i++) { - CFStringRef cfstr = CFArrayGetValueAtIndex(arr, i); - ret[i] = talloc_steal(ret, cfstr_get_cstr(cfstr)); - } - - ret[count] = NULL; - - CFRelease(arr); - return ret; -} diff --git a/osdep/macOS_swift_bridge.h b/osdep/macOS_swift_bridge.h deleted file mode 100644 index 9407b6fc9b26e..0000000000000 --- a/osdep/macOS_swift_bridge.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -// including frameworks here again doesn't make sense, but otherwise the swift -// compiler doesn't include the needed headers in our generated header file -#import -#import - -#include "player/client.h" -#include "video/out/libmpv.h" -#include "libmpv/render_gl.h" - -#include "options/m_config.h" -#include "player/core.h" -#include "input/input.h" -#include "video/out/win_state.h" - -#include "osdep/macosx_application_objc.h" -#include "osdep/macosx_events_objc.h" - - -// complex macros won't get imported to Swift so we have to reassign them -static int SWIFT_MBTN_LEFT = MP_MBTN_LEFT; -static int SWIFT_MBTN_MID = MP_MBTN_MID; -static int SWIFT_MBTN_RIGHT = MP_MBTN_RIGHT; -static int SWIFT_WHEEL_UP = MP_WHEEL_UP; -static int SWIFT_WHEEL_DOWN = MP_WHEEL_DOWN; -static int SWIFT_WHEEL_LEFT = MP_WHEEL_LEFT; -static int SWIFT_WHEEL_RIGHT = MP_WHEEL_RIGHT; -static int SWIFT_MBTN_BACK = MP_MBTN_BACK; -static int SWIFT_MBTN_FORWARD = MP_MBTN_FORWARD; -static int SWIFT_MBTN9 = MP_MBTN9; - -static int SWIFT_KEY_MOUSE_LEAVE = MP_KEY_MOUSE_LEAVE; -static int SWIFT_KEY_MOUSE_ENTER = MP_KEY_MOUSE_ENTER; - -// only used from Swift files and therefore seen as unused by the c compiler -static void SWIFT_TARRAY_STRING_APPEND(void *t, char ***a, int *i, char *s) __attribute__ ((unused)); - -static void SWIFT_TARRAY_STRING_APPEND(void *t, char ***a, int *i, char *s) -{ - MP_TARRAY_APPEND(t, *a, *i, s); -} diff --git a/osdep/macos/libmpv_helper.swift b/osdep/macos/libmpv_helper.swift deleted file mode 100644 index 8b1c697da2be1..0000000000000 --- a/osdep/macos/libmpv_helper.swift +++ /dev/null @@ -1,250 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -import Cocoa -import OpenGL.GL -import OpenGL.GL3 - -let glDummy: @convention(c) () -> Void = {} - -class LibmpvHelper { - var log: LogHelper - var mpvHandle: OpaquePointer? - var mpvRenderContext: OpaquePointer? - var macOptsPtr: UnsafeMutableRawPointer? - var macOpts: macos_opts = macos_opts() - var fbo: GLint = 1 - let deinitLock = NSLock() - - init(_ mpv: OpaquePointer, _ mpLog: OpaquePointer?) { - mpvHandle = mpv - log = LogHelper(mpLog) - - guard let app = NSApp as? Application, - let ptr = mp_get_config_group(nil, - mp_client_get_global(mpvHandle), - app.getMacOSConf()) else - { - log.sendError("macOS config group couldn't be retrieved'") - exit(1) - } - macOptsPtr = ptr - macOpts = UnsafeMutablePointer(OpaquePointer(ptr)).pointee - } - - func initRender() { - let advanced: CInt = 1 - let api = UnsafeMutableRawPointer(mutating: (MPV_RENDER_API_TYPE_OPENGL as NSString).utf8String) - let pAddress = mpv_opengl_init_params(get_proc_address: getProcAddress, - get_proc_address_ctx: nil) - - MPVHelper.withUnsafeMutableRawPointers([pAddress, advanced]) { (pointers: [UnsafeMutableRawPointer?]) in - var params: [mpv_render_param] = [ - mpv_render_param(type: MPV_RENDER_PARAM_API_TYPE, data: api), - mpv_render_param(type: MPV_RENDER_PARAM_OPENGL_INIT_PARAMS, data: pointers[0]), - mpv_render_param(type: MPV_RENDER_PARAM_ADVANCED_CONTROL, data: pointers[1]), - mpv_render_param() - ] - - if (mpv_render_context_create(&mpvRenderContext, mpvHandle, ¶ms) < 0) { - log.sendError("Render context init has failed.") - exit(1) - } - } - - } - - let getProcAddress: (@convention(c) (UnsafeMutableRawPointer?, UnsafePointer?) - -> UnsafeMutableRawPointer?) = - { - (ctx: UnsafeMutableRawPointer?, name: UnsafePointer?) - -> UnsafeMutableRawPointer? in - let symbol: CFString = CFStringCreateWithCString( - kCFAllocatorDefault, name, kCFStringEncodingASCII) - let identifier = CFBundleGetBundleWithIdentifier("com.apple.opengl" as CFString) - let addr = CFBundleGetFunctionPointerForName(identifier, symbol) - - if symbol as String == "glFlush" { - return unsafeBitCast(glDummy, to: UnsafeMutableRawPointer.self) - } - - return addr - } - - func setRenderUpdateCallback(_ callback: @escaping mpv_render_update_fn, context object: AnyObject) { - if mpvRenderContext == nil { - log.sendWarning("Init mpv render context first.") - } else { - mpv_render_context_set_update_callback(mpvRenderContext, callback, MPVHelper.bridge(obj: object)) - } - } - - func setRenderControlCallback(_ callback: @escaping mp_render_cb_control_fn, context object: AnyObject) { - if mpvRenderContext == nil { - log.sendWarning("Init mpv render context first.") - } else { - mp_render_context_set_control_callback(mpvRenderContext, callback, MPVHelper.bridge(obj: object)) - } - } - - func reportRenderFlip() { - if mpvRenderContext == nil { return } - mpv_render_context_report_swap(mpvRenderContext) - } - - func isRenderUpdateFrame() -> Bool { - deinitLock.lock() - if mpvRenderContext == nil { - deinitLock.unlock() - return false - } - let flags: UInt64 = mpv_render_context_update(mpvRenderContext) - deinitLock.unlock() - return flags & UInt64(MPV_RENDER_UPDATE_FRAME.rawValue) > 0 - } - - func drawRender(_ surface: NSSize, _ depth: GLint, _ ctx: CGLContextObj, skip: Bool = false) { - deinitLock.lock() - if mpvRenderContext != nil { - var i: GLint = 0 - let flip: CInt = 1 - let skip: CInt = skip ? 1 : 0 - let ditherDepth = depth - glGetIntegerv(GLenum(GL_DRAW_FRAMEBUFFER_BINDING), &i) - // CAOpenGLLayer has ownership of FBO zero yet can return it to us, - // so only utilize a newly received FBO ID if it is nonzero. - fbo = i != 0 ? i : fbo - - let data = mpv_opengl_fbo(fbo: Int32(fbo), - w: Int32(surface.width), - h: Int32(surface.height), - internal_format: 0) - - MPVHelper.withUnsafeMutableRawPointers([data, flip, ditherDepth, skip]) { (pointers: [UnsafeMutableRawPointer?]) in - var params: [mpv_render_param] = [ - mpv_render_param(type: MPV_RENDER_PARAM_OPENGL_FBO, data: pointers[0]), - mpv_render_param(type: MPV_RENDER_PARAM_FLIP_Y, data: pointers[1]), - mpv_render_param(type: MPV_RENDER_PARAM_DEPTH, data: pointers[2]), - mpv_render_param(type: MPV_RENDER_PARAM_SKIP_RENDERING, data: pointers[3]), - mpv_render_param() - ] - mpv_render_context_render(mpvRenderContext, ¶ms); - } - } else { - glClearColor(0, 0, 0, 1) - glClear(GLbitfield(GL_COLOR_BUFFER_BIT)) - } - - if !skip { CGLFlushDrawable(ctx) } - - deinitLock.unlock() - } - - func setRenderICCProfile(_ profile: NSColorSpace) { - if mpvRenderContext == nil { return } - guard var iccData = profile.iccProfileData else { - log.sendWarning("Invalid ICC profile data.") - return - } - iccData.withUnsafeMutableBytes { (ptr: UnsafeMutableRawBufferPointer) in - guard let baseAddress = ptr.baseAddress, ptr.count > 0 else { return } - - let u8Ptr = baseAddress.assumingMemoryBound(to: UInt8.self) - let iccBstr = bstrdup(nil, bstr(start: u8Ptr, len: ptr.count)) - var icc = mpv_byte_array(data: iccBstr.start, size: iccBstr.len) - withUnsafeMutableBytes(of: &icc) { (ptr: UnsafeMutableRawBufferPointer) in - let params = mpv_render_param(type: MPV_RENDER_PARAM_ICC_PROFILE, data: ptr.baseAddress) - mpv_render_context_set_parameter(mpvRenderContext, params) - } - } - } - - func setRenderLux(_ lux: Int) { - if mpvRenderContext == nil { return } - var light = lux - withUnsafeMutableBytes(of: &light) { (ptr: UnsafeMutableRawBufferPointer) in - let params = mpv_render_param(type: MPV_RENDER_PARAM_AMBIENT_LIGHT, data: ptr.baseAddress) - mpv_render_context_set_parameter(mpvRenderContext, params) - } - } - - func commandAsync(_ cmd: [String?], id: UInt64 = 1) { - if mpvHandle == nil { return } - var mCmd = cmd - mCmd.append(nil) - var cargs = mCmd.map { $0.flatMap { UnsafePointer(strdup($0)) } } - mpv_command_async(mpvHandle, id, &cargs) - for ptr in cargs { free(UnsafeMutablePointer(mutating: ptr)) } - } - - // Unsafe function when called while using the render API - func command(_ cmd: String) { - if mpvHandle == nil { return } - mpv_command_string(mpvHandle, cmd) - } - - func getBoolProperty(_ name: String) -> Bool { - if mpvHandle == nil { return false } - var value = Int32() - mpv_get_property(mpvHandle, name, MPV_FORMAT_FLAG, &value) - return value > 0 - } - - func getIntProperty(_ name: String) -> Int { - if mpvHandle == nil { return 0 } - var value = Int64() - mpv_get_property(mpvHandle, name, MPV_FORMAT_INT64, &value) - return Int(value) - } - - func getStringProperty(_ name: String) -> String? { - guard let mpv = mpvHandle else { return nil } - guard let value = mpv_get_property_string(mpv, name) else { return nil } - let str = String(cString: value) - mpv_free(value) - return str - } - - func deinitRender() { - mpv_render_context_set_update_callback(mpvRenderContext, nil, nil) - mp_render_context_set_control_callback(mpvRenderContext, nil, nil) - deinitLock.lock() - mpv_render_context_free(mpvRenderContext) - mpvRenderContext = nil - deinitLock.unlock() - } - - func deinitMPV(_ destroy: Bool = false) { - if destroy { - mpv_destroy(mpvHandle) - } - ta_free(macOptsPtr) - macOptsPtr = nil - mpvHandle = nil - } - - // *(char **) MPV_FORMAT_STRING on mpv_event_property - class func mpvStringArrayToString(_ obj: UnsafeMutableRawPointer) -> String? { - let cstr = UnsafeMutablePointer>(OpaquePointer(obj)) - return String(cString: cstr[0]) - } - - // MPV_FORMAT_FLAG - class func mpvFlagToBool(_ obj: UnsafeMutableRawPointer) -> Bool? { - return UnsafePointer(OpaquePointer(obj))?.pointee - } -} diff --git a/osdep/macos/log_helper.swift b/osdep/macos/log_helper.swift deleted file mode 100644 index 94640756bdd65..0000000000000 --- a/osdep/macos/log_helper.swift +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -import Cocoa - -class LogHelper: NSObject { - var log: OpaquePointer? - - init(_ log: OpaquePointer?) { - self.log = log - } - - func sendVerbose(_ msg: String) { - send(message: msg, type: MSGL_V) - } - - func sendInfo(_ msg: String) { - send(message: msg, type: MSGL_INFO) - } - - func sendWarning(_ msg: String) { - send(message: msg, type: MSGL_WARN) - } - - func sendError(_ msg: String) { - send(message: msg, type: MSGL_ERR) - } - - func send(message msg: String, type t: Int) { - let args: [CVarArg] = [ (msg as NSString).utf8String ?? "NO MESSAGE"] - mp_msg_va(log, Int32(t), "%s\n", getVaList(args)) - } -} diff --git a/osdep/macos/mpv_helper.swift b/osdep/macos/mpv_helper.swift deleted file mode 100644 index 3b2a7162cb83b..0000000000000 --- a/osdep/macos/mpv_helper.swift +++ /dev/null @@ -1,156 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -import Cocoa - -typealias swift_wakeup_cb_fn = (@convention(c) (UnsafeMutableRawPointer?) -> Void)? - -class MPVHelper { - var log: LogHelper - var vo: UnsafeMutablePointer - var optsCachePtr: UnsafeMutablePointer - var optsPtr: UnsafeMutablePointer - var macOptsCachePtr: UnsafeMutablePointer - var macOptsPtr: UnsafeMutablePointer - - // these computed properties return a local copy of the struct accessed: - // - don't use if you rely on the pointers - // - only for reading - var vout: vo { get { return vo.pointee } } - var optsCache: m_config_cache { get { return optsCachePtr.pointee } } - var opts: mp_vo_opts { get { return optsPtr.pointee } } - var macOptsCache: m_config_cache { get { return macOptsCachePtr.pointee } } - var macOpts: macos_opts { get { return macOptsPtr.pointee } } - - var input: OpaquePointer { get { return vout.input_ctx } } - - init(_ vo: UnsafeMutablePointer, _ log: LogHelper) { - self.vo = vo - self.log = log - - guard let app = NSApp as? Application, - let cache = m_config_cache_alloc(vo, vo.pointee.global, app.getVoSubConf()) else - { - log.sendError("NSApp couldn't be retrieved") - exit(1) - } - - optsCachePtr = cache - optsPtr = UnsafeMutablePointer(OpaquePointer(cache.pointee.opts)) - - guard let macCache = m_config_cache_alloc(vo, - vo.pointee.global, - app.getMacOSConf()) else - { - // will never be hit, mp_get_config_group asserts for invalid groups - exit(1) - } - macOptsCachePtr = macCache - macOptsPtr = UnsafeMutablePointer(OpaquePointer(macCache.pointee.opts)) - } - - func canBeDraggedAt(_ pos: NSPoint) -> Bool { - let canDrag = !mp_input_test_dragging(input, Int32(pos.x), Int32(pos.y)) - return canDrag - } - - func mouseEnabled() -> Bool { - return mp_input_mouse_enabled(input) - } - - func setMousePosition(_ pos: NSPoint) { - mp_input_set_mouse_pos(input, Int32(pos.x), Int32(pos.y)) - } - - func putAxis(_ mpkey: Int32, delta: Double) { - mp_input_put_wheel(input, mpkey, delta) - } - - func nextChangedOption(property: inout UnsafeMutableRawPointer?) -> Bool { - return m_config_cache_get_next_changed(optsCachePtr, &property) - } - - func setOption(fullscreen: Bool) { - optsPtr.pointee.fullscreen = fullscreen - _ = withUnsafeMutableBytes(of: &optsPtr.pointee.fullscreen) { (ptr: UnsafeMutableRawBufferPointer) in - m_config_cache_write_opt(optsCachePtr, ptr.baseAddress) - } - } - - func setOption(minimized: Bool) { - optsPtr.pointee.window_minimized = minimized - _ = withUnsafeMutableBytes(of: &optsPtr.pointee.window_minimized) { (ptr: UnsafeMutableRawBufferPointer) in - m_config_cache_write_opt(optsCachePtr, ptr.baseAddress) - } - } - - func setOption(maximized: Bool) { - optsPtr.pointee.window_maximized = maximized - _ = withUnsafeMutableBytes(of: &optsPtr.pointee.window_maximized) { (ptr: UnsafeMutableRawBufferPointer) in - m_config_cache_write_opt(optsCachePtr, ptr.baseAddress) - } - } - - func setMacOptionCallback(_ callback: swift_wakeup_cb_fn, context object: AnyObject) { - m_config_cache_set_wakeup_cb(macOptsCachePtr, callback, MPVHelper.bridge(obj: object)) - } - - func nextChangedMacOption(property: inout UnsafeMutableRawPointer?) -> Bool { - return m_config_cache_get_next_changed(macOptsCachePtr, &property) - } - - func command(_ cmd: String) { - let cCmd = UnsafePointer(strdup(cmd)) - let mpvCmd = mp_input_parse_cmd(input, bstr0(cCmd), "") - mp_input_queue_cmd(input, mpvCmd) - free(UnsafeMutablePointer(mutating: cCmd)) - } - - // (__bridge void*) - class func bridge(obj: T) -> UnsafeMutableRawPointer { - return UnsafeMutableRawPointer(Unmanaged.passUnretained(obj).toOpaque()) - } - - // (__bridge T*) - class func bridge(ptr: UnsafeRawPointer) -> T { - return Unmanaged.fromOpaque(ptr).takeUnretainedValue() - } - - class func withUnsafeMutableRawPointers(_ arguments: [Any], - pointers: [UnsafeMutableRawPointer?] = [], - closure: (_ pointers: [UnsafeMutableRawPointer?]) -> Void) { - if arguments.count > 0 { - let args = Array(arguments.dropFirst(1)) - var newPtrs = pointers - var firstArg = arguments.first - withUnsafeMutableBytes(of: &firstArg) { (ptr: UnsafeMutableRawBufferPointer) in - newPtrs.append(ptr.baseAddress) - withUnsafeMutableRawPointers(args, pointers: newPtrs, closure: closure) - } - - return - } - - closure(pointers) - } - - class func getPointer(_ value: inout T) -> UnsafeMutableRawPointer? { - return withUnsafeMutableBytes(of: &value) { (ptr: UnsafeMutableRawBufferPointer) in - ptr.baseAddress - } - } -} diff --git a/osdep/macos/precise_timer.swift b/osdep/macos/precise_timer.swift deleted file mode 100644 index f4ad3bb6b6394..0000000000000 --- a/osdep/macos/precise_timer.swift +++ /dev/null @@ -1,153 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -import Cocoa - -struct Timing { - let time: UInt64 - let closure: () -> () -} - -class PreciseTimer { - unowned var common: Common - var mpv: MPVHelper? { get { return common.mpv } } - - let nanoPerSecond: Double = 1e+9 - let machToNano: Double = { - var timebase: mach_timebase_info = mach_timebase_info() - mach_timebase_info(&timebase) - return Double(timebase.numer) / Double(timebase.denom) - }() - - let condition = NSCondition() - var events: [Timing] = [] - var isRunning: Bool = true - var isHighPrecision: Bool = false - - var thread: pthread_t! - var threadPort: thread_port_t = thread_port_t() - let policyFlavor = thread_policy_flavor_t(THREAD_TIME_CONSTRAINT_POLICY) - let policyCount = MemoryLayout.size / - MemoryLayout.size - var typeNumber: mach_msg_type_number_t { - return mach_msg_type_number_t(policyCount) - } - var threadAttr: pthread_attr_t = { - var attr = pthread_attr_t() - var param = sched_param() - pthread_attr_init(&attr) - param.sched_priority = sched_get_priority_max(SCHED_FIFO) - pthread_attr_setschedparam(&attr, ¶m) - pthread_attr_setschedpolicy(&attr, SCHED_FIFO) - return attr - }() - - init?(common com: Common) { - common = com - - pthread_create(&thread, &threadAttr, entryC, MPVHelper.bridge(obj: self)) - if thread == nil { - common.log.sendWarning("Couldn't create pthread for high precision timer") - return nil - } - - threadPort = pthread_mach_thread_np(thread) - } - - func updatePolicy(periodSeconds: Double = 1 / 60.0) { - let period = periodSeconds * nanoPerSecond / machToNano - var policy = thread_time_constraint_policy( - period: UInt32(period), - computation: UInt32(0.75 * period), - constraint: UInt32(0.85 * period), - preemptible: 1 - ) - - let success = withUnsafeMutablePointer(to: &policy) { - $0.withMemoryRebound(to: integer_t.self, capacity: policyCount) { - thread_policy_set(threadPort, policyFlavor, $0, typeNumber) - } - } - - isHighPrecision = success == KERN_SUCCESS - if !isHighPrecision { - common.log.sendWarning("Couldn't create a high precision timer") - } - } - - func terminate() { - condition.lock() - isRunning = false - condition.signal() - condition.unlock() - pthread_kill(thread, SIGALRM) - pthread_join(thread, nil) - } - - func scheduleAt(time: UInt64, closure: @escaping () -> ()) { - condition.lock() - let firstEventTime = events.first?.time ?? 0 - let lastEventTime = events.last?.time ?? 0 - events.append(Timing(time: time, closure: closure)) - - if lastEventTime > time { - events.sort{ $0.time < $1.time } - } - - condition.signal() - condition.unlock() - - if firstEventTime > time { - pthread_kill(thread, SIGALRM) - } - } - - let threadSignal: @convention(c) (Int32) -> () = { (sig: Int32) in } - - let entryC: @convention(c) (UnsafeMutableRawPointer) -> UnsafeMutableRawPointer? = { (ptr: UnsafeMutableRawPointer) in - let ptimer: PreciseTimer = MPVHelper.bridge(ptr: ptr) - ptimer.entry() - return nil - } - - func entry() { - signal(SIGALRM, threadSignal) - - while isRunning { - condition.lock() - while events.count == 0 && isRunning { - condition.wait() - } - - if !isRunning { break } - - guard let event = events.first else { - continue - } - condition.unlock() - - mach_wait_until(event.time) - - condition.lock() - if events.first?.time == event.time && isRunning { - event.closure() - events.removeFirst() - } - condition.unlock() - } - } -} diff --git a/osdep/macos/remote_command_center.swift b/osdep/macos/remote_command_center.swift deleted file mode 100644 index d97cb3328c21f..0000000000000 --- a/osdep/macos/remote_command_center.swift +++ /dev/null @@ -1,194 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -import MediaPlayer - -@available(macOS 10.12.2, *) -class RemoteCommandCenter: NSObject { - enum KeyType { - case normal - case repeatable - } - - var config: [MPRemoteCommand:[String:Any]] = [ - MPRemoteCommandCenter.shared().pauseCommand: [ - "mpKey": MP_KEY_PAUSEONLY, - "keyType": KeyType.normal - ], - MPRemoteCommandCenter.shared().playCommand: [ - "mpKey": MP_KEY_PLAYONLY, - "keyType": KeyType.normal - ], - MPRemoteCommandCenter.shared().stopCommand: [ - "mpKey": MP_KEY_STOP, - "keyType": KeyType.normal - ], - MPRemoteCommandCenter.shared().nextTrackCommand: [ - "mpKey": MP_KEY_NEXT, - "keyType": KeyType.normal - ], - MPRemoteCommandCenter.shared().previousTrackCommand: [ - "mpKey": MP_KEY_PREV, - "keyType": KeyType.normal - ], - MPRemoteCommandCenter.shared().togglePlayPauseCommand: [ - "mpKey": MP_KEY_PLAY, - "keyType": KeyType.normal - ], - MPRemoteCommandCenter.shared().seekForwardCommand: [ - "mpKey": MP_KEY_FORWARD, - "keyType": KeyType.repeatable, - "state": MP_KEY_STATE_UP - ], - MPRemoteCommandCenter.shared().seekBackwardCommand: [ - "mpKey": MP_KEY_REWIND, - "keyType": KeyType.repeatable, - "state": MP_KEY_STATE_UP - ], - ] - - var nowPlayingInfo: [String: Any] = [ - MPNowPlayingInfoPropertyMediaType: NSNumber(value: MPNowPlayingInfoMediaType.video.rawValue), - MPNowPlayingInfoPropertyDefaultPlaybackRate: NSNumber(value: 1), - MPNowPlayingInfoPropertyPlaybackProgress: NSNumber(value: 0.0), - MPMediaItemPropertyPlaybackDuration: NSNumber(value: 0), - MPMediaItemPropertyTitle: "mpv", - MPMediaItemPropertyAlbumTitle: "mpv", - MPMediaItemPropertyArtist: "mpv", - ] - - let disabledCommands: [MPRemoteCommand] = [ - MPRemoteCommandCenter.shared().changePlaybackRateCommand, - MPRemoteCommandCenter.shared().changeRepeatModeCommand, - MPRemoteCommandCenter.shared().changeShuffleModeCommand, - MPRemoteCommandCenter.shared().skipForwardCommand, - MPRemoteCommandCenter.shared().skipBackwardCommand, - MPRemoteCommandCenter.shared().changePlaybackPositionCommand, - MPRemoteCommandCenter.shared().enableLanguageOptionCommand, - MPRemoteCommandCenter.shared().disableLanguageOptionCommand, - MPRemoteCommandCenter.shared().ratingCommand, - MPRemoteCommandCenter.shared().likeCommand, - MPRemoteCommandCenter.shared().dislikeCommand, - MPRemoteCommandCenter.shared().bookmarkCommand, - ] - - var mpInfoCenter: MPNowPlayingInfoCenter { get { return MPNowPlayingInfoCenter.default() } } - var isPaused: Bool = false { didSet { updatePlaybackState() } } - - @objc override init() { - super.init() - - for cmd in disabledCommands { - cmd.isEnabled = false - } - } - - @objc func start() { - for (cmd, _) in config { - cmd.isEnabled = true - cmd.addTarget { [unowned self] event in - return self.cmdHandler(event) - } - } - - if let app = NSApp as? Application, let icon = app.getMPVIcon(), - #available(macOS 10.13.2, *) - { - let albumArt = MPMediaItemArtwork(boundsSize: icon.size) { _ in - return icon - } - nowPlayingInfo[MPMediaItemPropertyArtwork] = albumArt - } - - mpInfoCenter.nowPlayingInfo = nowPlayingInfo - mpInfoCenter.playbackState = .playing - - NotificationCenter.default.addObserver( - self, - selector: #selector(self.makeCurrent), - name: NSApplication.willBecomeActiveNotification, - object: nil - ) - } - - @objc func stop() { - for (cmd, _) in config { - cmd.isEnabled = false - cmd.removeTarget(nil) - } - - mpInfoCenter.nowPlayingInfo = nil - mpInfoCenter.playbackState = .unknown - } - - @objc func makeCurrent(notification: NSNotification) { - mpInfoCenter.playbackState = .paused - mpInfoCenter.playbackState = .playing - updatePlaybackState() - } - - func updatePlaybackState() { - mpInfoCenter.playbackState = isPaused ? .paused : .playing - } - - func cmdHandler(_ event: MPRemoteCommandEvent) -> MPRemoteCommandHandlerStatus { - guard let cmdConfig = config[event.command], - let mpKey = cmdConfig["mpKey"] as? Int32, - let keyType = cmdConfig["keyType"] as? KeyType else - { - return .commandFailed - } - - var state = cmdConfig["state"] as? UInt32 ?? 0 - - if let currentState = cmdConfig["state"] as? UInt32, keyType == .repeatable { - state = MP_KEY_STATE_DOWN - config[event.command]?["state"] = MP_KEY_STATE_DOWN - if currentState == MP_KEY_STATE_DOWN { - state = MP_KEY_STATE_UP - config[event.command]?["state"] = MP_KEY_STATE_UP - } - } - - EventsResponder.sharedInstance().handleMPKey(mpKey, withMask: Int32(state)) - - return .success - } - - @objc func processEvent(_ event: UnsafeMutablePointer) { - switch event.pointee.event_id { - case MPV_EVENT_PROPERTY_CHANGE: - handlePropertyChange(event) - default: - break - } - } - - func handlePropertyChange(_ event: UnsafeMutablePointer) { - let pData = OpaquePointer(event.pointee.data) - guard let property = UnsafePointer(pData)?.pointee else { - return - } - - switch String(cString: property.name) { - case "pause" where property.format == MPV_FORMAT_FLAG: - isPaused = LibmpvHelper.mpvFlagToBool(property.data) ?? false - default: - break - } - } -} diff --git a/osdep/macos/swift_compat.swift b/osdep/macos/swift_compat.swift deleted file mode 100644 index 24c00b0ae1c51..0000000000000 --- a/osdep/macos/swift_compat.swift +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -#if !HAVE_MACOS_10_14_FEATURES -extension NSAppearance.Name { - static let darkAqua: NSAppearance.Name = NSAppearance.Name(rawValue: "NSAppearanceNameDarkAqua") - static let accessibilityHighContrastAqua: NSAppearance.Name = NSAppearance.Name(rawValue: "NSAppearanceNameAccessibilityAqua") - static let accessibilityHighContrastDarkAqua: NSAppearance.Name = NSAppearance.Name(rawValue: "NSAppearanceNameAccessibilityDarkAqua") - static let accessibilityHighContrastVibrantLight: NSAppearance.Name = NSAppearance.Name(rawValue: "NSAppearanceNameAccessibilityVibrantLight") - static let accessibilityHighContrastVibrantDark: NSAppearance.Name = NSAppearance.Name(rawValue: "NSAppearanceNameAccessibilityVibrantDark") -} - -@available(OSX 10.12, *) -extension String { - static let RGBA16Float: String = kCAContentsFormatRGBA16Float - static let RGBA8Uint: String = kCAContentsFormatRGBA8Uint - static let gray8Uint: String = kCAContentsFormatGray8Uint -} -#endif - -extension NSPasteboard.PasteboardType { - static let fileURLCompat: NSPasteboard.PasteboardType = { - if #available(OSX 10.13, *) { - return .fileURL - } else { - return NSPasteboard.PasteboardType(kUTTypeURL as String) - } - } () - - static let URLCompat: NSPasteboard.PasteboardType = { - if #available(OSX 10.13, *) { - return .URL - } else { - return NSPasteboard.PasteboardType(kUTTypeFileURL as String) - } - } () -} - -#if !swift(>=5.0) -extension Data { - mutating func withUnsafeMutableBytes(_ body: (UnsafeMutableRawBufferPointer) throws -> Type) rethrows -> Type { - let dataCount = count - return try withUnsafeMutableBytes { (ptr: UnsafeMutablePointer) throws -> Type in - try body(UnsafeMutableRawBufferPointer(start: ptr, count: dataCount)) - } - } -} -#endif - -#if !swift(>=4.2) -extension NSDraggingInfo { - var draggingPasteboard: NSPasteboard { - get { return draggingPasteboard() } - } -} -#endif diff --git a/osdep/macos/swift_extensions.swift b/osdep/macos/swift_extensions.swift deleted file mode 100644 index a1aeb0abf7c25..0000000000000 --- a/osdep/macos/swift_extensions.swift +++ /dev/null @@ -1,89 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -import Cocoa - -extension NSDeviceDescriptionKey { - static let screenNumber = NSDeviceDescriptionKey("NSScreenNumber") -} - -extension NSScreen { - - public var displayID: CGDirectDisplayID { - get { - return deviceDescription[.screenNumber] as? CGDirectDisplayID ?? 0 - } - } - - public var displayName: String? { - get { - var name: String? = nil - var object: io_object_t - var iter = io_iterator_t() - let matching = IOServiceMatching("IODisplayConnect") - let result = IOServiceGetMatchingServices(kIOMasterPortDefault, matching, &iter) - - if result != KERN_SUCCESS || iter == 0 { return nil } - - repeat { - object = IOIteratorNext(iter) - if let info = IODisplayCreateInfoDictionary(object, IOOptionBits(kIODisplayOnlyPreferredName)).takeRetainedValue() as? [String:AnyObject], - (info[kDisplayVendorID] as? UInt32 == CGDisplayVendorNumber(displayID) && - info[kDisplayProductID] as? UInt32 == CGDisplayModelNumber(displayID) && - info[kDisplaySerialNumber] as? UInt32 ?? 0 == CGDisplaySerialNumber(displayID)) - { - if let productNames = info["DisplayProductName"] as? [String:String], - let productName = productNames.first?.value - { - name = productName - break - } - } - } while object != 0 - - IOObjectRelease(iter) - return name - } - } -} - -extension NSColor { - - convenience init(hex: String) { - let int = Int(hex.dropFirst(), radix: 16) ?? 0 - let alpha = CGFloat((int >> 24) & 0x000000FF)/255 - let red = CGFloat((int >> 16) & 0x000000FF)/255 - let green = CGFloat((int >> 8) & 0x000000FF)/255 - let blue = CGFloat((int) & 0x000000FF)/255 - - self.init(calibratedRed: red, green: green, blue: blue, alpha: alpha) - } -} - -extension Bool { - - init(_ int32: Int32) { - self.init(int32 != 0) - } -} - -extension Int32 { - - init(_ bool: Bool) { - self.init(bool ? 1 : 0) - } -} diff --git a/osdep/macosx_application.h b/osdep/macosx_application.h deleted file mode 100644 index 753b9f033fdab..0000000000000 --- a/osdep/macosx_application.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -#ifndef MPV_MACOSX_APPLICATION -#define MPV_MACOSX_APPLICATION - -#include "osdep/macosx_menubar.h" -#include "options/m_option.h" - -enum { - FRAME_VISIBLE = 0, - FRAME_WHOLE, -}; - -enum { - RENDER_TIMER_CALLBACK = 0, - RENDER_TIMER_PRECISE, - RENDER_TIMER_SYSTEM, -}; - -struct macos_opts { - int macos_title_bar_style; - int macos_title_bar_appearance; - int macos_title_bar_material; - struct m_color macos_title_bar_color; - int macos_fs_animation_duration; - bool macos_force_dedicated_gpu; - int macos_app_activation_policy; - int macos_geometry_calculation; - int macos_render_timer; - int cocoa_cb_sw_renderer; - bool cocoa_cb_10bit_context; -}; - -// multithreaded wrapper for mpv_main -int cocoa_main(int argc, char *argv[]); -void cocoa_register_menu_item_action(MPMenuKey key, void* action); - -extern const struct m_sub_options macos_conf; - -#endif /* MPV_MACOSX_APPLICATION */ diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m deleted file mode 100644 index bf60e05389679..0000000000000 --- a/osdep/macosx_application.m +++ /dev/null @@ -1,380 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -#include -#include -#include "config.h" -#include "mpv_talloc.h" - -#include "common/msg.h" -#include "input/input.h" -#include "player/client.h" -#include "options/m_config.h" -#include "options/options.h" - -#import "osdep/macosx_application_objc.h" -#include "osdep/macosx_compat.h" -#import "osdep/macosx_events_objc.h" -#include "osdep/threads.h" -#include "osdep/main-fn.h" - -#if HAVE_MACOS_TOUCHBAR -#import "osdep/macosx_touchbar.h" -#endif -#if HAVE_MACOS_COCOA_CB -#include "osdep/macOS_swift.h" -#endif - -#define MPV_PROTOCOL @"mpv://" - -#define OPT_BASE_STRUCT struct macos_opts -const struct m_sub_options macos_conf = { - .opts = (const struct m_option[]) { - {"macos-title-bar-appearance", OPT_CHOICE(macos_title_bar_appearance, - {"auto", 0}, {"aqua", 1}, {"darkAqua", 2}, - {"vibrantLight", 3}, {"vibrantDark", 4}, - {"aquaHighContrast", 5}, {"darkAquaHighContrast", 6}, - {"vibrantLightHighContrast", 7}, - {"vibrantDarkHighContrast", 8})}, - {"macos-title-bar-material", OPT_CHOICE(macos_title_bar_material, - {"titlebar", 0}, {"selection", 1}, {"menu", 2}, - {"popover", 3}, {"sidebar", 4}, {"headerView", 5}, - {"sheet", 6}, {"windowBackground", 7}, {"hudWindow", 8}, - {"fullScreen", 9}, {"toolTip", 10}, {"contentBackground", 11}, - {"underWindowBackground", 12}, {"underPageBackground", 13}, - {"dark", 14}, {"light", 15}, {"mediumLight", 16}, - {"ultraDark", 17})}, - {"macos-title-bar-color", OPT_COLOR(macos_title_bar_color)}, - {"macos-fs-animation-duration", - OPT_CHOICE(macos_fs_animation_duration, {"default", -1}), - M_RANGE(0, 1000)}, - {"macos-force-dedicated-gpu", OPT_BOOL(macos_force_dedicated_gpu)}, - {"macos-app-activation-policy", OPT_CHOICE(macos_app_activation_policy, - {"regular", 0}, {"accessory", 1}, {"prohibited", 2})}, - {"macos-geometry-calculation", OPT_CHOICE(macos_geometry_calculation, - {"visible", FRAME_VISIBLE}, {"whole", FRAME_WHOLE})}, - {"macos-render-timer", OPT_CHOICE(macos_render_timer, - {"callback", RENDER_TIMER_CALLBACK}, {"precise", RENDER_TIMER_PRECISE}, - {"system", RENDER_TIMER_SYSTEM})}, - {"cocoa-cb-sw-renderer", OPT_CHOICE(cocoa_cb_sw_renderer, - {"auto", -1}, {"no", 0}, {"yes", 1})}, - {"cocoa-cb-10bit-context", OPT_BOOL(cocoa_cb_10bit_context)}, - {0} - }, - .size = sizeof(struct macos_opts), - .defaults = &(const struct macos_opts){ - .macos_title_bar_color = {0, 0, 0, 0}, - .macos_fs_animation_duration = -1, - .cocoa_cb_sw_renderer = -1, - .cocoa_cb_10bit_context = true - }, -}; - -// Whether the NSApplication singleton was created. If this is false, we are -// running in libmpv mode, and cocoa_main() was never called. -static bool application_instantiated; - -static pthread_t playback_thread_id; - -@interface Application () -{ - EventsResponder *_eventsResponder; -} - -@end - -static Application *mpv_shared_app(void) -{ - return (Application *)[Application sharedApplication]; -} - -static void terminate_cocoa_application(void) -{ - dispatch_async(dispatch_get_main_queue(), ^{ - [NSApp hide:NSApp]; - [NSApp terminate:NSApp]; - }); -} - -@implementation Application -@synthesize menuBar = _menu_bar; -@synthesize openCount = _open_count; -@synthesize cocoaCB = _cocoa_cb; - -- (void)sendEvent:(NSEvent *)event -{ - if ([self modalWindow] || ![_eventsResponder processKeyEvent:event]) - [super sendEvent:event]; - [_eventsResponder wakeup]; -} - -- (id)init -{ - if (self = [super init]) { - _eventsResponder = [EventsResponder sharedInstance]; - - NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager]; - [em setEventHandler:self - andSelector:@selector(getUrl:withReplyEvent:) - forEventClass:kInternetEventClass - andEventID:kAEGetURL]; - } - - return self; -} - -- (void)dealloc -{ - NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager]; - [em removeEventHandlerForEventClass:kInternetEventClass - andEventID:kAEGetURL]; - [em removeEventHandlerForEventClass:kCoreEventClass - andEventID:kAEQuitApplication]; - [super dealloc]; -} - -static const char macosx_icon[] = -#include "TOOLS/osxbundle/icon.icns.inc" -; - -- (NSImage *)getMPVIcon -{ - // The C string contains a trailing null, so we strip it away - NSData *icon_data = [NSData dataWithBytesNoCopy:(void *)macosx_icon - length:sizeof(macosx_icon) - 1 - freeWhenDone:NO]; - return [[NSImage alloc] initWithData:icon_data]; -} - -#if HAVE_MACOS_TOUCHBAR -- (NSTouchBar *)makeTouchBar -{ - TouchBar *tBar = [[TouchBar alloc] init]; - [tBar setApp:self]; - tBar.delegate = tBar; - tBar.customizationIdentifier = customID; - tBar.defaultItemIdentifiers = @[play, previousItem, nextItem, seekBar]; - tBar.customizationAllowedItemIdentifiers = @[play, seekBar, previousItem, - nextItem, previousChapter, nextChapter, cycleAudio, cycleSubtitle, - currentPosition, timeLeft]; - return tBar; -} -#endif - -- (void)processEvent:(struct mpv_event *)event -{ -#if HAVE_MACOS_TOUCHBAR - if ([self respondsToSelector:@selector(touchBar)]) - [(TouchBar *)self.touchBar processEvent:event]; -#endif - if (_cocoa_cb) { - [_cocoa_cb processEvent:event]; - } -} - -- (void)setMpvHandle:(struct mpv_handle *)ctx -{ -#if HAVE_MACOS_COCOA_CB - [NSApp setCocoaCB:[[CocoaCB alloc] init:ctx]]; -#endif -} - -- (const struct m_sub_options *)getMacOSConf -{ - return &macos_conf; -} - -- (const struct m_sub_options *)getVoSubConf -{ - return &vo_sub_opts; -} - -- (void)queueCommand:(char *)cmd -{ - [_eventsResponder queueCommand:cmd]; -} - -- (void)stopMPV:(char *)cmd -{ - if (![_eventsResponder queueCommand:cmd]) - terminate_cocoa_application(); -} - -- (void)applicationWillFinishLaunching:(NSNotification *)notification -{ - NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager]; - [em setEventHandler:self - andSelector:@selector(handleQuitEvent:withReplyEvent:) - forEventClass:kCoreEventClass - andEventID:kAEQuitApplication]; -} - -- (void)handleQuitEvent:(NSAppleEventDescriptor *)event - withReplyEvent:(NSAppleEventDescriptor *)replyEvent -{ - [self stopMPV:"quit"]; -} - -- (void)getUrl:(NSAppleEventDescriptor *)event - withReplyEvent:(NSAppleEventDescriptor *)replyEvent -{ - NSString *url = - [[event paramDescriptorForKeyword:keyDirectObject] stringValue]; - - url = [url stringByReplacingOccurrencesOfString:MPV_PROTOCOL - withString:@"" - options:NSAnchoredSearch - range:NSMakeRange(0, [MPV_PROTOCOL length])]; - - url = [url stringByRemovingPercentEncoding]; - [_eventsResponder handleFilesArray:@[url]]; -} - -- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames -{ - if (mpv_shared_app().openCount > 0) { - mpv_shared_app().openCount--; - return; - } - [self openFiles:filenames]; -} - -- (void)openFiles:(NSArray *)filenames -{ - SEL cmpsel = @selector(localizedStandardCompare:); - NSArray *files = [filenames sortedArrayUsingSelector:cmpsel]; - [_eventsResponder handleFilesArray:files]; -} -@end - -struct playback_thread_ctx { - int *argc; - char ***argv; -}; - -static void cocoa_run_runloop(void) -{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - [NSApp run]; - [pool drain]; -} - -static void *playback_thread(void *ctx_obj) -{ - mpthread_set_name("playback core (OSX)"); - @autoreleasepool { - struct playback_thread_ctx *ctx = (struct playback_thread_ctx*) ctx_obj; - int r = mpv_main(*ctx->argc, *ctx->argv); - terminate_cocoa_application(); - // normally never reached - unless the cocoa mainloop hasn't started yet - exit(r); - } -} - -void cocoa_register_menu_item_action(MPMenuKey key, void* action) -{ - if (application_instantiated) - [[NSApp menuBar] registerSelector:(SEL)action forKey:key]; -} - -static void init_cocoa_application(bool regular) -{ - NSApp = mpv_shared_app(); - [NSApp setDelegate:NSApp]; - [NSApp setMenuBar:[[MenuBar alloc] init]]; - - // Will be set to Regular from cocoa_common during UI creation so that we - // don't create an icon when playing audio only files. - [NSApp setActivationPolicy: regular ? - NSApplicationActivationPolicyRegular : - NSApplicationActivationPolicyAccessory]; - - atexit_b(^{ - // Because activation policy has just been set to behave like a real - // application, that policy must be reset on exit to prevent, among - // other things, the menubar created here from remaining on screen. - dispatch_async(dispatch_get_main_queue(), ^{ - [NSApp setActivationPolicy:NSApplicationActivationPolicyProhibited]; - }); - }); -} - -static bool bundle_started_from_finder(char **argv) -{ - NSString *binary_path = [NSString stringWithUTF8String:argv[0]]; - return [binary_path hasSuffix:@"mpv-bundle"]; -} - -static bool is_psn_argument(char *arg_to_check) -{ - NSString *arg = [NSString stringWithUTF8String:arg_to_check]; - return [arg hasPrefix:@"-psn_"]; -} - -static void setup_bundle(int *argc, char *argv[]) -{ - if (*argc > 1 && is_psn_argument(argv[1])) { - *argc = 1; - argv[1] = NULL; - } - - NSDictionary *env = [[NSProcessInfo processInfo] environment]; - NSString *path_bundle = [env objectForKey:@"PATH"]; - NSString *path_new = [NSString stringWithFormat:@"%@:%@:%@:%@:%@", - path_bundle, - @"/usr/local/bin", - @"/usr/local/sbin", - @"/opt/local/bin", - @"/opt/local/sbin"]; - setenv("PATH", [path_new UTF8String], 1); - setenv("MPVBUNDLE", "true", 1); -} - -int cocoa_main(int argc, char *argv[]) -{ - @autoreleasepool { - application_instantiated = true; - [[EventsResponder sharedInstance] setIsApplication:YES]; - - struct playback_thread_ctx ctx = {0}; - ctx.argc = &argc; - ctx.argv = &argv; - - if (bundle_started_from_finder(argv)) { - setup_bundle(&argc, argv); - init_cocoa_application(true); - } else { - for (int i = 1; i < argc; i++) - if (argv[i][0] != '-') - mpv_shared_app().openCount++; - init_cocoa_application(false); - } - - pthread_create(&playback_thread_id, NULL, playback_thread, &ctx); - [[EventsResponder sharedInstance] waitForInputContext]; - cocoa_run_runloop(); - - // This should never be reached: cocoa_run_runloop blocks until the - // process is quit - fprintf(stderr, "There was either a problem " - "initializing Cocoa or the Runloop was stopped unexpectedly. " - "Please report this issues to a developer.\n"); - pthread_join(playback_thread_id, NULL); - return 1; - } -} - diff --git a/osdep/macosx_application_objc.h b/osdep/macosx_application_objc.h deleted file mode 100644 index 11959a83eaf12..0000000000000 --- a/osdep/macosx_application_objc.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -#import -#include "osdep/macosx_application.h" -#import "osdep/macosx_menubar_objc.h" - -@class CocoaCB; -struct mpv_event; -struct mpv_handle; - -@interface Application : NSApplication - -- (NSImage *)getMPVIcon; -- (void)processEvent:(struct mpv_event *)event; -- (void)queueCommand:(char *)cmd; -- (void)stopMPV:(char *)cmd; -- (void)openFiles:(NSArray *)filenames; -- (void)setMpvHandle:(struct mpv_handle *)ctx; -- (const struct m_sub_options *)getMacOSConf; -- (const struct m_sub_options *)getVoSubConf; - -@property(nonatomic, retain) MenuBar *menuBar; -@property(nonatomic, assign) size_t openCount; -@property(nonatomic, retain) CocoaCB *cocoaCB; -@end diff --git a/osdep/macosx_compat.h b/osdep/macosx_compat.h deleted file mode 100644 index d5f8dab571b23..0000000000000 --- a/osdep/macosx_compat.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Application Event Handling - * - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - - -#ifndef MPV_MACOSX_COMPAT -#define MPV_MACOSX_COMPAT - -#import -#include "osdep/macosx_versions.h" - -#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12) - -@interface NSWindow (macOS10_12_SDK) -+ (void)setAllowsAutomaticWindowTabbing:(BOOL)allow; -@end - -typedef NSUInteger NSWindowStyleMask; -static const NSWindowStyleMask NSWindowStyleMaskClosable = NSClosableWindowMask; -static const NSWindowStyleMask NSWindowStyleMaskTitled = NSTitledWindowMask; -static const NSWindowStyleMask NSWindowStyleMaskMiniaturizable = NSMiniaturizableWindowMask; -static const NSWindowStyleMask NSWindowStyleMaskResizable = NSResizableWindowMask; -static const NSWindowStyleMask NSWindowStyleMaskBorderless = NSBorderlessWindowMask; -static const NSWindowStyleMask NSWindowStyleMaskFullScreen = NSFullScreenWindowMask; - -static const NSEventType NSEventTypeSystemDefined = NSSystemDefined; -static const NSEventType NSEventTypeKeyDown = NSKeyDown; -static const NSEventType NSEventTypeKeyUp = NSKeyUp; - -static const NSEventMask NSEventMaskLeftMouseUp = NSLeftMouseUpMask; - -#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10) -typedef NSUInteger NSEventModifierFlags; -#endif - -static const NSEventModifierFlags NSEventModifierFlagShift = NSShiftKeyMask; -static const NSEventModifierFlags NSEventModifierFlagControl = NSControlKeyMask; -static const NSEventModifierFlags NSEventModifierFlagCommand = NSCommandKeyMask; -static const NSEventModifierFlags NSEventModifierFlagOption = NSAlternateKeyMask; - -#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_9) -typedef NSUInteger NSModalResponse; -static const NSModalResponse NSModalResponseOK = NSFileHandlingPanelOKButton; -#endif - -#endif - -#endif /* MPV_MACOSX_COMPAT */ diff --git a/osdep/macosx_events.h b/osdep/macosx_events.h deleted file mode 100644 index 9188c8bee2904..0000000000000 --- a/osdep/macosx_events.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Cocoa Application Event Handling - * - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -#ifndef MACOSX_EVENTS_H -#define MACOSX_EVENTS_H -#include "input/keycodes.h" - -struct input_ctx; -struct mpv_handle; - -void cocoa_put_key(int keycode); -void cocoa_put_key_with_modifiers(int keycode, int modifiers); - -void cocoa_init_media_keys(void); -void cocoa_uninit_media_keys(void); - -void cocoa_set_input_context(struct input_ctx *input_context); -void cocoa_set_mpv_handle(struct mpv_handle *ctx); - -#endif diff --git a/osdep/macosx_events.m b/osdep/macosx_events.m deleted file mode 100644 index 2a82b3d034f5d..0000000000000 --- a/osdep/macosx_events.m +++ /dev/null @@ -1,410 +0,0 @@ -/* - * Cocoa Application Event Handling - * - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -// Carbon header is included but Carbon is NOT linked to mpv's binary. This -// file only needs this include to use the keycode definitions in keymap. -#import - -// Media keys definitions -#import -#import - -#include "mpv_talloc.h" -#include "input/event.h" -#include "input/input.h" -#include "player/client.h" -#include "input/keycodes.h" -// doesn't make much sense, but needed to access keymap functionality -#include "video/out/vo.h" - -#include "osdep/macosx_compat.h" -#import "osdep/macosx_events_objc.h" -#import "osdep/macosx_application_objc.h" - -#include "config.h" - -#if HAVE_MACOS_COCOA_CB -#include "osdep/macOS_swift.h" -#endif - -@interface EventsResponder () -{ - struct input_ctx *_inputContext; - struct mpv_handle *_ctx; - BOOL _is_application; - NSCondition *_input_lock; -} - -- (NSEvent *)handleKey:(NSEvent *)event; -- (BOOL)setMpvHandle:(struct mpv_handle *)ctx; -- (void)readEvents; -- (void)startMediaKeys; -- (void)stopMediaKeys; -- (int)mapKeyModifiers:(int)cocoaModifiers; -- (int)keyModifierMask:(NSEvent *)event; -@end - - -#define NSLeftAlternateKeyMask (0x000020 | NSEventModifierFlagOption) -#define NSRightAlternateKeyMask (0x000040 | NSEventModifierFlagOption) - -static bool LeftAltPressed(int mask) -{ - return (mask & NSLeftAlternateKeyMask) == NSLeftAlternateKeyMask; -} - -static bool RightAltPressed(int mask) -{ - return (mask & NSRightAlternateKeyMask) == NSRightAlternateKeyMask; -} - -static const struct mp_keymap keymap[] = { - // special keys - {kVK_Return, MP_KEY_ENTER}, {kVK_Escape, MP_KEY_ESC}, - {kVK_Delete, MP_KEY_BACKSPACE}, {kVK_Option, MP_KEY_BACKSPACE}, - {kVK_Control, MP_KEY_BACKSPACE}, {kVK_Shift, MP_KEY_BACKSPACE}, - {kVK_Tab, MP_KEY_TAB}, - - // cursor keys - {kVK_UpArrow, MP_KEY_UP}, {kVK_DownArrow, MP_KEY_DOWN}, - {kVK_LeftArrow, MP_KEY_LEFT}, {kVK_RightArrow, MP_KEY_RIGHT}, - - // navigation block - {kVK_Help, MP_KEY_INSERT}, {kVK_ForwardDelete, MP_KEY_DELETE}, - {kVK_Home, MP_KEY_HOME}, {kVK_End, MP_KEY_END}, - {kVK_PageUp, MP_KEY_PAGE_UP}, {kVK_PageDown, MP_KEY_PAGE_DOWN}, - - // F-keys - {kVK_F1, MP_KEY_F + 1}, {kVK_F2, MP_KEY_F + 2}, {kVK_F3, MP_KEY_F + 3}, - {kVK_F4, MP_KEY_F + 4}, {kVK_F5, MP_KEY_F + 5}, {kVK_F6, MP_KEY_F + 6}, - {kVK_F7, MP_KEY_F + 7}, {kVK_F8, MP_KEY_F + 8}, {kVK_F9, MP_KEY_F + 9}, - {kVK_F10, MP_KEY_F + 10}, {kVK_F11, MP_KEY_F + 11}, {kVK_F12, MP_KEY_F + 12}, - {kVK_F13, MP_KEY_F + 13}, {kVK_F14, MP_KEY_F + 14}, {kVK_F15, MP_KEY_F + 15}, - {kVK_F16, MP_KEY_F + 16}, {kVK_F17, MP_KEY_F + 17}, {kVK_F18, MP_KEY_F + 18}, - {kVK_F19, MP_KEY_F + 19}, {kVK_F20, MP_KEY_F + 20}, - - // numpad - {kVK_ANSI_KeypadPlus, '+'}, {kVK_ANSI_KeypadMinus, '-'}, - {kVK_ANSI_KeypadMultiply, '*'}, {kVK_ANSI_KeypadDivide, '/'}, - {kVK_ANSI_KeypadEnter, MP_KEY_KPENTER}, - {kVK_ANSI_KeypadDecimal, MP_KEY_KPDEC}, - {kVK_ANSI_Keypad0, MP_KEY_KP0}, {kVK_ANSI_Keypad1, MP_KEY_KP1}, - {kVK_ANSI_Keypad2, MP_KEY_KP2}, {kVK_ANSI_Keypad3, MP_KEY_KP3}, - {kVK_ANSI_Keypad4, MP_KEY_KP4}, {kVK_ANSI_Keypad5, MP_KEY_KP5}, - {kVK_ANSI_Keypad6, MP_KEY_KP6}, {kVK_ANSI_Keypad7, MP_KEY_KP7}, - {kVK_ANSI_Keypad8, MP_KEY_KP8}, {kVK_ANSI_Keypad9, MP_KEY_KP9}, - - {0, 0} -}; - -static int convert_key(unsigned key, unsigned charcode) -{ - int mpkey = lookup_keymap_table(keymap, key); - if (mpkey) - return mpkey; - return charcode; -} - -void cocoa_init_media_keys(void) -{ - [[EventsResponder sharedInstance] startMediaKeys]; -} - -void cocoa_uninit_media_keys(void) -{ - [[EventsResponder sharedInstance] stopMediaKeys]; -} - -void cocoa_put_key(int keycode) -{ - [[EventsResponder sharedInstance] putKey:keycode]; -} - -void cocoa_put_key_with_modifiers(int keycode, int modifiers) -{ - keycode |= [[EventsResponder sharedInstance] mapKeyModifiers:modifiers]; - cocoa_put_key(keycode); -} - -void cocoa_set_input_context(struct input_ctx *input_context) -{ - [[EventsResponder sharedInstance] setInputContext:input_context]; -} - -static void wakeup(void *context) -{ - [[EventsResponder sharedInstance] readEvents]; -} - -void cocoa_set_mpv_handle(struct mpv_handle *ctx) -{ - if ([[EventsResponder sharedInstance] setMpvHandle:ctx]) { - mpv_observe_property(ctx, 0, "duration", MPV_FORMAT_DOUBLE); - mpv_observe_property(ctx, 0, "time-pos", MPV_FORMAT_DOUBLE); - mpv_observe_property(ctx, 0, "pause", MPV_FORMAT_FLAG); - mpv_set_wakeup_callback(ctx, wakeup, NULL); - } -} - -@implementation EventsResponder - -@synthesize remoteCommandCenter = _remoteCommandCenter; - -+ (EventsResponder *)sharedInstance -{ - static EventsResponder *responder = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - responder = [EventsResponder new]; - }); - return responder; -} - -- (id)init -{ - self = [super init]; - if (self) { - _input_lock = [NSCondition new]; - } - return self; -} - -- (void)waitForInputContext -{ - [_input_lock lock]; - while (!_inputContext) - [_input_lock wait]; - [_input_lock unlock]; -} - -- (void)setInputContext:(struct input_ctx *)ctx -{ - [_input_lock lock]; - _inputContext = ctx; - [_input_lock signal]; - [_input_lock unlock]; -} - -- (void)wakeup -{ - [_input_lock lock]; - if (_inputContext) - mp_input_wakeup(_inputContext); - [_input_lock unlock]; -} - -- (bool)queueCommand:(char *)cmd -{ - bool r = false; - [_input_lock lock]; - if (_inputContext) { - mp_cmd_t *cmdt = mp_input_parse_cmd(_inputContext, bstr0(cmd), ""); - mp_input_queue_cmd(_inputContext, cmdt); - r = true; - } - [_input_lock unlock]; - return r; -} - -- (void)putKey:(int)keycode -{ - [_input_lock lock]; - if (_inputContext) - mp_input_put_key(_inputContext, keycode); - [_input_lock unlock]; -} - -- (BOOL)useAltGr -{ - BOOL r = YES; - [_input_lock lock]; - if (_inputContext) - r = mp_input_use_alt_gr(_inputContext); - [_input_lock unlock]; - return r; -} - -- (void)setIsApplication:(BOOL)isApplication -{ - _is_application = isApplication; -} - -- (BOOL)setMpvHandle:(struct mpv_handle *)ctx -{ - if (_is_application) { - dispatch_sync(dispatch_get_main_queue(), ^{ - _ctx = ctx; - [NSApp setMpvHandle:ctx]; - }); - return YES; - } else { - mpv_destroy(ctx); - return NO; - } -} - -- (void)readEvents -{ - dispatch_async(dispatch_get_main_queue(), ^{ - while (_ctx) { - mpv_event *event = mpv_wait_event(_ctx, 0); - if (event->event_id == MPV_EVENT_NONE) - break; - [self processEvent:event]; - } - }); -} - --(void)processEvent:(struct mpv_event *)event -{ - if(_is_application) { - [NSApp processEvent:event]; - } - - if (_remoteCommandCenter) { - [_remoteCommandCenter processEvent:event]; - } - - switch (event->event_id) { - case MPV_EVENT_SHUTDOWN: { -#if HAVE_MACOS_COCOA_CB - if ([(Application *)NSApp cocoaCB].isShuttingDown) { - _ctx = nil; - return; - } -#endif - mpv_destroy(_ctx); - _ctx = nil; - break; - } - } -} - -- (void)startMediaKeys -{ -#if HAVE_MACOS_MEDIA_PLAYER - // 10.12.2 runtime availability check - if (_remoteCommandCenter == nil && [NSApp respondsToSelector:@selector(touchBar)]) { - _remoteCommandCenter = [[RemoteCommandCenter alloc] init]; - } -#endif - - [_remoteCommandCenter start]; -} - -- (void)stopMediaKeys -{ - [_remoteCommandCenter stop]; -} - -- (int)mapKeyModifiers:(int)cocoaModifiers -{ - int mask = 0; - if (cocoaModifiers & NSEventModifierFlagShift) - mask |= MP_KEY_MODIFIER_SHIFT; - if (cocoaModifiers & NSEventModifierFlagControl) - mask |= MP_KEY_MODIFIER_CTRL; - if (LeftAltPressed(cocoaModifiers) || - (RightAltPressed(cocoaModifiers) && ![self useAltGr])) - mask |= MP_KEY_MODIFIER_ALT; - if (cocoaModifiers & NSEventModifierFlagCommand) - mask |= MP_KEY_MODIFIER_META; - return mask; -} - -- (int)mapTypeModifiers:(NSEventType)type -{ - NSDictionary *map = @{ - @(NSEventTypeKeyDown) : @(MP_KEY_STATE_DOWN), - @(NSEventTypeKeyUp) : @(MP_KEY_STATE_UP), - }; - return [map[@(type)] intValue]; -} - -- (int)keyModifierMask:(NSEvent *)event -{ - return [self mapKeyModifiers:[event modifierFlags]] | - [self mapTypeModifiers:[event type]]; -} - --(BOOL)handleMPKey:(int)key withMask:(int)mask -{ - if (key > 0) { - cocoa_put_key(key | mask); - if (mask & MP_KEY_STATE_UP) - cocoa_put_key(MP_INPUT_RELEASE_ALL); - return YES; - } else { - return NO; - } -} - -- (NSEvent*)handleKey:(NSEvent *)event -{ - if ([event isARepeat]) return nil; - - NSString *chars; - - if ([self useAltGr] && RightAltPressed([event modifierFlags])) { - chars = [event characters]; - } else { - chars = [event charactersIgnoringModifiers]; - } - - struct bstr t = bstr0([chars UTF8String]); - int key = convert_key([event keyCode], bstr_decode_utf8(t, &t)); - - if (key > -1) - [self handleMPKey:key withMask:[self keyModifierMask:event]]; - - return nil; -} - -- (bool)processKeyEvent:(NSEvent *)event -{ - if (event.type == NSEventTypeKeyDown || event.type == NSEventTypeKeyUp){ - if (![[NSApp mainMenu] performKeyEquivalent:event]) - [self handleKey:event]; - return true; - } - return false; -} - -- (void)handleFilesArray:(NSArray *)files -{ - enum mp_dnd_action action = [NSEvent modifierFlags] & - NSEventModifierFlagShift ? DND_APPEND : DND_REPLACE; - - size_t num_files = [files count]; - char **files_utf8 = talloc_array(NULL, char*, num_files); - [files enumerateObjectsUsingBlock:^(NSString *p, NSUInteger i, BOOL *_){ - if ([p hasPrefix:@"file:///.file/id="]) - p = [[NSURL URLWithString:p] path]; - char *filename = (char *)[p UTF8String]; - size_t bytes = [p lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; - files_utf8[i] = talloc_memdup(files_utf8, filename, bytes + 1); - }]; - [_input_lock lock]; - if (_inputContext) - mp_event_drop_files(_inputContext, num_files, files_utf8, action); - [_input_lock unlock]; - talloc_free(files_utf8); -} - -@end diff --git a/osdep/macosx_events_objc.h b/osdep/macosx_events_objc.h deleted file mode 100644 index 9394fe7160b5e..0000000000000 --- a/osdep/macosx_events_objc.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Cocoa Application Event Handling - * - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -#import -#include "osdep/macosx_events.h" - -@class RemoteCommandCenter; -struct input_ctx; - -@interface EventsResponder : NSObject - -+ (EventsResponder *)sharedInstance; -- (void)setInputContext:(struct input_ctx *)ctx; -- (void)setIsApplication:(BOOL)isApplication; - -/// Blocks until inputContext is present. -- (void)waitForInputContext; -- (void)wakeup; -- (void)putKey:(int)keycode; -- (void)handleFilesArray:(NSArray *)files; - -- (bool)queueCommand:(char *)cmd; -- (bool)processKeyEvent:(NSEvent *)event; - -- (BOOL)handleMPKey:(int)key withMask:(int)mask; - -@property(nonatomic, retain) RemoteCommandCenter *remoteCommandCenter; - -@end diff --git a/osdep/macosx_menubar.h b/osdep/macosx_menubar.h deleted file mode 100644 index 509083dd2099d..0000000000000 --- a/osdep/macosx_menubar.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -#ifndef MPV_MACOSX_MENU -#define MPV_MACOSX_MENU - -// Menu Keys identifying menu items -typedef enum { - MPM_H_SIZE, - MPM_N_SIZE, - MPM_D_SIZE, - MPM_MINIMIZE, - MPM_ZOOM, -} MPMenuKey; - -#endif /* MPV_MACOSX_MENU */ diff --git a/osdep/macosx_menubar.m b/osdep/macosx_menubar.m deleted file mode 100644 index c8255dd037e25..0000000000000 --- a/osdep/macosx_menubar.m +++ /dev/null @@ -1,835 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -#include "config.h" -#include "common/common.h" - -#import "macosx_menubar_objc.h" -#import "osdep/macosx_application_objc.h" -#include "osdep/macosx_compat.h" - -@implementation MenuBar -{ - NSArray *menuTree; -} - -- (id)init -{ - if (self = [super init]) { - NSUserDefaults *userDefaults =[NSUserDefaults standardUserDefaults]; - [userDefaults setBool:NO forKey:@"NSFullScreenMenuItemEverywhere"]; - [userDefaults setBool:YES forKey:@"NSDisabledDictationMenuItem"]; - [userDefaults setBool:YES forKey:@"NSDisabledCharacterPaletteMenuItem"]; - - if ([NSWindow respondsToSelector:@selector(setAllowsAutomaticWindowTabbing:)]) - [NSWindow setAllowsAutomaticWindowTabbing: NO]; - - menuTree = @[ - @{ - @"name": @"Apple", - @"menu": @[ - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"About mpv", - @"action" : @"about", - @"key" : @"", - @"target" : self - }], - @{ @"name": @"separator" }, - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Preferences…", - @"action" : @"preferences:", - @"key" : @",", - @"target" : self, - @"file" : @"mpv.conf", - @"alertTitle1": @"No Application found to open your config file.", - @"alertText1" : @"Please open the mpv.conf file with " - "your preferred text editor in the now " - "open folder to edit your config.", - @"alertTitle2": @"No config file found.", - @"alertText2" : @"Please create a mpv.conf file with your " - "preferred text editor in the now open folder.", - @"alertTitle3": @"No config path or file found.", - @"alertText3" : @"Please create the following path ~/.config/mpv/ " - "and a mpv.conf file within with your preferred " - "text editor." - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Keyboard Shortcuts Config…", - @"action" : @"preferences:", - @"key" : @"", - @"target" : self, - @"file" : @"input.conf", - @"alertTitle1": @"No Application found to open your config file.", - @"alertText1" : @"Please open the input.conf file with " - "your preferred text editor in the now " - "open folder to edit your config.", - @"alertTitle2": @"No config file found.", - @"alertText2" : @"Please create a input.conf file with your " - "preferred text editor in the now open folder.", - @"alertTitle3": @"No config path or file found.", - @"alertText3" : @"Please create the following path ~/.config/mpv/ " - "and a input.conf file within with your preferred " - "text editor." - }], - @{ @"name": @"separator" }, - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Services", - @"key" : @"", - }], - @{ @"name": @"separator" }, - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Hide mpv", - @"action" : @"hide:", - @"key" : @"h", - @"target" : NSApp - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Hide Others", - @"action" : @"hideOtherApplications:", - @"key" : @"h", - @"modifiers" : [NSNumber numberWithUnsignedInteger: - NSEventModifierFlagCommand | - NSEventModifierFlagOption], - @"target" : NSApp - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Show All", - @"action" : @"unhideAllApplications:", - @"key" : @"", - @"target" : NSApp - }], - @{ @"name": @"separator" }, - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Quit and Remember Position", - @"action" : @"quit:", - @"key" : @"", - @"target" : self, - @"cmd" : @"quit-watch-later" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Quit mpv", - @"action" : @"quit:", - @"key" : @"q", - @"target" : self, - @"cmd" : @"quit" - }] - ] - }, - @{ - @"name": @"File", - @"menu": @[ - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Open File…", - @"action" : @"openFile", - @"key" : @"o", - @"target" : self - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Open URL…", - @"action" : @"openURL", - @"key" : @"O", - @"target" : self - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Open Playlist…", - @"action" : @"openPlaylist", - @"key" : @"", - @"target" : self - }], - @{ @"name": @"separator" }, - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Close", - @"action" : @"performClose:", - @"key" : @"w" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Save Screenshot", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"async screenshot" - }] - ] - }, - @{ - @"name": @"Edit", - @"menu": @[ - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Undo", - @"action" : @"undo:", - @"key" : @"z" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Redo", - @"action" : @"redo:", - @"key" : @"Z" - }], - @{ @"name": @"separator" }, - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Cut", - @"action" : @"cut:", - @"key" : @"x" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Copy", - @"action" : @"copy:", - @"key" : @"c" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Paste", - @"action" : @"paste:", - @"key" : @"v" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Select All", - @"action" : @"selectAll:", - @"key" : @"a" - }] - ] - }, - @{ - @"name": @"View", - @"menu": @[ - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Toggle Fullscreen", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"cycle fullscreen" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Toggle Float on Top", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"cycle ontop" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Toggle Visibility on All Workspaces", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"cycle on-all-workspaces" - }], -#if HAVE_MACOS_TOUCHBAR - @{ @"name": @"separator" }, - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Customize Touch Bar…", - @"action" : @"toggleTouchBarCustomizationPalette:", - @"key" : @"", - @"target" : NSApp - }] -#endif - ] - }, - @{ - @"name": @"Video", - @"menu": @[ - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Zoom Out", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"add panscan -0.1" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Zoom In", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"add panscan 0.1" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Reset Zoom", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"set panscan 0" - }], - @{ @"name": @"separator" }, - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Aspect Ratio 4:3", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"set video-aspect-override \"4:3\"" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Aspect Ratio 16:9", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"set video-aspect-override \"16:9\"" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Aspect Ratio 1.85:1", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"set video-aspect-override \"1.85:1\"" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Aspect Ratio 2.35:1", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"set video-aspect-override \"2.35:1\"" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Reset Aspect Ratio", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"set video-aspect-override \"-1\"" - }], - @{ @"name": @"separator" }, - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Half Size", - @"key" : @"0", - @"cmdSpecial" : [NSNumber numberWithInt:MPM_H_SIZE] - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Normal Size", - @"key" : @"1", - @"cmdSpecial" : [NSNumber numberWithInt:MPM_N_SIZE] - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Double Size", - @"key" : @"2", - @"cmdSpecial" : [NSNumber numberWithInt:MPM_D_SIZE] - }] - ] - }, - @{ - @"name": @"Audio", - @"menu": @[ - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Next Audio Track", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"cycle audio" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Previous Audio Track", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"cycle audio down" - }], - @{ @"name": @"separator" }, - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Toggle Mute", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"cycle mute" - }], - @{ @"name": @"separator" }, - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Play Audio Later", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"add audio-delay 0.1" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Play Audio Earlier", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"add audio-delay -0.1" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Reset Audio Delay", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"set audio-delay 0.0 " - }] - ] - }, - @{ - @"name": @"Subtitle", - @"menu": @[ - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Next Subtitle Track", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"cycle sub" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Previous Subtitle Track", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"cycle sub down" - }], - @{ @"name": @"separator" }, - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Toggle Force Style", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"cycle-values sub-ass-override \"force\" \"no\"" - }], - @{ @"name": @"separator" }, - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Display Subtitles Later", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"add sub-delay 0.1" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Display Subtitles Earlier", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"add sub-delay -0.1" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Reset Subtitle Delay", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"set sub-delay 0.0" - }] - ] - }, - @{ - @"name": @"Playback", - @"menu": @[ - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Toggle Pause", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"cycle pause" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Increase Speed", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"add speed 0.1" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Decrease Speed", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"add speed -0.1" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Reset Speed", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"set speed 1.0" - }], - @{ @"name": @"separator" }, - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Show Playlist", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"script-message osc-playlist" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Show Chapters", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"script-message osc-chapterlist" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Show Tracks", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"script-message osc-tracklist" - }], - @{ @"name": @"separator" }, - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Next File", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"playlist-next" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Previous File", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"playlist-prev" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Toggle Loop File", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"cycle-values loop-file \"inf\" \"no\"" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Toggle Loop Playlist", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"cycle-values loop-playlist \"inf\" \"no\"" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Shuffle", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"playlist-shuffle" - }], - @{ @"name": @"separator" }, - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Next Chapter", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"add chapter 1" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Previous Chapter", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"add chapter -1" - }], - @{ @"name": @"separator" }, - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Step Forward", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"frame-step" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Step Backward", - @"action" : @"cmd:", - @"key" : @"", - @"target" : self, - @"cmd" : @"frame-back-step" - }] - ] - }, - @{ - @"name": @"Window", - @"menu": @[ - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Minimize", - @"key" : @"m", - @"cmdSpecial" : [NSNumber numberWithInt:MPM_MINIMIZE] - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Zoom", - @"key" : @"z", - @"cmdSpecial" : [NSNumber numberWithInt:MPM_ZOOM] - }] - ] - }, - @{ - @"name": @"Help", - @"menu": @[ - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"mpv Website…", - @"action" : @"url:", - @"key" : @"", - @"target" : self, - @"url" : @"https://mpv.io" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"mpv on github…", - @"action" : @"url:", - @"key" : @"", - @"target" : self, - @"url" : @"https://github.com/mpv-player/mpv" - }], - @{ @"name": @"separator" }, - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Online Manual…", - @"action" : @"url:", - @"key" : @"", - @"target" : self, - @"url" : @"https://mpv.io/manual/master/" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Online Wiki…", - @"action" : @"url:", - @"key" : @"", - @"target" : self, - @"url" : @"https://github.com/mpv-player/mpv/wiki" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Release Notes…", - @"action" : @"url:", - @"key" : @"", - @"target" : self, - @"url" : @"https://github.com/mpv-player/mpv/blob/master/RELEASE_NOTES" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Keyboard Shortcuts…", - @"action" : @"url:", - @"key" : @"", - @"target" : self, - @"url" : @"https://github.com/mpv-player/mpv/blob/master/etc/input.conf" - }], - @{ @"name": @"separator" }, - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Report Issue…", - @"action" : @"url:", - @"key" : @"", - @"target" : self, - @"url" : @"https://github.com/mpv-player/mpv/issues/new/choose" - }], - [NSMutableDictionary dictionaryWithDictionary:@{ - @"name" : @"Show log File…", - @"action" : @"showFile:", - @"key" : @"", - @"target" : self, - @"file" : @"~/Library/Logs/mpv.log", - @"alertTitle" : @"No log File found.", - @"alertText" : @"You deactivated logging for the Bundle." - }] - ] - } - ]; - - [NSApp setMainMenu:[self mainMenu]]; - } - - return self; -} - -- (NSMenu *)mainMenu -{ - NSMenu *mainMenu = [[NSMenu alloc] initWithTitle:@"MainMenu"]; - [NSApp setServicesMenu:[[NSMenu alloc] init]]; - NSString* bundle = [[[NSProcessInfo processInfo] environment] objectForKey:@"MPVBUNDLE"]; - - for(id mMenu in menuTree) { - NSMenu *menu = [[NSMenu alloc] initWithTitle:mMenu[@"name"]]; - NSMenuItem *mItem = [mainMenu addItemWithTitle:mMenu[@"name"] - action:nil - keyEquivalent:@""]; - [mainMenu setSubmenu:menu forItem:mItem]; - - for(id subMenu in mMenu[@"menu"]) { - NSString *name = subMenu[@"name"]; - NSString *action = subMenu[@"action"]; - -#if HAVE_MACOS_TOUCHBAR - if ([action isEqual:@"toggleTouchBarCustomizationPalette:"]) { - if (![NSApp respondsToSelector:@selector(touchBar)]) - continue; - } -#endif - - if ([name isEqual:@"Show log File…"] && ![bundle isEqual:@"true"]) { - continue; - } - - if ([name isEqual:@"separator"]) { - [menu addItem:[NSMenuItem separatorItem]]; - } else { - NSMenuItem *iItem = [menu addItemWithTitle:name - action:NSSelectorFromString(action) - keyEquivalent:subMenu[@"key"]]; - [iItem setTarget:subMenu[@"target"]]; - [subMenu setObject:iItem forKey:@"menuItem"]; - - NSNumber *m = subMenu[@"modifiers"]; - if (m) { - [iItem setKeyEquivalentModifierMask:m.unsignedIntegerValue]; - } - - if ([subMenu[@"name"] isEqual:@"Services"]) { - iItem.submenu = [NSApp servicesMenu]; - } - } - } - } - - return mainMenu; -} - -- (void)about -{ - NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: - @"mpv", @"ApplicationName", - [(Application *)NSApp getMPVIcon], @"ApplicationIcon", - [NSString stringWithUTF8String:mpv_copyright], @"Copyright", - [NSString stringWithUTF8String:mpv_version], @"ApplicationVersion", - nil]; - [NSApp orderFrontStandardAboutPanelWithOptions:options]; -} - -- (void)preferences:(NSMenuItem *)menuItem -{ - NSWorkspace *workspace = [NSWorkspace sharedWorkspace]; - NSFileManager *fileManager = [NSFileManager defaultManager]; - NSMutableDictionary *mItemDict = [self getDictFromMenuItem:menuItem]; - NSArray *configPaths = @[ - [NSString stringWithFormat:@"%@/.mpv/", NSHomeDirectory()], - [NSString stringWithFormat:@"%@/.config/mpv/", NSHomeDirectory()]]; - - for (id path in configPaths) { - NSString *fileP = [path stringByAppendingString:mItemDict[@"file"]]; - if ([fileManager fileExistsAtPath:fileP]){ - if ([workspace openFile:fileP]) - return; - [workspace openFile:path]; - [self alertWithTitle:mItemDict[@"alertTitle1"] - andText:mItemDict[@"alertText1"]]; - return; - } - if ([workspace openFile:path]) { - [self alertWithTitle:mItemDict[@"alertTitle2"] - andText:mItemDict[@"alertText2"]]; - return; - } - } - - [self alertWithTitle:mItemDict[@"alertTitle3"] - andText:mItemDict[@"alertText3"]]; -} - -- (void)quit:(NSMenuItem *)menuItem -{ - NSString *cmd = [self getDictFromMenuItem:menuItem][@"cmd"]; - [(Application *)NSApp stopMPV:(char *)[cmd UTF8String]]; -} - -- (void)openFile -{ - NSOpenPanel *panel = [[NSOpenPanel alloc] init]; - [panel setCanChooseDirectories:YES]; - [panel setAllowsMultipleSelection:YES]; - - if ([panel runModal] == NSModalResponseOK){ - NSMutableArray *fileArray = [[NSMutableArray alloc] init]; - for (id url in [panel URLs]) - [fileArray addObject:[url path]]; - [(Application *)NSApp openFiles:fileArray]; - } -} - -- (void)openPlaylist -{ - NSOpenPanel *panel = [[NSOpenPanel alloc] init]; - - if ([panel runModal] == NSModalResponseOK){ - NSString *pl = [NSString stringWithFormat:@"loadlist \"%@\"", - [panel URLs][0].path]; - [(Application *)NSApp queueCommand:(char *)[pl UTF8String]]; - } -} - -- (void)openURL -{ - NSAlert *alert = [[NSAlert alloc] init]; - [alert setMessageText:@"Open URL"]; - [alert addButtonWithTitle:@"Ok"]; - [alert addButtonWithTitle:@"Cancel"]; - [alert setIcon:[(Application *)NSApp getMPVIcon]]; - - NSTextField *input = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 300, 24)]; - [input setPlaceholderString:@"URL"]; - [alert setAccessoryView:input]; - - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ - [input becomeFirstResponder]; - }); - - if ([alert runModal] == NSAlertFirstButtonReturn && [input stringValue].length > 0) { - NSArray *url = [NSArray arrayWithObjects:[input stringValue], nil]; - [(Application *)NSApp openFiles:url]; - } -} - -- (void)cmd:(NSMenuItem *)menuItem -{ - NSString *cmd = [self getDictFromMenuItem:menuItem][@"cmd"]; - [(Application *)NSApp queueCommand:(char *)[cmd UTF8String]]; -} - -- (void)url:(NSMenuItem *)menuItem -{ - NSString *url = [self getDictFromMenuItem:menuItem][@"url"]; - [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]]; -} - -- (void)showFile:(NSMenuItem *)menuItem -{ - NSWorkspace *workspace = [NSWorkspace sharedWorkspace]; - NSFileManager *fileManager = [NSFileManager defaultManager]; - NSMutableDictionary *mItemDict = [self getDictFromMenuItem:menuItem]; - NSString *file = [mItemDict[@"file"] stringByExpandingTildeInPath]; - - if ([fileManager fileExistsAtPath:file]){ - NSURL *url = [NSURL fileURLWithPath:file]; - NSArray *urlArray = [NSArray arrayWithObjects:url, nil]; - - [workspace activateFileViewerSelectingURLs:urlArray]; - return; - } - - [self alertWithTitle:mItemDict[@"alertTitle"] - andText:mItemDict[@"alertText"]]; -} - -- (void)alertWithTitle:(NSString *)title andText:(NSString *)text -{ - NSAlert *alert = [[NSAlert alloc] init]; - [alert setMessageText:title]; - [alert setInformativeText:text]; - [alert addButtonWithTitle:@"Ok"]; - [alert setIcon:[(Application *)NSApp getMPVIcon]]; - [alert runModal]; -} - -- (NSMutableDictionary *)getDictFromMenuItem:(NSMenuItem *)menuItem -{ - for(id mMenu in menuTree) { - for(id subMenu in mMenu[@"menu"]) { - if([subMenu[@"menuItem"] isEqual:menuItem]) - return subMenu; - } - } - - return nil; -} - -- (void)registerSelector:(SEL)action forKey:(MPMenuKey)key -{ - for(id mMenu in menuTree) { - for(id subMenu in mMenu[@"menu"]) { - if([subMenu[@"cmdSpecial"] isEqual:[NSNumber numberWithInt:key]]) { - [subMenu[@"menuItem"] setAction:action]; - return; - } - } - } -} - -@end diff --git a/osdep/macosx_menubar_objc.h b/osdep/macosx_menubar_objc.h deleted file mode 100644 index 072fef85c7a8e..0000000000000 --- a/osdep/macosx_menubar_objc.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -#import -#include "osdep/macosx_menubar.h" - -@interface MenuBar : NSObject - -- (void)registerSelector:(SEL)action forKey:(MPMenuKey)key; - -@end diff --git a/osdep/macosx_touchbar.h b/osdep/macosx_touchbar.h deleted file mode 100644 index a03b68c0e6570..0000000000000 --- a/osdep/macosx_touchbar.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -#import -#import "osdep/macosx_application_objc.h" - -#define BASE_ID @"io.mpv.touchbar" -static NSTouchBarCustomizationIdentifier customID = BASE_ID; -static NSTouchBarItemIdentifier seekBar = BASE_ID ".seekbar"; -static NSTouchBarItemIdentifier play = BASE_ID ".play"; -static NSTouchBarItemIdentifier nextItem = BASE_ID ".nextItem"; -static NSTouchBarItemIdentifier previousItem = BASE_ID ".previousItem"; -static NSTouchBarItemIdentifier nextChapter = BASE_ID ".nextChapter"; -static NSTouchBarItemIdentifier previousChapter = BASE_ID ".previousChapter"; -static NSTouchBarItemIdentifier cycleAudio = BASE_ID ".cycleAudio"; -static NSTouchBarItemIdentifier cycleSubtitle = BASE_ID ".cycleSubtitle"; -static NSTouchBarItemIdentifier currentPosition = BASE_ID ".currentPosition"; -static NSTouchBarItemIdentifier timeLeft = BASE_ID ".timeLeft"; - -struct mpv_event; - -@interface TouchBar : NSTouchBar - --(void)processEvent:(struct mpv_event *)event; - -@property(nonatomic, retain) Application *app; -@property(nonatomic, retain) NSDictionary *touchbarItems; -@property(nonatomic, assign) double duration; -@property(nonatomic, assign) double position; -@property(nonatomic, assign) int pause; - -@end diff --git a/osdep/macosx_touchbar.m b/osdep/macosx_touchbar.m deleted file mode 100644 index ccce8f773df54..0000000000000 --- a/osdep/macosx_touchbar.m +++ /dev/null @@ -1,334 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -#include "player/client.h" -#import "macosx_touchbar.h" - -@implementation TouchBar - -@synthesize app = _app; -@synthesize touchbarItems = _touchbar_items; -@synthesize duration = _duration; -@synthesize position = _position; -@synthesize pause = _pause; - -- (id)init -{ - if (self = [super init]) { - self.touchbarItems = @{ - seekBar: [NSMutableDictionary dictionaryWithDictionary:@{ - @"type": @"slider", - @"name": @"Seek Bar", - @"cmd": @"seek %f absolute-percent" - }], - play: [NSMutableDictionary dictionaryWithDictionary:@{ - @"type": @"button", - @"name": @"Play Button", - @"cmd": @"cycle pause", - @"image": [NSImage imageNamed:NSImageNameTouchBarPauseTemplate], - @"imageAlt": [NSImage imageNamed:NSImageNameTouchBarPlayTemplate] - }], - previousItem: [NSMutableDictionary dictionaryWithDictionary:@{ - @"type": @"button", - @"name": @"Previous Playlist Item", - @"cmd": @"playlist-prev", - @"image": [NSImage imageNamed:NSImageNameTouchBarGoBackTemplate] - }], - nextItem: [NSMutableDictionary dictionaryWithDictionary:@{ - @"type": @"button", - @"name": @"Next Playlist Item", - @"cmd": @"playlist-next", - @"image": [NSImage imageNamed:NSImageNameTouchBarGoForwardTemplate] - }], - previousChapter: [NSMutableDictionary dictionaryWithDictionary:@{ - @"type": @"button", - @"name": @"Previous Chapter", - @"cmd": @"add chapter -1", - @"image": [NSImage imageNamed:NSImageNameTouchBarSkipBackTemplate] - }], - nextChapter: [NSMutableDictionary dictionaryWithDictionary:@{ - @"type": @"button", - @"name": @"Next Chapter", - @"cmd": @"add chapter 1", - @"image": [NSImage imageNamed:NSImageNameTouchBarSkipAheadTemplate] - }], - cycleAudio: [NSMutableDictionary dictionaryWithDictionary:@{ - @"type": @"button", - @"name": @"Cycle Audio", - @"cmd": @"cycle audio", - @"image": [NSImage imageNamed:NSImageNameTouchBarAudioInputTemplate] - }], - cycleSubtitle: [NSMutableDictionary dictionaryWithDictionary:@{ - @"type": @"button", - @"name": @"Cycle Subtitle", - @"cmd": @"cycle sub", - @"image": [NSImage imageNamed:NSImageNameTouchBarComposeTemplate] - }], - currentPosition: [NSMutableDictionary dictionaryWithDictionary:@{ - @"type": @"text", - @"name": @"Current Position" - }], - timeLeft: [NSMutableDictionary dictionaryWithDictionary:@{ - @"type": @"text", - @"name": @"Time Left" - }] - }; - - [self addObserver:self forKeyPath:@"visible" options:0 context:nil]; - } - return self; -} - -- (nullable NSTouchBarItem *)touchBar:(NSTouchBar *)touchBar - makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier -{ - if ([self.touchbarItems[identifier][@"type"] isEqualToString:@"slider"]) { - NSCustomTouchBarItem *tbItem = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]; - NSSlider *slider = [NSSlider sliderWithTarget:self action:@selector(seekbarChanged:)]; - slider.minValue = 0.0f; - slider.maxValue = 100.0f; - tbItem.view = slider; - tbItem.customizationLabel = self.touchbarItems[identifier][@"name"]; - [self.touchbarItems[identifier] setObject:slider forKey:@"view"]; - [self.touchbarItems[identifier] setObject:tbItem forKey:@"tbItem"]; - [tbItem addObserver:self forKeyPath:@"visible" options:0 context:nil]; - return tbItem; - } else if ([self.touchbarItems[identifier][@"type"] isEqualToString:@"button"]) { - NSCustomTouchBarItem *tbItem = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]; - NSImage *tbImage = self.touchbarItems[identifier][@"image"]; - NSButton *tbButton = [NSButton buttonWithImage:tbImage target:self action:@selector(buttonAction:)]; - tbItem.view = tbButton; - tbItem.customizationLabel = self.touchbarItems[identifier][@"name"]; - [self.touchbarItems[identifier] setObject:tbButton forKey:@"view"]; - [self.touchbarItems[identifier] setObject:tbItem forKey:@"tbItem"]; - [tbItem addObserver:self forKeyPath:@"visible" options:0 context:nil]; - return tbItem; - } else if ([self.touchbarItems[identifier][@"type"] isEqualToString:@"text"]) { - NSCustomTouchBarItem *tbItem = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]; - NSTextField *tbText = [NSTextField labelWithString:@"0:00"]; - tbText.alignment = NSTextAlignmentCenter; - tbItem.view = tbText; - tbItem.customizationLabel = self.touchbarItems[identifier][@"name"]; - [self.touchbarItems[identifier] setObject:tbText forKey:@"view"]; - [self.touchbarItems[identifier] setObject:tbItem forKey:@"tbItem"]; - [tbItem addObserver:self forKeyPath:@"visible" options:0 context:nil]; - return tbItem; - } - - return nil; -} - -- (void)observeValueForKeyPath:(NSString *)keyPath - ofObject:(id)object - change:(NSDictionary *)change - context:(void *)context { - if ([keyPath isEqualToString:@"visible"]) { - NSNumber *visible = [object valueForKey:@"visible"]; - if (visible.boolValue) { - [self updateTouchBarTimeItems]; - [self updatePlayButton]; - } - } -} - -- (void)updateTouchBarTimeItems -{ - if (!self.isVisible) - return; - - [self updateSlider]; - [self updateTimeLeft]; - [self updateCurrentPosition]; -} - -- (void)updateSlider -{ - NSCustomTouchBarItem *tbItem = self.touchbarItems[seekBar][@"tbItem"]; - if (!tbItem.visible) - return; - - NSSlider *seekSlider = self.touchbarItems[seekBar][@"view"]; - - if (self.duration <= 0) { - seekSlider.enabled = NO; - seekSlider.doubleValue = 0; - } else { - seekSlider.enabled = YES; - if (!seekSlider.highlighted) - seekSlider.doubleValue = (self.position/self.duration)*100; - } -} - -- (void)updateTimeLeft -{ - NSCustomTouchBarItem *tbItem = self.touchbarItems[timeLeft][@"tbItem"]; - if (!tbItem.visible) - return; - - NSTextField *timeLeftItem = self.touchbarItems[timeLeft][@"view"]; - - [self removeConstraintForIdentifier:timeLeft]; - if (self.duration <= 0) { - timeLeftItem.stringValue = @""; - } else { - int left = (int)(floor(self.duration)-floor(self.position)); - NSString *leftFormat = [self formatTime:left]; - NSString *durFormat = [self formatTime:self.duration]; - timeLeftItem.stringValue = [NSString stringWithFormat:@"-%@", leftFormat]; - [self applyConstraintFromString:[NSString stringWithFormat:@"-%@", durFormat] - forIdentifier:timeLeft]; - } -} - -- (void)updateCurrentPosition -{ - NSCustomTouchBarItem *tbItem = self.touchbarItems[currentPosition][@"tbItem"]; - if (!tbItem.visible) - return; - - NSTextField *curPosItem = self.touchbarItems[currentPosition][@"view"]; - NSString *posFormat = [self formatTime:(int)floor(self.position)]; - curPosItem.stringValue = posFormat; - - [self removeConstraintForIdentifier:currentPosition]; - if (self.duration <= 0) { - [self applyConstraintFromString:[self formatTime:self.position] - forIdentifier:currentPosition]; - } else { - NSString *durFormat = [self formatTime:self.duration]; - [self applyConstraintFromString:durFormat forIdentifier:currentPosition]; - } -} - -- (void)updatePlayButton -{ - NSCustomTouchBarItem *tbItem = self.touchbarItems[play][@"tbItem"]; - if (!self.isVisible || !tbItem.visible) - return; - - NSButton *playButton = self.touchbarItems[play][@"view"]; - if (self.pause) { - playButton.image = self.touchbarItems[play][@"imageAlt"]; - } else { - playButton.image = self.touchbarItems[play][@"image"]; - } -} - -- (void)buttonAction:(NSButton *)sender -{ - NSString *identifier = [self getIdentifierFromView:sender]; - [self.app queueCommand:(char *)[self.touchbarItems[identifier][@"cmd"] UTF8String]]; -} - -- (void)seekbarChanged:(NSSlider *)slider -{ - NSString *identifier = [self getIdentifierFromView:slider]; - NSString *seek = [NSString stringWithFormat: - self.touchbarItems[identifier][@"cmd"], slider.doubleValue]; - [self.app queueCommand:(char *)[seek UTF8String]]; -} - -- (NSString *)formatTime:(int)time -{ - int seconds = time % 60; - int minutes = (time / 60) % 60; - int hours = time / (60 * 60); - - NSString *stime = hours > 0 ? [NSString stringWithFormat:@"%d:", hours] : @""; - stime = (stime.length > 0 || minutes > 9) ? - [NSString stringWithFormat:@"%@%02d:", stime, minutes] : - [NSString stringWithFormat:@"%d:", minutes]; - stime = [NSString stringWithFormat:@"%@%02d", stime, seconds]; - - return stime; -} - -- (void)removeConstraintForIdentifier:(NSTouchBarItemIdentifier)identifier -{ - NSTextField *field = self.touchbarItems[identifier][@"view"]; - [field removeConstraint:self.touchbarItems[identifier][@"constrain"]]; -} - -- (void)applyConstraintFromString:(NSString *)string - forIdentifier:(NSTouchBarItemIdentifier)identifier -{ - NSTextField *field = self.touchbarItems[identifier][@"view"]; - if (field) { - NSString *fString = [[string componentsSeparatedByCharactersInSet: - [NSCharacterSet decimalDigitCharacterSet]] componentsJoinedByString:@"0"]; - NSTextField *textField = [NSTextField labelWithString:fString]; - NSSize size = [textField frame].size; - - NSLayoutConstraint *con = - [NSLayoutConstraint constraintWithItem:field - attribute:NSLayoutAttributeWidth - relatedBy:NSLayoutRelationEqual - toItem:nil - attribute:NSLayoutAttributeNotAnAttribute - multiplier:1.0 - constant:(int)ceil(size.width*1.1)]; - [field addConstraint:con]; - [self.touchbarItems[identifier] setObject:con forKey:@"constrain"]; - } -} - -- (NSString *)getIdentifierFromView:(id)view -{ - NSString *identifier; - for (identifier in self.touchbarItems) - if([self.touchbarItems[identifier][@"view"] isEqual:view]) - break; - return identifier; -} - -- (void)processEvent:(struct mpv_event *)event -{ - switch (event->event_id) { - case MPV_EVENT_END_FILE: { - self.position = 0; - self.duration = 0; - break; - } - case MPV_EVENT_PROPERTY_CHANGE: { - [self handlePropertyChange:(mpv_event_property *)event->data]; - break; - } - } -} - -- (void)handlePropertyChange:(struct mpv_event_property *)property -{ - NSString *name = [NSString stringWithUTF8String:property->name]; - mpv_format format = property->format; - - if ([name isEqualToString:@"time-pos"] && format == MPV_FORMAT_DOUBLE) { - double newPosition = *(double *)property->data; - newPosition = newPosition < 0 ? 0 : newPosition; - if ((int)(floor(newPosition) - floor(self.position)) != 0) { - self.position = newPosition; - [self updateTouchBarTimeItems]; - } - } else if ([name isEqualToString:@"duration"] && format == MPV_FORMAT_DOUBLE) { - self.duration = *(double *)property->data; - [self updateTouchBarTimeItems]; - } else if ([name isEqualToString:@"pause"] && format == MPV_FORMAT_FLAG) { - self.pause = *(int *)property->data; - [self updatePlayButton]; - } -} - -@end diff --git a/osdep/macosx_versions.h b/osdep/macosx_versions.h deleted file mode 100644 index 29ab01eb5a1f2..0000000000000 --- a/osdep/macosx_versions.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -#ifndef MPV_MACOSX_VERSIONS -#define MPV_MACOSX_VERSIONS - -#if !defined(MAC_OS_X_VERSION_10_9) -# define MAC_OS_X_VERSION_10_9 1090 -#endif - -#if !defined(MAC_OS_X_VERSION_10_10) -# define MAC_OS_X_VERSION_10_10 101000 -#endif - -#if !defined(MAC_OS_X_VERSION_10_12) -# define MAC_OS_X_VERSION_10_12 101200 -#endif - -#endif /* MPV_MACOSX_VERSIONS */ diff --git a/osdep/main-fn-cocoa.c b/osdep/main-fn-cocoa.c deleted file mode 100644 index eeed127ead8ef..0000000000000 --- a/osdep/main-fn-cocoa.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "osdep/macosx_application.h" - -// This is needed because Cocoa absolutely requires creating the NSApplication -// singleton and running it in the "main" thread. It is apparently not -// possible to do this on a separate thread at all. It is not known how -// Apple managed this colossal fuckup. -int main(int argc, char *argv[]) -{ - return cocoa_main(argc, argv); -} diff --git a/osdep/meson.build b/osdep/meson.build index 60fc2f6d574fa..41bcfbf419003 100644 --- a/osdep/meson.build +++ b/osdep/meson.build @@ -1,59 +1,59 @@ -# custom swift targets -bridge = join_paths(source_root, 'osdep/macOS_swift_bridge.h') -header = join_paths(build_root, 'osdep/macOS_swift.h') -module = join_paths(build_root, 'osdep/macOS_swift.swiftmodule') -target = join_paths(build_root, 'osdep/macOS_swift.o') - -swift_flags = ['-frontend', '-c', '-sdk', macos_sdk_path, - '-enable-objc-interop', '-emit-objc-header', '-parse-as-library'] - -if swift_ver.version_compare('>=6.0') - swift_flags += ['-swift-version', '5'] -endif - -if get_option('debug') - swift_flags += '-g' -endif - -if get_option('optimization') != '0' - swift_flags += '-O' -endif - -if macos_10_11_features.allowed() - swift_flags += ['-D', 'HAVE_MACOS_10_11_FEATURES'] -endif - -if macos_10_14_features.allowed() - swift_flags += ['-D', 'HAVE_MACOS_10_14_FEATURES'] -endif - -extra_flags = get_option('swift-flags').split() -swift_flags += extra_flags - -swift_compile = [swift_prog, swift_flags, '-module-name', 'macOS_swift', - '-emit-module-path', '@OUTPUT0@', '-import-objc-header', bridge, - '-emit-objc-header-path', '@OUTPUT1@', '-o', '@OUTPUT2@', - '@INPUT@', '-I.', '-I' + source_root, - '-I' + libplacebo.get_variable('includedir', - default_value: source_root / 'subprojects' / 'libplacebo' / 'src' / 'include')] - -swift_targets = custom_target('swift_targets', - input: swift_sources, - output: ['macOS_swift.swiftmodule', 'macOS_swift.h', 'macOS_swift.o'], - command: swift_compile, -) -sources += swift_targets - -swift_lib_dir_py = find_program(join_paths(tools_directory, 'macos-swift-lib-directory.py')) -swift_lib_dir = run_command(swift_lib_dir_py, swift_prog.full_path(), check: true).stdout() -message('Detected Swift library directory: ' + swift_lib_dir) - -# linker flags -swift_link_flags = ['-L' + swift_lib_dir, '-Xlinker', '-rpath', - '-Xlinker', swift_lib_dir, '-rdynamic', '-Xlinker', - '-add_ast_path', '-Xlinker', module] -if swift_ver.version_compare('>=5.0') - swift_link_flags += ['-Xlinker', '-rpath', '-Xlinker', - '/usr/lib/swift', '-L/usr/lib/swift'] -endif -add_project_link_arguments(swift_link_flags, language: ['c', 'objc']) +# custom swift targets +bridge = join_paths(source_root, 'osdep/darwin/swift_bridge.h') +header = join_paths(build_root, 'osdep/darwin/swift.h') +module = join_paths(build_root, 'osdep/darwin/swift.swiftmodule') +target = join_paths(build_root, 'osdep/darwin/swift.o') + +swift_flags = ['-frontend', '-c', '-sdk', macos_sdk_path, + '-enable-objc-interop', '-emit-objc-header', '-parse-as-library'] + +if swift_ver.version_compare('>=6.0') + swift_flags += ['-swift-version', '5'] +endif + +if get_option('debug') + swift_flags += '-g' +endif + +if get_option('optimization') != '0' + swift_flags += '-O' +endif + +if macos_10_11_features.allowed() + swift_flags += ['-D', 'HAVE_MACOS_10_11_FEATURES'] +endif + +if macos_10_14_features.allowed() + swift_flags += ['-D', 'HAVE_MACOS_10_14_FEATURES'] +endif + +extra_flags = get_option('swift-flags').split() +swift_flags += extra_flags + +swift_compile = [swift_prog, swift_flags, '-module-name', 'macOS_swift', + '-emit-module-path', '@OUTPUT0@', '-import-objc-header', bridge, + '-emit-objc-header-path', '@OUTPUT1@', '-o', '@OUTPUT2@', + '@INPUT@', '-I.', '-I' + source_root, + '-I' + libplacebo.get_variable('includedir', + default_value: source_root / 'subprojects' / 'libplacebo' / 'src' / 'include')] + +swift_targets = custom_target('swift_targets', + input: swift_sources, + output: ['macOS_swift.swiftmodule', 'macOS_swift.h', 'macOS_swift.o'], + command: swift_compile, +) +sources += swift_targets + +swift_lib_dir_py = find_program(join_paths(tools_directory, 'macos-swift-lib-directory.py')) +swift_lib_dir = run_command(swift_lib_dir_py, swift_prog.full_path(), check: true).stdout() +message('Detected Swift library directory: ' + swift_lib_dir) + +# linker flags +swift_link_flags = ['-L' + swift_lib_dir, '-Xlinker', '-rpath', + '-Xlinker', swift_lib_dir, '-rdynamic', '-Xlinker', + '-add_ast_path', '-Xlinker', module] +if swift_ver.version_compare('>=5.0') + swift_link_flags += ['-Xlinker', '-rpath', '-Xlinker', + '/usr/lib/swift', '-L/usr/lib/swift'] +endif +add_project_link_arguments(swift_link_flags, language: ['c', 'objc']) diff --git a/osdep/path-darwin.c b/osdep/path-darwin.c deleted file mode 100644 index 0b55ea4c56c22..0000000000000 --- a/osdep/path-darwin.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -#include -#include - -#include "options/path.h" -#include "path.h" - -#include "config.h" - -static pthread_once_t path_init_once = PTHREAD_ONCE_INIT; - -static char mpv_home[512]; -static char old_home[512]; -static char mpv_cache[512]; -static char old_cache[512]; - -static void path_init(void) -{ - char *home = getenv("HOME"); - char *xdg_config = getenv("XDG_CONFIG_HOME"); - - if (xdg_config && xdg_config[0]) { - snprintf(mpv_home, sizeof(mpv_home), "%s/mpv", xdg_config); - } else if (home && home[0]) { - snprintf(mpv_home, sizeof(mpv_home), "%s/.config/mpv", home); - } - - // Maintain compatibility with old ~/.mpv - if (home && home[0]) { - snprintf(old_home, sizeof(old_home), "%s/.mpv", home); - snprintf(old_cache, sizeof(old_cache), "%s/.mpv/cache", home); - } - - if (home && home[0]) - snprintf(mpv_cache, sizeof(mpv_cache), "%s/Library/Caches/io.mpv", home); - - // If the old ~/.mpv exists, and the XDG config dir doesn't, use the old - // config dir only. - if (mp_path_exists(old_home) && !mp_path_exists(mpv_home)) { - snprintf(mpv_home, sizeof(mpv_home), "%s", old_home); - snprintf(mpv_cache, sizeof(mpv_cache), "%s", old_cache); - old_home[0] = '\0'; - old_cache[0] = '\0'; - } -} - -const char *mp_get_platform_path_darwin(void *talloc_ctx, const char *type) -{ - pthread_once(&path_init_once, path_init); - if (strcmp(type, "home") == 0) - return mpv_home; - if (strcmp(type, "old_home") == 0) - return old_home; - if (strcmp(type, "cache") == 0) - return mpv_cache; - if (strcmp(type, "global") == 0) - return MPV_CONFDIR; - if (strcmp(type, "desktop") == 0) - return getenv("HOME"); - return NULL; -} diff --git a/osdep/path-macosx.m b/osdep/path-macosx.m deleted file mode 100644 index 8a5a704e4987b..0000000000000 --- a/osdep/path-macosx.m +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -#import -#include "options/path.h" -#include "osdep/path.h" - -const char *mp_get_platform_path_osx(void *talloc_ctx, const char *type) -{ - if (strcmp(type, "osxbundle") == 0 && getenv("MPVBUNDLE")) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - NSString *path = [[NSBundle mainBundle] resourcePath]; - char *res = talloc_strdup(talloc_ctx, [path UTF8String]); - [pool release]; - return res; - } - if (strcmp(type, "desktop") == 0 && getenv("HOME")) - return mp_path_join(talloc_ctx, getenv("HOME"), "Desktop"); - return NULL; -} diff --git a/osdep/semaphore.h b/osdep/semaphore.h deleted file mode 100644 index cad2f7fb1f3eb..0000000000000 --- a/osdep/semaphore.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef MP_SEMAPHORE_H_ -#define MP_SEMAPHORE_H_ - -#include -#include - -// OSX provides non-working empty stubs, so we emulate them. -// This should be AS-safe, but cancellation issues were ignored. -// sem_getvalue() is not provided. -// sem_post() won't always correctly return an error on overflow. -// Process-shared semantics are not provided. - -#ifdef __APPLE__ - -#define MP_SEMAPHORE_EMULATION - -#include - -#define MP_SEM_VALUE_MAX 4096 - -typedef struct { - int wakeup_pipe[2]; - pthread_mutex_t lock; - // protected by lock - unsigned int count; -} mp_sem_t; - -int mp_sem_init(mp_sem_t *sem, int pshared, unsigned int value); -int mp_sem_wait(mp_sem_t *sem); -int mp_sem_trywait(mp_sem_t *sem); -int mp_sem_timedwait(mp_sem_t *sem, const struct timespec *abs_timeout); -int mp_sem_post(mp_sem_t *sem); -int mp_sem_destroy(mp_sem_t *sem); - -#undef sem_init -#undef sem_wait -#undef sem_trywait -#undef sem_timedwait -#undef sem_post -#undef sem_getvalue -#undef sem_destroy -#undef sem_getvalue -#undef sem_t -#undef SEM_VALUE_MAX - -#define sem_init mp_sem_init -#define sem_wait mp_sem_wait -#define sem_trywait mp_sem_trywait -#define sem_timedwait mp_sem_timedwait -#define sem_post mp_sem_post -#define sem_destroy mp_sem_destroy -#define sem_t mp_sem_t -#define SEM_VALUE_MAX MP_SEM_VALUE_MAX - -#define sem_getvalue (void) - -#endif - -#endif diff --git a/osdep/semaphore_osx.c b/osdep/semaphore_osx.c deleted file mode 100644 index 1e2015bddde2a..0000000000000 --- a/osdep/semaphore_osx.c +++ /dev/null @@ -1,123 +0,0 @@ -/* Copyright (C) 2017 the mpv developers - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include "osdep/semaphore.h" - -#ifdef MP_SEMAPHORE_EMULATION - -#include -#include -#include -#include -#include - -#include "osdep/io.h" - -int mp_sem_init(mp_sem_t *sem, int pshared, unsigned int value) -{ - if (pshared) { - errno = ENOSYS; - return -1; - } - if (value > INT_MAX) { - errno = EINVAL; - return -1; - } - if (mp_make_wakeup_pipe(sem->wakeup_pipe) < 0) - return -1; - sem->count = 0; - pthread_mutex_init(&sem->lock, NULL); - return 0; -} - -int mp_sem_wait(mp_sem_t *sem) -{ - return mp_sem_timedwait(sem, NULL); -} - -int mp_sem_trywait(mp_sem_t *sem) -{ - int r = -1; - pthread_mutex_lock(&sem->lock); - if (sem->count == 0) { - char buf[1024]; - ssize_t s = read(sem->wakeup_pipe[0], buf, sizeof(buf)); - if (s > 0 && s <= INT_MAX - sem->count) // can't handle overflows correctly - sem->count += s; - } - if (sem->count > 0) { - sem->count -= 1; - r = 0; - } - pthread_mutex_unlock(&sem->lock); - if (r < 0) - errno = EAGAIN; - return r; -} - -int mp_sem_timedwait(mp_sem_t *sem, const struct timespec *abs_timeout) -{ - while (1) { - if (!mp_sem_trywait(sem)) - return 0; - - int timeout_ms = -1; - if (abs_timeout) { - timeout_ms = 0; - - // OSX does not provide clock_gettime() either. - struct timeval tv; - gettimeofday(&tv, NULL); - - if (abs_timeout->tv_sec >= tv.tv_sec) { - long long msec = (abs_timeout->tv_sec - tv.tv_sec) * 1000LL + - abs_timeout->tv_nsec / 1000LL / 1000LL - tv.tv_usec / 1000LL; - if (msec > INT_MAX) - msec = INT_MAX; - if (msec < 0) - msec = 0; - timeout_ms = msec; - } - } - struct pollfd fd = {.fd = sem->wakeup_pipe[0], .events = POLLIN}; - int r = poll(&fd, 1, timeout_ms); - if (r < 0) - return -1; - if (r == 0) { - errno = ETIMEDOUT; - return -1; - } - } -} - -int mp_sem_post(mp_sem_t *sem) -{ - if (write(sem->wakeup_pipe[1], &(char){0}, 1) == 1) - return 0; - // Actually we can't handle overflow fully correctly, because we can't - // check sem->count atomically, while still being AS-safe. - errno = EOVERFLOW; - return -1; -} - -int mp_sem_destroy(mp_sem_t *sem) -{ - close(sem->wakeup_pipe[0]); - close(sem->wakeup_pipe[1]); - pthread_mutex_destroy(&sem->lock); - return 0; -} - -#endif diff --git a/osdep/terminal-dummy.c b/osdep/terminal-dummy.c deleted file mode 100644 index 4b33d786a8fcf..0000000000000 --- a/osdep/terminal-dummy.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "terminal.h" - -void terminal_init(void) -{ -} - -void terminal_setup_getch(struct input_ctx *ictx) -{ -} - -void terminal_uninit(void) -{ -} - -bool terminal_in_background(void) -{ - return false; -} - -void terminal_get_size(int *w, int *h) -{ -} - -void terminal_get_size2(int *rows, int *cols, int *px_width, int *px_height) -{ -} - -void mp_write_console_ansi(void *wstream, char *buf) -{ -} - -bool terminal_try_attach(void) -{ - return false; -} diff --git a/osdep/timer-darwin.c b/osdep/timer-darwin.c deleted file mode 100644 index bb8a9b43248b8..0000000000000 --- a/osdep/timer-darwin.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Precise timer routines using Mach timing - * - * Copyright (c) 2003-2004, Dan Villiom Podlaski Christiansen - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "common/msg.h" -#include "timer.h" - -static double timebase_ratio_ns; - -void mp_sleep_ns(int64_t ns) -{ - uint64_t deadline = ns / timebase_ratio_ns + mach_absolute_time(); - mach_wait_until(deadline); -} - -uint64_t mp_raw_time_ns(void) -{ - return mach_absolute_time() * timebase_ratio_ns; -} - -void mp_raw_time_init(void) -{ - struct mach_timebase_info timebase; - - mach_timebase_info(&timebase); - timebase_ratio_ns = (double)timebase.numer / (double)timebase.denom; -} diff --git a/osdep/language-posix.c b/osdep/unix/language.c similarity index 100% rename from osdep/language-posix.c rename to osdep/unix/language.c diff --git a/osdep/main-fn-unix.c b/osdep/unix/main-fn.c similarity index 100% rename from osdep/main-fn-unix.c rename to osdep/unix/main-fn.c diff --git a/osdep/path-unix.c b/osdep/unix/path.c similarity index 100% rename from osdep/path-unix.c rename to osdep/unix/path.c diff --git a/osdep/poll_wrapper.c b/osdep/unix/poll_wrapper.c similarity index 100% rename from osdep/poll_wrapper.c rename to osdep/unix/poll_wrapper.c diff --git a/osdep/poll_wrapper.h b/osdep/unix/poll_wrapper.h similarity index 100% rename from osdep/poll_wrapper.h rename to osdep/unix/poll_wrapper.h diff --git a/osdep/subprocess-posix.c b/osdep/unix/subprocess.c similarity index 100% rename from osdep/subprocess-posix.c rename to osdep/unix/subprocess.c diff --git a/osdep/terminal-unix.c b/osdep/unix/terminal.c similarity index 99% rename from osdep/terminal-unix.c rename to osdep/unix/terminal.c index d31e1e753f3d7..7431b7d162060 100644 --- a/osdep/terminal-unix.c +++ b/osdep/unix/terminal.c @@ -31,7 +31,7 @@ #include "osdep/io.h" #include "osdep/threads.h" -#include "osdep/poll_wrapper.h" +#include "osdep/unix/poll_wrapper.h" #include "common/common.h" #include "misc/bstr.h" diff --git a/osdep/timer-linux.c b/osdep/unix/timer.c similarity index 98% rename from osdep/timer-linux.c rename to osdep/unix/timer.c index ff4b137cb227e..d80f25e6586b7 100644 --- a/osdep/timer-linux.c +++ b/osdep/unix/timer.c @@ -20,7 +20,8 @@ #include #include -#include "timer.h" + +#include void mp_sleep_ns(int64_t ns) { diff --git a/osdep/path-uwp.c b/osdep/uwp/path.c similarity index 100% rename from osdep/path-uwp.c rename to osdep/uwp/path.c diff --git a/osdep/win32-console-wrapper.c b/osdep/win32/console.c similarity index 100% rename from osdep/win32-console-wrapper.c rename to osdep/win32/console.c diff --git a/osdep/glob-win.c b/osdep/win32/glob.c similarity index 100% rename from osdep/glob-win.c rename to osdep/win32/glob.c diff --git a/osdep/w32_keyboard.c b/osdep/win32/keyboard.c similarity index 99% rename from osdep/w32_keyboard.c rename to osdep/win32/keyboard.c index 6eaa99c1208ee..2ef2cf0a996a5 100644 --- a/osdep/w32_keyboard.c +++ b/osdep/win32/keyboard.c @@ -16,7 +16,7 @@ */ #include -#include "osdep/w32_keyboard.h" +#include "keyboard.h" #include "input/keycodes.h" struct keymap { diff --git a/osdep/w32_keyboard.h b/osdep/win32/keyboard.h similarity index 100% rename from osdep/w32_keyboard.h rename to osdep/win32/keyboard.h diff --git a/osdep/language-win.c b/osdep/win32/language.c similarity index 100% rename from osdep/language-win.c rename to osdep/win32/language.c diff --git a/osdep/main-fn-win.c b/osdep/win32/main-fn.c similarity index 100% rename from osdep/main-fn-win.c rename to osdep/win32/main-fn.c diff --git a/osdep/win32/meson.build b/osdep/win32/meson.build new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/osdep/mpv.exe.manifest b/osdep/win32/mpv.exe.manifest similarity index 100% rename from osdep/mpv.exe.manifest rename to osdep/win32/mpv.exe.manifest diff --git a/osdep/mpv.rc b/osdep/win32/mpv.rc similarity index 100% rename from osdep/mpv.rc rename to osdep/win32/mpv.rc diff --git a/osdep/path-win.c b/osdep/win32/path.c similarity index 100% rename from osdep/path-win.c rename to osdep/win32/path.c diff --git a/osdep/subprocess-win.c b/osdep/win32/subprocess.c similarity index 99% rename from osdep/subprocess-win.c rename to osdep/win32/subprocess.c index bb3527eaa6426..923b79be41f93 100644 --- a/osdep/subprocess-win.c +++ b/osdep/win32/subprocess.c @@ -21,7 +21,7 @@ #include "osdep/subprocess.h" #include "osdep/io.h" -#include "osdep/windows_utils.h" +#include #include "mpv_talloc.h" #include "common/common.h" diff --git a/osdep/terminal-win.c b/osdep/win32/terminal.c similarity index 99% rename from osdep/terminal-win.c rename to osdep/win32/terminal.c index 4e88f29679ca8..e5cfcff0eb71f 100644 --- a/osdep/terminal-win.c +++ b/osdep/win32/terminal.c @@ -29,10 +29,10 @@ #include "common/common.h" #include "input/keycodes.h" #include "input/input.h" -#include "terminal.h" +#include "osdep/terminal.h" #include "osdep/io.h" #include "osdep/threads.h" -#include "osdep/w32_keyboard.h" +#include // https://docs.microsoft.com/en-us/windows/console/setconsolemode // These values are effective on Windows 10 build 16257 (August 2017) or later diff --git a/osdep/timer-win32.c b/osdep/win32/timer.c similarity index 99% rename from osdep/timer-win32.c rename to osdep/win32/timer.c index 7867b5a5251dd..7b60c8a0716dc 100644 --- a/osdep/timer-win32.c +++ b/osdep/win32/timer.c @@ -21,7 +21,7 @@ #include #include -#include "timer.h" +#include #include "config.h" diff --git a/osdep/windows_utils.c b/osdep/win32/utils.c similarity index 99% rename from osdep/windows_utils.c rename to osdep/win32/utils.c index 8cedf939e23d2..6e0076730651f 100644 --- a/osdep/windows_utils.c +++ b/osdep/win32/utils.c @@ -26,7 +26,7 @@ #include #include "common/common.h" -#include "windows_utils.h" +#include "utils.h" char *mp_GUID_to_str_buf(char *buf, size_t buf_size, const GUID *guid) { diff --git a/osdep/windows_utils.h b/osdep/win32/utils.h similarity index 100% rename from osdep/windows_utils.h rename to osdep/win32/utils.h diff --git a/player/main.c b/player/main.c index cd84026730ddf..acca30d17d21c 100644 --- a/player/main.c +++ b/player/main.c @@ -71,7 +71,7 @@ static const char def_config[] = ; #if HAVE_COCOA -#include "osdep/macosx_events.h" +#include "events.h" #endif #ifndef FULLCONFIG diff --git a/player/meson.build b/player/meson.build index dc334b8c963ee..12ab19a75743b 100644 --- a/player/meson.build +++ b/player/meson.build @@ -4,7 +4,7 @@ subdir('lua') # Meson doesn't allow having multiple build targets with the same name in the same file. # Just generate the com in here for windows builds. if win32 and get_option('cplayer') - wrapper_sources= '../osdep/win32-console-wrapper.c' + wrapper_sources= '../osdep/win32/console.c' executable('mpv', wrapper_sources, c_args: '-municode', link_args: '-municode', name_suffix: 'com', install: true) endif diff --git a/test/meson.build b/test/meson.build index a2b8ce496c893..30fe2ead56e1c 100644 --- a/test/meson.build +++ b/test/meson.build @@ -40,7 +40,7 @@ test_utils_deps = [libavutil, libm] if features['win32-internal-pthreads'] test_utils_args += '-DWIN32_TESTS' test_utils_files += ['osdep/win32/pthread.c', - 'osdep/windows_utils.c'] + 'osdep/win32/utils.c'] else test_utils_deps += pthreads endif diff --git a/video/d3d.c b/video/d3d.c index dfb999b8548ef..2702138408e7d 100644 --- a/video/d3d.c +++ b/video/d3d.c @@ -34,7 +34,7 @@ #include "video/hwdec.h" #include "video/mp_image.h" #include "video/mp_image_pool.h" -#include "osdep/windows_utils.h" +#include #include "d3d.h" diff --git a/video/filter/vf_d3d11vpp.c b/video/filter/vf_d3d11vpp.c index 3f00c5aa4dca9..f4f167cf13963 100644 --- a/video/filter/vf_d3d11vpp.c +++ b/video/filter/vf_d3d11vpp.c @@ -24,7 +24,7 @@ #include "common/common.h" #include "osdep/timer.h" -#include "osdep/windows_utils.h" +#include #include "filters/f_autoconvert.h" #include "filters/filter.h" #include "filters/filter_internal.h" diff --git a/video/out/cocoa/events_view.m b/video/out/cocoa/events_view.m index 2cfe3f2fda629..c744dfdb4f12b 100644 --- a/video/out/cocoa/events_view.m +++ b/video/out/cocoa/events_view.m @@ -18,7 +18,7 @@ #include "input/input.h" #include "input/keycodes.h" -#include "osdep/macosx_compat.h" +#include "compat.h" #include "video/out/cocoa_common.h" #include "events_view.h" diff --git a/video/out/cocoa/video_view.m b/video/out/cocoa/video_view.m index c0457d2a95ea9..c6c02cdf312e3 100644 --- a/video/out/cocoa/video_view.m +++ b/video/out/cocoa/video_view.m @@ -15,7 +15,7 @@ * License along with mpv. If not, see . */ -#include "osdep/macosx_compat.h" +#include "compat.h" #include "video/out/cocoa_common.h" #include "video_view.h" diff --git a/video/out/cocoa/window.m b/video/out/cocoa/window.m index 011d8e422766d..229cc9f5320c8 100644 --- a/video/out/cocoa/window.m +++ b/video/out/cocoa/window.m @@ -19,8 +19,8 @@ #include "input/keycodes.h" -#include "osdep/macosx_events.h" -#include "osdep/macosx_compat.h" +#include "events.h" +#include "compat.h" #include "video/out/cocoa_common.h" #include "window.h" diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index d670a7c1c3edf..2003870ba1ea5 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -32,12 +32,12 @@ #import "video/out/cocoa/mpvadapter.h" #include "osdep/threads.h" -#include "osdep/macosx_compat.h" -#include "osdep/macosx_events_objc.h" +#include "compat.h" +#include "events_objc.h" #include "osdep/timer.h" -#include "osdep/macosx_application.h" -#include "osdep/macosx_application_objc.h" +#include "application.h" +#include "application_objc.h" #include "options/options.h" #include "video/out/vo.h" diff --git a/video/out/d3d11/context.c b/video/out/d3d11/context.c index 05f04fdb6b082..ea6bbc7b5899e 100644 --- a/video/out/d3d11/context.c +++ b/video/out/d3d11/context.c @@ -18,7 +18,7 @@ #include "common/msg.h" #include "options/m_config.h" #include "osdep/timer.h" -#include "osdep/windows_utils.h" +#include #include "video/out/gpu/context.h" #include "video/out/gpu/d3d11_helpers.h" diff --git a/video/out/d3d11/hwdec_d3d11va.c b/video/out/d3d11/hwdec_d3d11va.c index 6aaa12bc66a5a..ba4ec7f1c33a2 100644 --- a/video/out/d3d11/hwdec_d3d11va.c +++ b/video/out/d3d11/hwdec_d3d11va.c @@ -21,7 +21,7 @@ #include "common/common.h" #include "options/m_config.h" -#include "osdep/windows_utils.h" +#include #include "video/hwdec.h" #include "video/d3d.h" #include "video/out/d3d11/ra_d3d11.h" diff --git a/video/out/d3d11/hwdec_dxva2dxgi.c b/video/out/d3d11/hwdec_dxva2dxgi.c index 62158d467b453..33dfceca267e3 100644 --- a/video/out/d3d11/hwdec_dxva2dxgi.c +++ b/video/out/d3d11/hwdec_dxva2dxgi.c @@ -21,7 +21,7 @@ #include #include "common/common.h" -#include "osdep/windows_utils.h" +#include #include "video/hwdec.h" #include "video/d3d.h" #include "video/out/d3d11/ra_d3d11.h" diff --git a/video/out/d3d11/ra_d3d11.c b/video/out/d3d11/ra_d3d11.c index e2a2b633b6c78..a5d0b29215d8a 100644 --- a/video/out/d3d11/ra_d3d11.c +++ b/video/out/d3d11/ra_d3d11.c @@ -10,7 +10,7 @@ #include "osdep/io.h" #include "osdep/subprocess.h" #include "osdep/timer.h" -#include "osdep/windows_utils.h" +#include #include "video/out/gpu/spirv.h" #include "video/out/gpu/utils.h" diff --git a/video/out/drm_common.c b/video/out/drm_common.c index d3cb58e8a60cb..2535012857dae 100644 --- a/video/out/drm_common.c +++ b/video/out/drm_common.c @@ -42,7 +42,7 @@ #include "common/msg.h" #include "options/m_config.h" #include "osdep/io.h" -#include "osdep/poll_wrapper.h" +#include "osdep/unix/poll_wrapper.h" #include "osdep/timer.h" #include "misc/ctype.h" #include "video/out/vo.h" @@ -431,7 +431,7 @@ void vo_drm_release_crtc(struct vo_drm_state *drm) if (request) drmModeAtomicFree(request); - + if (!success) MP_ERR(drm, "Failed to restore previous mode\n"); diff --git a/video/out/gpu/d3d11_helpers.c b/video/out/gpu/d3d11_helpers.c index b3e524056e516..2df310d71aa13 100644 --- a/video/out/gpu/d3d11_helpers.c +++ b/video/out/gpu/d3d11_helpers.c @@ -25,7 +25,7 @@ #include "common/msg.h" #include "misc/bstr.h" #include "osdep/io.h" -#include "osdep/windows_utils.h" +#include #include "d3d11_helpers.h" diff --git a/video/out/gpu_next/context.c b/video/out/gpu_next/context.c index 2887cff938f78..f7b2545078031 100644 --- a/video/out/gpu_next/context.c +++ b/video/out/gpu_next/context.c @@ -33,7 +33,7 @@ #include "video/out/gpu/video.h" #if HAVE_D3D11 -#include "osdep/windows_utils.h" +#include #include "video/out/d3d11/ra_d3d11.h" #include "video/out/d3d11/context.h" #endif diff --git a/video/out/opengl/context_angle.c b/video/out/opengl/context_angle.c index 553718af24fa3..37c22dcd44b97 100644 --- a/video/out/opengl/context_angle.c +++ b/video/out/opengl/context_angle.c @@ -30,7 +30,7 @@ #include "common/common.h" #include "options/m_config.h" #include "video/out/w32_common.h" -#include "osdep/windows_utils.h" +#include #include "context.h" #include "utils.h" diff --git a/video/out/opengl/context_cocoa.c b/video/out/opengl/context_cocoa.c index ec8ec27458def..9f5aa888e9b24 100644 --- a/video/out/opengl/context_cocoa.c +++ b/video/out/opengl/context_cocoa.c @@ -20,7 +20,7 @@ #include "options/m_config.h" #include "video/out/cocoa_common.h" #include "context.h" -#include "osdep/macosx_application.h" +#include "application.h" struct priv { GL gl; diff --git a/video/out/opengl/context_dxinterop.c b/video/out/opengl/context_dxinterop.c index cda696f71ba44..086848058a42c 100644 --- a/video/out/opengl/context_dxinterop.c +++ b/video/out/opengl/context_dxinterop.c @@ -19,7 +19,7 @@ #include #include #include -#include "osdep/windows_utils.h" +#include #include "video/out/w32_common.h" #include "context.h" #include "utils.h" diff --git a/video/out/opengl/hwdec_d3d11egl.c b/video/out/opengl/hwdec_d3d11egl.c index c3120914ea2c1..26c58341cf0c7 100644 --- a/video/out/opengl/hwdec_d3d11egl.c +++ b/video/out/opengl/hwdec_d3d11egl.c @@ -26,7 +26,7 @@ #include "common/common.h" #include "osdep/timer.h" -#include "osdep/windows_utils.h" +#include #include "video/out/gpu/hwdec.h" #include "ra_gl.h" #include "video/hwdec.h" diff --git a/video/out/opengl/hwdec_dxva2egl.c b/video/out/opengl/hwdec_dxva2egl.c index 979ef59745790..6e69b718dac5a 100644 --- a/video/out/opengl/hwdec_dxva2egl.c +++ b/video/out/opengl/hwdec_dxva2egl.c @@ -26,7 +26,7 @@ #include "common/common.h" #include "osdep/timer.h" -#include "osdep/windows_utils.h" +#include #include "video/out/gpu/hwdec.h" #include "ra_gl.h" #include "video/hwdec.h" diff --git a/video/out/opengl/hwdec_dxva2gldx.c b/video/out/opengl/hwdec_dxva2gldx.c index 01728130d7182..2bbfab1db895b 100644 --- a/video/out/opengl/hwdec_dxva2gldx.c +++ b/video/out/opengl/hwdec_dxva2gldx.c @@ -19,7 +19,7 @@ #include #include "common/common.h" -#include "osdep/windows_utils.h" +#include #include "video/out/gpu/hwdec.h" #include "ra_gl.h" #include "video/hwdec.h" diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c index e2436f64f1919..354b1d65cad03 100644 --- a/video/out/vo_gpu_next.c +++ b/video/out/vo_gpu_next.c @@ -50,7 +50,7 @@ #if HAVE_D3D11 && defined(PL_HAVE_D3D11) #include #include "video/out/d3d11/ra_d3d11.h" -#include "osdep/windows_utils.h" +#include #endif #if PL_API_VER >= 309 diff --git a/video/out/w32_common.c b/video/out/w32_common.c index f58149e3c9f13..c969999e92727 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -43,7 +43,7 @@ #include "win32/droptarget.h" #include "osdep/io.h" #include "osdep/threads.h" -#include "osdep/w32_keyboard.h" +#include #include "misc/dispatch.h" #include "misc/rendezvous.h" #include "mpv_talloc.h" diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index d5ab2fe1c9500..4cc72c77fa9ec 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -29,7 +29,7 @@ #include "input/keycodes.h" #include "options/m_config.h" #include "osdep/io.h" -#include "osdep/poll_wrapper.h" +#include "osdep/unix/poll_wrapper.h" #include "osdep/timer.h" #include "present_sync.h" #include "wayland_common.h" diff --git a/video/out/win32/droptarget.c b/video/out/win32/droptarget.c index 8a33522df0384..b2d544dbc12cd 100644 --- a/video/out/win32/droptarget.c +++ b/video/out/win32/droptarget.c @@ -25,7 +25,7 @@ #include "input/input.h" #include "input/event.h" #include "osdep/io.h" -#include "osdep/windows_utils.h" +#include #include "mpv_talloc.h" #include "droptarget.h" diff --git a/video/out/x11_common.c b/video/out/x11_common.c index f77f4c86f874d..750753835278a 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -55,7 +55,7 @@ #include "vo.h" #include "win_state.h" #include "osdep/io.h" -#include "osdep/poll_wrapper.h" +#include "osdep/unix/poll_wrapper.h" #include "osdep/timer.h" #include "osdep/subprocess.h"