From: Claude Date: Mon, 3 Mar 2025 00:00:00 +0000 Subject: [PATCH] osdep/mac: fix app_bridge for non-Swift builds diff --git a/osdep/mac/app_bridge.m b/osdep/mac/app_bridge.m index 58e10cb405..f19c62ff6a 100644 --- a/osdep/mac/app_bridge.m +++ b/osdep/mac/app_bridge.m @@ -17,10 +17,24 @@ #include "config.h" -#import "osdep/mac/app_bridge_objc.h" +#import +#include "options/m_option.h" +#include "options/m_config.h" +#include "osdep/mac/app_bridge.h" +#include "common/common.h" +#include "mpv_talloc.h" #if HAVE_SWIFT +#import "osdep/mac/app_bridge_objc.h" #include "osdep/mac/swift.h" +#else +// For non-Swift builds, we need these declarations +#import +struct input_ctx; +struct mpv_handle; +extern const struct m_sub_options vo_sub_opts; +extern const struct m_sub_options mp_opt_root; +extern int mpv_main(int argc, char *argv[]); #endif #define OPT_BASE_STRUCT struct macos_opts @@ -165,4 +179,27 @@ int cocoa_main(int argc, char *argv[]) { return [(Application *)[Application sharedApplication] main:argc :argv]; } +#else +// Minimal implementation for non-Swift builds +#include "mpv_talloc.h" + +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) {} +void cocoa_init_cocoa_cb(void) {} + +extern int mpv_main(int argc, char *argv[]); + +int cocoa_main(int argc, char *argv[]) +{ + // Initialize autorelease pool + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + // Run mpv_main directly (no threading for simplicity on old systems) + int ret = mpv_main(argc, argv); + + [pool release]; + return ret; +} #endif