mirror of https://github.com/mpv-player/mpv
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
This commit is contained in:
parent
5aac4c1aee
commit
3f2bc2e535
|
@ -34,10 +34,8 @@ class LibmpvHelper {
|
||||||
mpvHandle = mpv
|
mpvHandle = mpv
|
||||||
log = LogHelper(mpLog)
|
log = LogHelper(mpLog)
|
||||||
|
|
||||||
guard let app = NSApp as? Application,
|
let global = mp_client_get_global(mpvHandle)
|
||||||
let ptr = mp_get_config_group(nil,
|
guard let ptr = mp_get_config_group(nil, global, Application.getMacOSConf()) else
|
||||||
mp_client_get_global(mpvHandle),
|
|
||||||
app.getMacOSConf()) else
|
|
||||||
{
|
{
|
||||||
log.sendError("macOS config group couldn't be retrieved'")
|
log.sendError("macOS config group couldn't be retrieved'")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
|
@ -42,23 +42,14 @@ class MPVHelper {
|
||||||
self.vo = vo
|
self.vo = vo
|
||||||
self.log = log
|
self.log = log
|
||||||
|
|
||||||
guard let app = NSApp as? Application,
|
guard let cache = m_config_cache_alloc(vo, vo.pointee.global, Application.getVoSubConf()),
|
||||||
let cache = m_config_cache_alloc(vo, vo.pointee.global, app.getVoSubConf()) else
|
let macCache = m_config_cache_alloc(vo, vo.pointee.global, Application.getMacOSConf()) else
|
||||||
{
|
|
||||||
log.sendError("NSApp couldn't be retrieved")
|
|
||||||
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
|
// will never be hit, mp_get_config_group asserts for invalid groups
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
|
optsCachePtr = cache
|
||||||
|
optsPtr = UnsafeMutablePointer<mp_vo_opts>(OpaquePointer(cache.pointee.opts))
|
||||||
macOptsCachePtr = macCache
|
macOptsCachePtr = macCache
|
||||||
macOptsPtr = UnsafeMutablePointer<macos_opts>(OpaquePointer(macCache.pointee.opts))
|
macOptsPtr = UnsafeMutablePointer<macos_opts>(OpaquePointer(macCache.pointee.opts))
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,12 +190,12 @@ static const char macosx_icon[] =
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
- (const struct m_sub_options *)getMacOSConf
|
+ (const struct m_sub_options *)getMacOSConf
|
||||||
{
|
{
|
||||||
return &macos_conf;
|
return &macos_conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (const struct m_sub_options *)getVoSubConf
|
+ (const struct m_sub_options *)getVoSubConf
|
||||||
{
|
{
|
||||||
return &vo_sub_opts;
|
return &vo_sub_opts;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,8 @@ struct mpv_handle;
|
||||||
- (void)stopMPV:(char *)cmd;
|
- (void)stopMPV:(char *)cmd;
|
||||||
- (void)openFiles:(NSArray *)filenames;
|
- (void)openFiles:(NSArray *)filenames;
|
||||||
- (void)setMpvHandle:(struct mpv_handle *)ctx;
|
- (void)setMpvHandle:(struct mpv_handle *)ctx;
|
||||||
- (const struct m_sub_options *)getMacOSConf;
|
+ (const struct m_sub_options *)getMacOSConf;
|
||||||
- (const struct m_sub_options *)getVoSubConf;
|
+ (const struct m_sub_options *)getVoSubConf;
|
||||||
|
|
||||||
@property(nonatomic, retain) MenuBar *menuBar;
|
@property(nonatomic, retain) MenuBar *menuBar;
|
||||||
@property(nonatomic, assign) size_t openCount;
|
@property(nonatomic, assign) size_t openCount;
|
||||||
|
|
Loading…
Reference in New Issue