Commit 06e5daea authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

Don't send blocks from qtcapture Demux that we have already sent before. Avoid...

Don't send blocks from qtcapture Demux that we have already sent before. Avoid excessive CPU usage while there are no new blocks.
parent c375cdfc
...@@ -68,6 +68,7 @@ vlc_module_end(); ...@@ -68,6 +68,7 @@ vlc_module_end();
{ {
CVImageBufferRef currentImageBuffer; CVImageBufferRef currentImageBuffer;
mtime_t currentPts; mtime_t currentPts;
mtime_t previousPts;
} }
- (id)init; - (id)init;
- (void)outputVideoFrame:(CVImageBufferRef)videoFrame withSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection; - (void)outputVideoFrame:(CVImageBufferRef)videoFrame withSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection;
...@@ -82,6 +83,7 @@ vlc_module_end(); ...@@ -82,6 +83,7 @@ vlc_module_end();
{ {
currentImageBuffer = nil; currentImageBuffer = nil;
currentPts = 0; currentPts = 0;
previousPts = 0;
} }
return self; return self;
} }
...@@ -117,13 +119,13 @@ vlc_module_end(); ...@@ -117,13 +119,13 @@ vlc_module_end();
CVImageBufferRef imageBuffer; CVImageBufferRef imageBuffer;
mtime_t pts; mtime_t pts;
if(!currentImageBuffer) if(!currentImageBuffer || currentPts == previousPts )
return 0; return 0;
@synchronized (self) @synchronized (self)
{ {
imageBuffer = CVBufferRetain(currentImageBuffer); imageBuffer = CVBufferRetain(currentImageBuffer);
pts = currentPts; pts = previousPts = currentPts;
CVPixelBufferLockBaseAddress(imageBuffer, 0); CVPixelBufferLockBaseAddress(imageBuffer, 0);
void * pixels = CVPixelBufferGetBaseAddress(imageBuffer); void * pixels = CVPixelBufferGetBaseAddress(imageBuffer);
...@@ -353,6 +355,7 @@ static int Demux( demux_t *p_demux ) ...@@ -353,6 +355,7 @@ static int Demux( demux_t *p_demux )
/* Nothing to display yet, just forget */ /* Nothing to display yet, just forget */
block_Release( p_block ); block_Release( p_block );
[pool release]; [pool release];
msleep( 10000 );
return 1; return 1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment