summaryrefslogtreecommitdiffstats
path: root/osdep
diff options
context:
space:
mode:
authorder richter <der.richter@gmx.de>2023-11-23 17:44:02 +0100
committerder richter <der.richter@gmx.de>2023-11-25 19:04:07 +0100
commit3f2bc2e5355e7588585de3f74b224947e89ce256 (patch)
tree17656ced0e68965ee0fea58fe55ad87dab360b86 /osdep
parent5aac4c1aee909ece346ba54b262cf915ca314483 (diff)
downloadmpv-3f2bc2e5355e7588585de3f74b224947e89ce256.tar.bz2
mpv-3f2bc2e5355e7588585de3f74b224947e89ce256.tar.xz
mac: fix libmpv usage without embedding
NSApp is only an Application when initialised from mpv itself. when used via libmpv an Application is never initialised and mpv would always immediately exit. make the retrieval of the vo and mac options static so they can be retrieved in all cases. Fixes #12518
Diffstat (limited to 'osdep')
-rw-r--r--osdep/macos/libmpv_helper.swift6
-rw-r--r--osdep/macos/mpv_helper.swift15
-rw-r--r--osdep/macosx_application.m4
-rw-r--r--osdep/macosx_application_objc.h4
4 files changed, 9 insertions, 20 deletions
diff --git a/osdep/macos/libmpv_helper.swift b/osdep/macos/libmpv_helper.swift
index 8b1c697da2..572b250980 100644
--- a/osdep/macos/libmpv_helper.swift
+++ b/osdep/macos/libmpv_helper.swift
@@ -34,10 +34,8 @@ class LibmpvHelper {
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
+ let global = mp_client_get_global(mpvHandle)
+ guard let ptr = mp_get_config_group(nil, global, Application.getMacOSConf()) else
{
log.sendError("macOS config group couldn't be retrieved'")
exit(1)
diff --git a/osdep/macos/mpv_helper.swift b/osdep/macos/mpv_helper.swift
index 3b2a7162cb..6e5a80dc89 100644
--- a/osdep/macos/mpv_helper.swift
+++ b/osdep/macos/mpv_helper.swift
@@ -42,23 +42,14 @@ class MPVHelper {
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
+ guard let cache = m_config_cache_alloc(vo, vo.pointee.global, Application.getVoSubConf()),
+ let macCache = m_config_cache_alloc(vo, vo.pointee.global, Application.getMacOSConf()) else
{
- log.sendError("NSApp couldn't be retrieved")
+ // will never be hit, mp_get_config_group asserts for invalid groups
exit(1)
}
-
optsCachePtr = cache
optsPtr = UnsafeMutablePointer<mp_vo_opts>(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<macos_opts>(OpaquePointer(macCache.pointee.opts))
}
diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m
index 73503ad66c..1a1c6aefc0 100644
--- a/osdep/macosx_application.m
+++ b/osdep/macosx_application.m
@@ -190,12 +190,12 @@ static const char macosx_icon[] =
#endif
}
-- (const struct m_sub_options *)getMacOSConf
++ (const struct m_sub_options *)getMacOSConf
{
return &macos_conf;
}
-- (const struct m_sub_options *)getVoSubConf
++ (const struct m_sub_options *)getVoSubConf
{
return &vo_sub_opts;
}
diff --git a/osdep/macosx_application_objc.h b/osdep/macosx_application_objc.h
index 11959a83ea..fab968dba8 100644
--- a/osdep/macosx_application_objc.h
+++ b/osdep/macosx_application_objc.h
@@ -31,8 +31,8 @@ struct mpv_handle;
- (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;
++ (const struct m_sub_options *)getMacOSConf;
++ (const struct m_sub_options *)getVoSubConf;
@property(nonatomic, retain) MenuBar *menuBar;
@property(nonatomic, assign) size_t openCount;