]> git.sesse.net Git - vlc/blobdiff - modules/access/qtcapture.m
Usefull coment instead of "Gruik" (evenif I like the previous one...)
[vlc] / modules / access / qtcapture.m
index fba2fbe7afa09c073eaf8663399e5ca2f3c22180..eac2e6f005426e7a80997989869887cfea21307a 100644 (file)
@@ -38,6 +38,7 @@
 #include <vlc_interface.h>
 
 #import <QTKit/QTKit.h>
+#import <CoreAudio/CoreAudio.h>
 
 /*****************************************************************************
 * Local prototypes
@@ -109,7 +110,11 @@ vlc_module_end();
     {
         imageBufferToRelease = currentImageBuffer;
         currentImageBuffer = videoFrame;
-        currentPts = 1000000L / [sampleBuffer presentationTime].timeScale * [sampleBuffer presentationTime].timeValue;
+        currentPts = (mtime_t)(1000000L / [sampleBuffer presentationTime].timeScale * [sampleBuffer presentationTime].timeValue);
+        
+        /* Try to use hosttime of the sample if available, because iSight Pts seems broken */
+        NSNumber *hosttime = (NSNumber *)[sampleBuffer attributeForKey:QTSampleBufferHostTimeAttribute];
+        if( hosttime ) currentPts = (mtime_t)AudioConvertHostTimeToNanos([hosttime unsignedLongLongValue])/1000;
     }
     CVBufferRelease(imageBufferToRelease);
 }
@@ -317,10 +322,15 @@ static void Close( vlc_object_t *p_this )
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys = p_demux->p_sys;
 
-    [p_sys->session stopRunning];
-    [p_sys->output release];
-    [p_sys->session release];
-    [p_sys->device release];
+    /* Hack: if libvlc was killed, main interface thread was,
+     * and poor QTKit needs it, so don't tell him.
+     * Else we dead lock. */
+    if( vlc_object_alive(p_this->p_libvlc))
+    {
+        [p_sys->session stopRunning];
+        [p_sys->output release];
+        [p_sys->session release];
+    }
     free( p_sys );
 
     [pool release];