aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2017-04-19 12:35:42 +0200
committerGravatar wm4 <wm4@nowhere>2017-04-19 12:55:44 +0200
commitdcb580035786fdebe58c5146941bc9700cab842b (patch)
treeea2e819bc70d16d0b6534be413de3bde66ca6386
parente335e3323932ca7e27ffbe99e7dc2447a83ba857 (diff)
osx: fix deadlock on exit with libmpv on OSX
There is explicit code to handle the libmpv case, but it expects that a dispatch queue is running. This is not necessarily the case. E.g. edit the simple.c mpv example not to do any playback and to destroy the mpv handle immediately. It will freeze on exit, because nothing will release the mpv_handle. I'm not sure how this should be fixed, so disable it for now in library mode.
-rw-r--r--osdep/macosx_events.m19
1 files changed, 11 insertions, 8 deletions
diff --git a/osdep/macosx_events.m b/osdep/macosx_events.m
index fc7118de4c..dbdef2f255 100644
--- a/osdep/macosx_events.m
+++ b/osdep/macosx_events.m
@@ -53,7 +53,7 @@
- (BOOL)handleMediaKey:(NSEvent *)event;
- (NSEvent *)handleKey:(NSEvent *)event;
-- (void)setMpvHandle:(struct mpv_handle *)ctx;
+- (BOOL)setMpvHandle:(struct mpv_handle *)ctx;
- (void)readEvents;
- (void)startAppleRemote;
- (void)stopAppleRemote;
@@ -217,11 +217,12 @@ static void wakeup(void *context)
void cocoa_set_mpv_handle(struct mpv_handle *ctx)
{
- [[EventsResponder sharedInstance] setMpvHandle:ctx];
- mpv_observe_property(ctx, 0, "duration", MPV_FORMAT_DOUBLE);
- mpv_observe_property(ctx, 0, "time-pos", MPV_FORMAT_DOUBLE);
- mpv_observe_property(ctx, 0, "pause", MPV_FORMAT_FLAG);
- mpv_set_wakeup_callback(ctx, wakeup, NULL);
+ if ([[EventsResponder sharedInstance] setMpvHandle:ctx]) {
+ mpv_observe_property(ctx, 0, "duration", MPV_FORMAT_DOUBLE);
+ mpv_observe_property(ctx, 0, "time-pos", MPV_FORMAT_DOUBLE);
+ mpv_observe_property(ctx, 0, "pause", MPV_FORMAT_FLAG);
+ mpv_set_wakeup_callback(ctx, wakeup, NULL);
+ }
}
@implementation EventsResponder
@@ -305,12 +306,14 @@ void cocoa_set_mpv_handle(struct mpv_handle *ctx)
_is_application = isApplication;
}
-- (void)setMpvHandle:(struct mpv_handle *)ctx
+- (BOOL)setMpvHandle:(struct mpv_handle *)ctx
{
if (_is_application) {
dispatch_sync(dispatch_get_main_queue(), ^{ _ctx = ctx; });
+ return YES;
} else {
- _ctx = ctx;
+ mpv_detach_destroy(ctx);
+ return NO;
}
}