mirror of
				https://projects.vdr-developer.org/git/vdr-plugin-softhddevice.git
				synced 2023-10-10 17:16:51 +00:00 
			
		
		
		
	Fix PIP threading problems.
This commit is contained in:
		
							
								
								
									
										19
									
								
								softhddev.c
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								softhddev.c
									
									
									
									
									
								
							@@ -1518,6 +1518,11 @@ static void FixPacketForFFMpeg(VideoDecoder * vdecoder, AVPacket * avpkt)
 | 
			
		||||
*/
 | 
			
		||||
int VideoPollInput(VideoStream * stream)
 | 
			
		||||
{
 | 
			
		||||
    if (!stream->Decoder) {		// closing
 | 
			
		||||
	fprintf(stderr, "no decoder\n");
 | 
			
		||||
	return -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (stream->ClearBuffers) {
 | 
			
		||||
	atomic_set(&stream->PacketsFilled, 0);
 | 
			
		||||
	stream->PacketRead = stream->PacketWrite;
 | 
			
		||||
@@ -1549,6 +1554,11 @@ int VideoDecodeInput(VideoStream * stream)
 | 
			
		||||
    AVPacket *avpkt;
 | 
			
		||||
    int saved_size;
 | 
			
		||||
 | 
			
		||||
    if (!stream->Decoder) {		// closing
 | 
			
		||||
	fprintf(stderr, "no decoder\n");
 | 
			
		||||
	return -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (stream->ClearBuffers) {		// clear buffer request
 | 
			
		||||
	atomic_set(&stream->PacketsFilled, 0);
 | 
			
		||||
	stream->PacketRead = stream->PacketWrite;
 | 
			
		||||
@@ -2987,16 +2997,17 @@ void PipStop(void)
 | 
			
		||||
	return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (PipVideoStream->HwDecoder) {
 | 
			
		||||
	VideoDelHwDecoder(PipVideoStream->HwDecoder);
 | 
			
		||||
	PipVideoStream->HwDecoder = NULL;
 | 
			
		||||
	// FIXME: does CodecVideoClose call hw decoder?
 | 
			
		||||
    }
 | 
			
		||||
    if (PipVideoStream->Decoder) {
 | 
			
		||||
	PipVideoStream->SkipStream = 1;
 | 
			
		||||
	CodecVideoClose(PipVideoStream->Decoder);
 | 
			
		||||
	CodecVideoDelDecoder(PipVideoStream->Decoder);
 | 
			
		||||
	PipVideoStream->Decoder = NULL;
 | 
			
		||||
    }
 | 
			
		||||
    if (PipVideoStream->HwDecoder) {
 | 
			
		||||
	VideoDelHwDecoder(PipVideoStream->HwDecoder);
 | 
			
		||||
	PipVideoStream->HwDecoder = NULL;
 | 
			
		||||
    }
 | 
			
		||||
    VideoPacketExit(PipVideoStream);
 | 
			
		||||
 | 
			
		||||
    PipVideoStream->NewStream = 1;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										15
									
								
								video.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								video.c
									
									
									
									
									
								
							@@ -8231,6 +8231,7 @@ static void VdpauSyncRenderFrame(VdpauDecoder * decoder,
 | 
			
		||||
    while (atomic_read(&decoder->SurfacesFilled) >= VIDEO_SURFACES_MAX) {
 | 
			
		||||
	struct timespec abstime;
 | 
			
		||||
 | 
			
		||||
	fprintf(stderr, "video/vdpau: must be removed\n");
 | 
			
		||||
	pthread_mutex_unlock(&VideoLockMutex);
 | 
			
		||||
 | 
			
		||||
	abstime = decoder->FrameTime;
 | 
			
		||||
@@ -8378,6 +8379,7 @@ static void VdpauDisplayHandlerThread(void)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    decoded = 0;
 | 
			
		||||
    pthread_mutex_lock(&VideoLockMutex);
 | 
			
		||||
    for (i = 0; i < VdpauDecoderN; ++i) {
 | 
			
		||||
	int filled;
 | 
			
		||||
 | 
			
		||||
@@ -8389,10 +8391,8 @@ static void VdpauDisplayHandlerThread(void)
 | 
			
		||||
	filled = atomic_read(&decoder->SurfacesFilled);
 | 
			
		||||
	if (filled < VIDEO_SURFACES_MAX) {
 | 
			
		||||
	    // FIXME: hot polling
 | 
			
		||||
	    pthread_mutex_lock(&VideoLockMutex);
 | 
			
		||||
	    // fetch+decode or reopen
 | 
			
		||||
	    err = VideoDecodeInput(decoder->Stream);
 | 
			
		||||
	    pthread_mutex_unlock(&VideoLockMutex);
 | 
			
		||||
	} else {
 | 
			
		||||
	    err = VideoPollInput(decoder->Stream);
 | 
			
		||||
	}
 | 
			
		||||
@@ -8409,6 +8409,7 @@ static void VdpauDisplayHandlerThread(void)
 | 
			
		||||
	}
 | 
			
		||||
	decoded = 1;
 | 
			
		||||
    }
 | 
			
		||||
    pthread_mutex_unlock(&VideoLockMutex);
 | 
			
		||||
 | 
			
		||||
    if (!decoded) {			// nothing decoded, sleep
 | 
			
		||||
	// FIXME: sleep on wakeup
 | 
			
		||||
@@ -9459,7 +9460,13 @@ struct _video_hw_decoder_
 | 
			
		||||
///
 | 
			
		||||
VideoHwDecoder *VideoNewHwDecoder(VideoStream * stream)
 | 
			
		||||
{
 | 
			
		||||
    return VideoUsedModule->NewHwDecoder(stream);
 | 
			
		||||
    VideoHwDecoder *hw;
 | 
			
		||||
 | 
			
		||||
    VideoThreadLock();
 | 
			
		||||
    hw = VideoUsedModule->NewHwDecoder(stream);
 | 
			
		||||
    VideoThreadUnlock();
 | 
			
		||||
 | 
			
		||||
    return hw;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
@@ -9470,7 +9477,9 @@ VideoHwDecoder *VideoNewHwDecoder(VideoStream * stream)
 | 
			
		||||
void VideoDelHwDecoder(VideoHwDecoder * hw_decoder)
 | 
			
		||||
{
 | 
			
		||||
    if (hw_decoder) {
 | 
			
		||||
	VideoThreadLock();
 | 
			
		||||
	VideoUsedModule->DelHwDecoder(hw_decoder);
 | 
			
		||||
	VideoThreadUnlock();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user