diff options
author | der richter <der.richter@gmx.de> | 2024-02-25 23:59:11 +0100 |
---|---|---|
committer | der richter <der.richter@gmx.de> | 2024-02-27 14:01:38 +0100 |
commit | a7c4a113b82dc57641c08e1da5c3df9acb704be4 (patch) | |
tree | 7c2937343e2345a9050a320c868195c85f5ed437 /osdep/macosx_application.m | |
parent | 3dcc661de7e884e147965615749965df5f80a443 (diff) | |
download | mpv-a7c4a113b82dc57641c08e1da5c3df9acb704be4.tar.bz2 mpv-a7c4a113b82dc57641c08e1da5c3df9acb704be4.tar.xz |
cocoa-cb: remove pre-allocation and initialise only when used
cocoa-cb was always pre-allocated in the Application itself because
libmpv needs to be set up before usage, an opengl context has to be set
and because it was decided mac specific code should be kept out of
libmpv.
this means that a completely working libmpv and opengl renderer was set
up even if it wasn't used. leading to unnecessary log message, resources
being used or reserved on the system that might not be used, triggering
of dedicated GPU unnecessarily and many other things.
even if not optimal, this wasn't the biggest problem since we only had
that one working vo on macOS. though now that we have a vulkan
gpu(-next) backend on macOS that was made the default, we always have
that dangling cocoa-cb instance, which is completely unnecessary.
move the cocoa-cb initialisation into libmpv preinit function and only
init cocoa-cb when we are a standalone App and cocoa-cb support is build
into.
Diffstat (limited to 'osdep/macosx_application.m')
-rw-r--r-- | osdep/macosx_application.m | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m index 1a1c6aefc0..c9ccd48033 100644 --- a/osdep/macosx_application.m +++ b/osdep/macosx_application.m @@ -183,10 +183,12 @@ static const char macosx_icon[] = } } -- (void)setMpvHandle:(struct mpv_handle *)ctx +- (void)initCocoaCb:(struct mpv_handle *)ctx { #if HAVE_MACOS_COCOA_CB - [NSApp setCocoaCB:[[CocoaCB alloc] init:ctx]]; + if (!_cocoa_cb) { + [NSApp setCocoaCB:[[CocoaCB alloc] init:ctx]]; + } #endif } |