Browse Source

Media List Player: prevent deadlocks when blocking or waiting on the main thread

(cherry picked from commit ec989599abf96a428861b5aab98c09c62f82b14e)
Felix Paul Kühne 9 years ago
parent
commit
a862067755
2 changed files with 16 additions and 1 deletions
  1. 16 0
      Sources/VLCMediaListPlayer.m
  2. 0 1
      Sources/VLCMediaPlayer.m

+ 16 - 0
Sources/VLCMediaListPlayer.m

@@ -115,21 +115,37 @@
 
 - (void)playMedia:(VLCMedia *)media
 {
+    if ([NSThread isMainThread]) {
+        [self performSelectorInBackground:@selector(playMedia:) withObject:media];
+        return;
+    }
     libvlc_media_list_player_play_item(instance, [media libVLCMediaDescriptor]);
 }
 
 - (void)play
 {
+    if ([NSThread isMainThread]) {
+        [self performSelectorInBackground:@selector(play) withObject:nil];
+        return;
+    }
     libvlc_media_list_player_play(instance);
 }
 
 - (void)pause
 {
+    if ([NSThread isMainThread]) {
+        [self performSelectorInBackground:@selector(pause) withObject:nil];
+        return;
+    }
     libvlc_media_list_player_pause(instance);
 }
 
 - (void)stop
 {
+    if ([NSThread isMainThread]) {
+        [self performSelectorInBackground:@selector(stop) withObject:nil];
+        return;
+    }
     libvlc_media_list_player_stop(instance);
 }
 

+ 0 - 1
Sources/VLCMediaPlayer.m

@@ -1091,7 +1091,6 @@ static void HandleMediaPlayerSnapshot(const libvlc_event_t * event, void * self)
 - (void)gotoNextFrame
 {
     libvlc_media_player_next_frame(_playerInstance);
-
 }
 
 - (void)fastForward