Browse Source

player: protect play against calls from the main thread

(cherry picked from commit abe8875413c8c8d72f585ce5af4d334d35b93af0)
Felix Paul Kühne 9 years ago
parent
commit
180b6287a4
1 changed files with 9 additions and 0 deletions
  1. 9 0
      Sources/VLCMediaPlayer.m

+ 9 - 0
Sources/VLCMediaPlayer.m

@@ -1055,6 +1055,15 @@ static void HandleMediaPlayerSnapshot(const libvlc_event_t * event, void * self)
 
 - (void)play
 {
+    if ([NSThread isMainThread]) {
+        /* Hack because we create a dead lock here, when the vout is created
+         * and tries to recontact us on the main thread */
+        /* FIXME: to do this properly we need to do some locking. We may want
+         * to move that to libvlc */
+        [self performSelectorInBackground:@selector(play) withObject:nil];
+        return;
+    }
+
     libvlc_media_player_play(_playerInstance);
 }