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.
This commit is contained in:
wm4 2017-04-19 12:35:42 +02:00
parent e335e33239
commit dcb5800357
1 changed files with 11 additions and 8 deletions

View File

@ -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;
}
}