summaryrefslogtreecommitdiffstats
path: root/osdep
diff options
context:
space:
mode:
Diffstat (limited to 'osdep')
-rw-r--r--osdep/endian.h4
-rw-r--r--osdep/io.c6
-rw-r--r--osdep/mac/event_helper.swift2
-rw-r--r--osdep/mac/log_helper.swift13
-rw-r--r--osdep/mac/meson.build4
-rw-r--r--osdep/mac/swift_compat.swift18
-rw-r--r--osdep/path-win.c9
-rw-r--r--osdep/terminal-unix.c2
-rw-r--r--osdep/terminal-win.c7
-rw-r--r--osdep/terminal.h2
-rw-r--r--osdep/w32_keyboard.c2
11 files changed, 60 insertions, 9 deletions
diff --git a/osdep/endian.h b/osdep/endian.h
index c6d13760ea..733cecca74 100644
--- a/osdep/endian.h
+++ b/osdep/endian.h
@@ -9,6 +9,10 @@
#define BYTE_ORDER __BYTE_ORDER
#define LITTLE_ENDIAN __LITTLE_ENDIAN
#define BIG_ENDIAN __BIG_ENDIAN
+#elif defined(__BYTE_ORDER__)
+#define BYTE_ORDER __BYTE_ORDER__
+#define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
+#define BIG_ENDIAN __ORDER_BIG_ENDIAN__
#elif defined(__DARWIN_BYTE_ORDER)
#define BYTE_ORDER __DARWIN_BYTE_ORDER
#define LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN
diff --git a/osdep/io.c b/osdep/io.c
index a58eb6ec04..1e8171de59 100644
--- a/osdep/io.c
+++ b/osdep/io.c
@@ -664,11 +664,12 @@ static void free_env(void)
static void init_getenv(void)
{
#if !HAVE_UWP
- wchar_t *wenv = GetEnvironmentStringsW();
- if (!wenv)
+ wchar_t *wenv_begin = GetEnvironmentStringsW();
+ if (!wenv_begin)
return;
utf8_environ_ctx = talloc_new(NULL);
int num_env = 0;
+ wchar_t *wenv = wenv_begin;
while (1) {
size_t len = wcslen(wenv);
if (!len)
@@ -677,6 +678,7 @@ static void init_getenv(void)
MP_TARRAY_APPEND(utf8_environ_ctx, utf8_environ, num_env, s);
wenv += len + 1;
}
+ FreeEnvironmentStringsW(wenv_begin);
MP_TARRAY_APPEND(utf8_environ_ctx, utf8_environ, num_env, NULL);
// Avoid showing up in leak detectors etc.
atexit(free_env);
diff --git a/osdep/mac/event_helper.swift b/osdep/mac/event_helper.swift
index 0f194ce8aa..6331a64a9f 100644
--- a/osdep/mac/event_helper.swift
+++ b/osdep/mac/event_helper.swift
@@ -75,7 +75,7 @@ class EventHelper {
mpv_set_wakeup_callback(mpv, wakeup, TypeHelper.bridge(obj: self))
}
- func subscribe(_ subscriber: any EventSubscriber, event: Event) {
+ func subscribe(_ subscriber: EventSubscriber, event: Event) {
guard let mpv = mpv else { return }
if !event.name.isEmpty {
diff --git a/osdep/mac/log_helper.swift b/osdep/mac/log_helper.swift
index 690d7bcbc1..b3464fd1bd 100644
--- a/osdep/mac/log_helper.swift
+++ b/osdep/mac/log_helper.swift
@@ -20,7 +20,12 @@ import os
class LogHelper {
var log: OpaquePointer?
- let logger = Logger(subsystem: "io.mpv", category: "mpv")
+#if HAVE_MACOS_11_FEATURES
+ @available(macOS 11.0, *)
+ var logger: Logger? {
+ return Logger(subsystem: "io.mpv", category: "mpv")
+ }
+#endif
let loggerMapping: [Int: OSLogType] = [
MSGL_V: .debug,
@@ -51,7 +56,11 @@ class LogHelper {
func send(message: String, type: Int) {
guard let log = log else {
- logger.log(level: loggerMapping[type] ?? .default, "\(message, privacy: .public)")
+#if HAVE_MACOS_11_FEATURES
+ if #available(macOS 11.0, *) {
+ logger?.log(level: loggerMapping[type] ?? .default, "\(message, privacy: .public)")
+ }
+#endif
return
}
diff --git a/osdep/mac/meson.build b/osdep/mac/meson.build
index 4358173c17..9116d81476 100644
--- a/osdep/mac/meson.build
+++ b/osdep/mac/meson.build
@@ -19,6 +19,10 @@ if get_option('optimization') != '0'
swift_flags += '-O'
endif
+if macos_10_15_4_features.allowed()
+ swift_flags += ['-D', 'HAVE_MACOS_10_15_4_FEATURES']
+endif
+
if macos_11_features.allowed()
swift_flags += ['-D', 'HAVE_MACOS_11_FEATURES']
endif
diff --git a/osdep/mac/swift_compat.swift b/osdep/mac/swift_compat.swift
index 6924d5cfca..24365cdd4a 100644
--- a/osdep/mac/swift_compat.swift
+++ b/osdep/mac/swift_compat.swift
@@ -15,6 +15,16 @@
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
+#if !swift(>=5.7)
+extension NSCondition {
+ func withLock<R>(_ body: () throws -> R) rethrows -> R {
+ self.lock()
+ defer { self.unlock() }
+ return try body()
+ }
+}
+#endif
+
#if !swift(>=5.0)
extension Data {
mutating func withUnsafeMutableBytes<Type>(_ body: (UnsafeMutableRawBufferPointer) throws -> Type) rethrows -> Type {
@@ -33,3 +43,11 @@ extension NSDraggingInfo {
}
}
#endif
+
+#if !HAVE_MACOS_12_FEATURES && HAVE_MACOS_11_FEATURES
+@available(macOS 11.0, *)
+extension CGColorSpace {
+ static let itur_2100_HLG: CFString = kCGColorSpaceITUR_2100_HLG
+ static let itur_2100_PQ: CFString = kCGColorSpaceITUR_2100_PQ
+}
+#endif
diff --git a/osdep/path-win.c b/osdep/path-win.c
index 3b104cac03..10884cb384 100644
--- a/osdep/path-win.c
+++ b/osdep/path-win.c
@@ -76,12 +76,19 @@ static char *mp_get_win_local_app_dir(void *talloc_ctx)
return path ? mp_path_join(talloc_ctx, path, "mpv") : NULL;
}
+static void path_uninit(void)
+{
+ TA_FREEP(&portable_path);
+}
+
static void path_init(void)
{
void *tmp = talloc_new(NULL);
char *path = mp_get_win_exe_subdir(tmp, "portable_config");
- if (path && mp_path_exists(path))
+ if (path && mp_path_exists(path)) {
portable_path = talloc_strdup(NULL, path);
+ atexit(path_uninit);
+ }
talloc_free(tmp);
}
diff --git a/osdep/terminal-unix.c b/osdep/terminal-unix.c
index 94d3e6085e..6f70548875 100644
--- a/osdep/terminal-unix.c
+++ b/osdep/terminal-unix.c
@@ -109,7 +109,7 @@ static const struct key_entry keys[] = {
{"\033[B", MP_KEY_DOWN},
{"\033[C", MP_KEY_RIGHT},
{"\033[D", MP_KEY_LEFT},
- {"\033[E", MP_KEY_KP5},
+ {"\033[E", MP_KEY_KPBEGIN},
{"\033[F", MP_KEY_END},
{"\033[H", MP_KEY_HOME},
diff --git a/osdep/terminal-win.c b/osdep/terminal-win.c
index 435354155a..1c059ff688 100644
--- a/osdep/terminal-win.c
+++ b/osdep/terminal-win.c
@@ -632,6 +632,11 @@ void terminal_set_mouse_input(bool enable)
}
}
+static VOID NTAPI fls_free_cb(PVOID ptr)
+{
+ talloc_free(ptr);
+}
+
void terminal_init(void)
{
CONSOLE_SCREEN_BUFFER_INFO cinfo;
@@ -653,6 +658,6 @@ void terminal_init(void)
GetConsoleScreenBufferInfo(hSTDOUT, &cinfo);
stdoutAttrs = cinfo.wAttributes;
- tmp_buffers_key = FlsAlloc((PFLS_CALLBACK_FUNCTION)talloc_free);
+ tmp_buffers_key = FlsAlloc(fls_free_cb);
utf8_output = SetConsoleOutputCP(CP_UTF8);
}
diff --git a/osdep/terminal.h b/osdep/terminal.h
index 4174cf2d3b..1c63809f59 100644
--- a/osdep/terminal.h
+++ b/osdep/terminal.h
@@ -38,6 +38,8 @@
#define TERM_ESC_ENABLE_MOUSE "\033[?1003h"
#define TERM_ESC_DISABLE_MOUSE "\033[?1003l"
+#define TERM_ESC_GREY "\033[38;5;8m"
+
struct input_ctx;
/* Global initialization for terminal output. */
diff --git a/osdep/w32_keyboard.c b/osdep/w32_keyboard.c
index 57988ec0ec..109e751d9d 100644
--- a/osdep/w32_keyboard.c
+++ b/osdep/w32_keyboard.c
@@ -67,7 +67,7 @@ static const struct keymap vk_map[] = {
// numpad without numlock
{VK_INSERT, MP_KEY_KPINS}, {VK_END, MP_KEY_KPEND}, {VK_DOWN, MP_KEY_KPDOWN},
- {VK_NEXT, MP_KEY_KPPGDOWN}, {VK_LEFT, MP_KEY_KPLEFT}, {VK_CLEAR, MP_KEY_KP5},
+ {VK_NEXT, MP_KEY_KPPGDOWN}, {VK_LEFT, MP_KEY_KPLEFT}, {VK_CLEAR, MP_KEY_KPBEGIN},
{VK_RIGHT, MP_KEY_KPRIGHT}, {VK_HOME, MP_KEY_KPHOME}, {VK_UP, MP_KEY_KPUP},
{VK_PRIOR, MP_KEY_KPPGUP}, {VK_DELETE, MP_KEY_KPDEL},