Poll input buffers, if display buffers are full.

This commit is contained in:
Johns 2012-05-13 18:33:24 +02:00
parent 43e70b6a3f
commit 752ee356fa
3 changed files with 38 additions and 7 deletions

View File

@ -397,7 +397,7 @@ static inline int FastAdtsCheck(const uint8_t * p)
/// o B*1 MPEG Version: 0 for MPEG-4, 1 for MPEG-2
/// o C*2 layer: always 0
/// o ..
/// o F*4 sampling frequency index (15 is invalid)
/// o F*4 sampling frequency index (15 is invalid)
/// o ..
/// o M*13 frame length
///
@ -655,6 +655,12 @@ static void PesParse(PesDemux * pesdx, const uint8_t * data, int size,
//pesdx->State = PES_MPEG_DECODE;
break;
}
if (AudioCodecID != CODEC_ID_NONE) {
// shouldn't happen after we have a vaild codec
// detected
Debug(4, "pesdemux: skip @%d %02x\n", pesdx->Skip,
q[0]);
}
// try next byte
++pesdx->Skip;
++q;
@ -1093,6 +1099,7 @@ int PlayAudio(const uint8_t * data, int size, uint8_t id)
// 4 bytes 0xFFExxxxx Mpeg audio
// 3 bytes 0x56Exxx AAC LATM audio
// 5 bytes 0x0B77xxxxxx AC3 audio
// 7/9 bytes 0xFFFxxxxxxxxxxx ADTS audio
// PCM audio can't be found
r = 0;
codec_id = CODEC_ID_NONE; // keep compiler happy
@ -1427,6 +1434,26 @@ void FixPacketForFFMpeg(VideoDecoder * MyVideoDecoder, AVPacket * avpkt)
CodecVideoDecode(MyVideoDecoder, tmp);
}
/**
** Poll PES packet ringbuffer.
**
** Called if video frame buffers are full.
*/
int VideoPollInput(void)
{
if (VideoClearBuffers) {
atomic_set(&VideoPacketsFilled, 0);
VideoPacketRead = VideoPacketWrite;
if (MyVideoDecoder) {
CodecVideoFlushBuffers(MyVideoDecoder);
VideoResetStart(MyHwDecoder);
}
VideoClearBuffers = 0;
return 1;
}
return 0;
}
/**
** Decode from PES packet ringbuffer.
**
@ -1434,7 +1461,7 @@ void FixPacketForFFMpeg(VideoDecoder * MyVideoDecoder, AVPacket * avpkt)
** @retval 1 stream paused
** @retval -1 empty stream
*/
int VideoDecode(void)
int VideoDecodeInput(void)
{
int filled;
AVPacket *avpkt;

10
video.c
View File

@ -4677,8 +4677,10 @@ static void VaapiDisplayHandlerThread(void)
// FIXME: hot polling
pthread_mutex_lock(&VideoLockMutex);
// fetch+decode or reopen
err = VideoDecode();
err = VideoDecodeInput();
pthread_mutex_unlock(&VideoLockMutex);
} else {
err = VideoPollInput();
}
if (err) {
// FIXME: sleep on wakeup
@ -8085,8 +8087,10 @@ static void VdpauDisplayHandlerThread(void)
// FIXME: hot polling
pthread_mutex_lock(&VideoLockMutex);
// fetch+decode or reopen
err = VideoDecode();
err = VideoDecodeInput();
pthread_mutex_unlock(&VideoLockMutex);
} else {
err = VideoPollInput();
}
if (err) {
// FIXME: sleep on wakeup
@ -10296,7 +10300,7 @@ void FeedKeyPress( __attribute__ ((unused))
{
}
int VideoDecode(void)
int VideoDecodeInput(void)
{
return -1;
}

View File

@ -177,8 +177,8 @@ extern void VideoOsdExit(void); ///< Cleanup osd.
extern void VideoInit(const char *); ///< Setup video module.
extern void VideoExit(void); ///< Cleanup and exit video module.
extern void VideoFlushInput(void); ///< Flush video input buffers.
extern int VideoDecode(void); ///< Decode video input buffers.
extern int VideoPollInput(void); ///< Poll video input buffers.
extern int VideoDecodeInput(void); ///< Decode video input buffers.
extern int VideoGetBuffers(void); ///< Get number of input buffers.
/// @}