diff options
author | Johns <johns98@gmx.net> | 2013-01-05 20:44:54 +0100 |
---|---|---|
committer | Johns <johns98@gmx.net> | 2013-01-05 20:44:54 +0100 |
commit | fa09d940c57174c033ea4f65f61d32dda4e834bd (patch) | |
tree | a08d9c8c5fc48cc3aa9bba178157ea2e81a6acc8 | |
parent | d4702b9a9ec1774f546e91958f0752c0c45a632c (diff) | |
download | vdr-plugin-softhddevice-fa09d940c57174c033ea4f65f61d32dda4e834bd.tar.gz vdr-plugin-softhddevice-fa09d940c57174c033ea4f65f61d32dda4e834bd.tar.bz2 |
Fix PIP threading problems.
-rw-r--r-- | softhddev.c | 19 | ||||
-rw-r--r-- | video.c | 15 |
2 files changed, 27 insertions, 7 deletions
diff --git a/softhddev.c b/softhddev.c index 102be69..fd51917 100644 --- a/softhddev.c +++ b/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; @@ -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(); } } |