summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohns <johns98@gmx.net>2012-04-05 15:47:59 +0200
committerJohns <johns98@gmx.net>2012-04-05 15:47:59 +0200
commitc986d285ea28e824d02ce5253f6e29d3e8da8df3 (patch)
tree0be58ecff4d56dab590c423631cd5d556bc60899
parent8612044b9bf051e0ecd9b900e1f8a3ce1b035483 (diff)
downloadvdr-plugin-softhddevice-c986d285ea28e824d02ce5253f6e29d3e8da8df3.tar.gz
vdr-plugin-softhddevice-c986d285ea28e824d02ce5253f6e29d3e8da8df3.tar.bz2
Buffer less video and audio.
-rw-r--r--ChangeLog2
-rw-r--r--softhddev.c65
-rw-r--r--softhddev.h2
3 files changed, 53 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 2d92071..348dd9d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@ User johns
Date:
Release Version 0.5.0
+ Buffer less video and audio.
+ Fix 100% cpu use, with mp3 plugin.
Audio/Video sync rewrite, trick-speed support moved to video.
Faster VdpauBlackSurface version.
Fix bug: VideoSetPts wrong position for multi frame packets.
diff --git a/softhddev.c b/softhddev.c
index 9d7a49e..c6ad33f 100644
--- a/softhddev.c
+++ b/softhddev.c
@@ -878,13 +878,12 @@ int PlayAudio(const uint8_t * data, int size, uint8_t id)
// channel switch: SetAudioChannelDevice: SetDigitalAudioDevice:
- if (StreamFreezed) { // stream freezed
- return 0;
- }
if (SkipAudio || !MyAudioDecoder) { // skip audio
return size;
}
-
+ if (StreamFreezed) { // stream freezed
+ return 0;
+ }
if (NewAudioStream) {
// this clears the audio ringbuffer indirect, open and setup does it
CodecAudioClose(MyAudioDecoder);
@@ -893,10 +892,14 @@ int PlayAudio(const uint8_t * data, int size, uint8_t id)
AudioChannelID = -1;
NewAudioStream = 0;
}
- // Don't overrun audio buffers on replay
+ // hard limit buffer full: don't overrun audio buffers on replay
if (AudioFreeBytes() < AUDIO_MIN_BUFFER_FREE) {
return 0;
}
+ // soft limit buffer full
+ if (AudioUsedBytes() > AUDIO_MIN_BUFFER_FREE && VideoGetBuffers() > 3) {
+ return 0;
+ }
// PES header 0x00 0x00 0x01 ID
// ID 0xBD 0xC0-0xCF
@@ -1088,17 +1091,12 @@ int PlayTsAudio(const uint8_t * data, int size)
{
static TsDemux tsdx[1];
- if (StreamFreezed) { // stream freezed
- return 0;
- }
if (SkipAudio || !MyAudioDecoder) { // skip audio
return size;
}
- // Don't overrun audio buffers on replay
- if (AudioFreeBytes() < AUDIO_MIN_BUFFER_FREE) {
+ if (StreamFreezed) { // stream freezed
return 0;
}
-
if (NewAudioStream) {
// this clears the audio ringbuffer indirect, open and setup does it
CodecAudioClose(MyAudioDecoder);
@@ -1109,6 +1107,15 @@ int PlayTsAudio(const uint8_t * data, int size)
NewAudioStream = 0;
PesReset(PesDemuxAudio);
}
+ // hard limit buffer full: don't overrun audio buffers on replay
+ if (AudioFreeBytes() < AUDIO_MIN_BUFFER_FREE) {
+ return 0;
+ }
+ // soft limit buffer full
+ if (AudioUsedBytes() > AUDIO_MIN_BUFFER_FREE && VideoGetBuffers() > 3) {
+ return 0;
+ }
+
return TsDemuxer(tsdx, data, size);
}
@@ -1612,10 +1619,6 @@ int PlayVideo(const uint8_t * data, int size)
int z;
int l;
- if (Usr1Signal) { // x11 server ready
- Usr1Signal = 0;
- StartVideo();
- }
if (!MyVideoDecoder) { // no x11 video started
return size;
}
@@ -1660,10 +1663,15 @@ int PlayVideo(const uint8_t * data, int size)
}
return size;
}
- // buffer full: needed for replay
+ // hard limit buffer full: needed for replay
if (atomic_read(&VideoPacketsFilled) >= VIDEO_PACKET_MAX - 3) {
return 0;
}
+ // soft limit buffer full
+ if (atomic_read(&VideoPacketsFilled) > 3
+ && AudioUsedBytes() > AUDIO_MIN_BUFFER_FREE) {
+ return 0;
+ }
// get pts/dts
pts = AV_NOPTS_VALUE;
if (data[7] & 0x80) {
@@ -2069,6 +2077,7 @@ int Poll(int timeout)
// poll is only called during replay, flush buffers after replay
VideoClearClose = 1;
for (;;) {
+#if 0
int empty;
int t;
@@ -2078,6 +2087,18 @@ int Poll(int timeout)
if (empty || !timeout) {
return empty;
}
+#else
+ int full;
+ int t;
+
+ // one buffer is full
+ full = AudioFreeBytes() >= AUDIO_MIN_BUFFER_FREE
+ || atomic_read(&VideoPacketsFilled) < VIDEO_PACKET_MAX - 3;
+
+ if (!full || !timeout) {
+ return !full;
+ }
+#endif
t = 15;
if (timeout < t) {
t = timeout;
@@ -2462,10 +2483,22 @@ void Stop(void)
}
/**
+** Perform any cleanup or other regular tasks.
+*/
+void Housekeeping(void)
+{
+}
+
+/**
** Main thread hook, periodic called from main thread.
*/
void MainThreadHook(void)
{
+ if (Usr1Signal) { // x11 server ready
+ Usr1Signal = 0;
+ StartVideo();
+ VideoDisplayWakeup();
+ }
}
//////////////////////////////////////////////////////////////////////////////
diff --git a/softhddev.h b/softhddev.h
index 78862d6..77181c7 100644
--- a/softhddev.h
+++ b/softhddev.h
@@ -81,6 +81,8 @@ extern "C"
extern int Start(void);
/// C plugin stop code
extern void Stop(void);
+ /// C plugin house keeping
+ extern void Housekeeping(void);
/// C plugin main thread hook
extern void MainThreadHook(void);