Browse Source

VLCMediaThumbnailer: use a private VLCLibrary instance with single threaded avcodec decoding

Felix Paul Kühne 12 years ago
parent
commit
85450a77c0
1 changed files with 7 additions and 3 deletions
  1. 7 3
      Sources/VLCMediaThumbnailer.m

+ 7 - 3
Sources/VLCMediaThumbnailer.m

@@ -27,6 +27,9 @@
 
 
 @interface VLCMediaThumbnailer ()
+{
+    VLCLibrary *_privateLibrary;
+}
 - (void)didFetchThumbnail;
 - (void)notifyDelegate;
 - (void)fetchThumbnail;
@@ -93,6 +96,7 @@ void display(void *opaque, void *picture)
     if (_thumbnail)
         CGImageRelease(_thumbnail);
     [_media release];
+    [_privateLibrary release];
     [super dealloc];
 }
 
@@ -114,12 +118,10 @@ void display(void *opaque, void *picture)
     [self startFetchingThumbnail];
 }
 
-
 - (void)startFetchingThumbnail
 {
     NSArray *tracks = [_media tracksInformation];
 
-
     // Find the video track
     NSDictionary *videoTrack = nil;
     for (NSDictionary *track in tracks) {
@@ -163,7 +165,9 @@ void display(void *opaque, void *picture)
     NSAssert(_data, @"Can't create data");
 
     NSAssert(!_mp, @"We are already fetching a thumbnail");
-    _mp = libvlc_media_player_new([VLCLibrary sharedInstance]);
+    if (!_privateLibrary)
+        _privateLibrary = [[VLCLibrary alloc] initWithOptions:[NSArray arrayWithObject:@"--avcodec-threads=1"]];
+    _mp = libvlc_media_player_new([_privateLibrary instance]);
 
     libvlc_media_add_option([_media libVLCMediaDescriptor], "no-audio");