Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mac: fix libmpv usage without embedding #12947

Merged
merged 2 commits into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions osdep/macos/libmpv_helper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 3 additions & 12 deletions osdep/macos/mpv_helper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
1 change: 0 additions & 1 deletion osdep/macosx_application.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ enum {
};

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;
Expand Down
4 changes: 2 additions & 2 deletions osdep/macosx_application.m
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ - (void)setMpvHandle:(struct mpv_handle *)ctx
#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;
}
Expand Down
4 changes: 2 additions & 2 deletions osdep/macosx_application_objc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 1 addition & 7 deletions video/out/mac/title_bar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,6 @@ class TitleBar: NSVisualEffectView {
default:
return nil
}


let style = UserDefaults.standard.string(forKey: "AppleInterfaceStyle")
return appearanceFrom(string: style == nil ? "aqua" : "vibrantDark")
}

func materialFrom(string: String) -> NSVisualEffectView.Material {
Expand All @@ -221,9 +217,7 @@ class TitleBar: NSVisualEffectView {
case "15", "light": return .light
case "16", "mediumLight": return .mediumLight
case "17", "ultraDark": return .ultraDark
default: break
default: return .titlebar
}

return .titlebar
}
}