summaryrefslogtreecommitdiff
path: root/device.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2009-04-05 12:29:27 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2009-04-05 12:29:27 +0200
commit371a9a90250463bb1b5aeece709c444a836269aa (patch)
treef9c51176ee390ef54f99e691df59d8037da753ec /device.c
parent43d25f07de0c9a6feedaa331c82f923beb379fcf (diff)
downloadvdr-371a9a90250463bb1b5aeece709c444a836269aa.tar.gz
vdr-371a9a90250463bb1b5aeece709c444a836269aa.tar.bz2
cDevice::PlayTs() now plays as many TS packets as possible in one call
Diffstat (limited to 'device.c')
-rw-r--r--device.c77
1 files changed, 44 insertions, 33 deletions
diff --git a/device.c b/device.c
index 4a20fd74..ccf176c4 100644
--- a/device.c
+++ b/device.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: device.c 2.12 2009/01/30 16:01:53 kls Exp $
+ * $Id: device.c 2.13 2009/04/05 12:15:41 kls Exp $
*/
#include "device.h"
@@ -1315,43 +1315,54 @@ int cDevice::PlayTsSubtitle(const uchar *Data, int Length)
//TODO detect and report continuity errors?
int cDevice::PlayTs(const uchar *Data, int Length, bool VideoOnly)
{
- if (Length == TS_SIZE) {
- if (!TsHasPayload(Data))
- return Length; // silently ignore TS packets w/o payload
- int PayloadOffset = TsPayloadOffset(Data);
- if (PayloadOffset < Length) {
- cMutexLock MutexLock(&mutexCurrentAudioTrack);
- int Pid = TsPid(Data);
- if (Pid == 0)
- patPmtParser.ParsePat(Data, Length);
- else if (Pid == patPmtParser.PmtPid())
- patPmtParser.ParsePmt(Data, Length);
- else if (Pid == patPmtParser.Vpid()) {
- isPlayingVideo = true;
- return PlayTsVideo(Data, Length);
- }
- else if (Pid == availableTracks[currentAudioTrack].id) {
- if (!VideoOnly || HasIBPTrickSpeed()) {
- int w = PlayTsAudio(Data, Length);
- if (w > 0)
- Audios.PlayTsAudio(Data, Length);
- return w;
- }
- }
- else if (Pid == availableTracks[currentSubtitleTrack].id) {
- if (!VideoOnly || HasIBPTrickSpeed())
- return PlayTsSubtitle(Data, Length);
- }
- return Length;
- }
- }
- else if (Data == NULL) {
+ int Played = 0;
+ if (Data == NULL) {
patPmtParser.Reset();
tsToPesVideo.Reset();
tsToPesAudio.Reset();
tsToPesSubtitle.Reset();
}
- return -1;
+ else {
+ cMutexLock MutexLock(&mutexCurrentAudioTrack);
+ while (Length >= TS_SIZE) {
+ if (TsHasPayload(Data)) { // silently ignore TS packets w/o payload
+ int PayloadOffset = TsPayloadOffset(Data);
+ if (PayloadOffset < TS_SIZE) {
+ int Pid = TsPid(Data);
+ if (Pid == 0)
+ patPmtParser.ParsePat(Data, TS_SIZE);
+ else if (Pid == patPmtParser.PmtPid())
+ patPmtParser.ParsePmt(Data, TS_SIZE);
+ else if (Pid == patPmtParser.Vpid()) {
+ isPlayingVideo = true;
+ int w = PlayTsVideo(Data, TS_SIZE);
+ if (w < 0)
+ return Played ? Played : w;
+ if (w == 0)
+ break;
+ }
+ else if (Pid == availableTracks[currentAudioTrack].id) {
+ if (!VideoOnly || HasIBPTrickSpeed()) {
+ int w = PlayTsAudio(Data, TS_SIZE);
+ if (w < 0)
+ return Played ? Played : w;
+ if (w == 0)
+ break;
+ Audios.PlayTsAudio(Data, TS_SIZE);
+ }
+ }
+ else if (Pid == availableTracks[currentSubtitleTrack].id) {
+ if (!VideoOnly || HasIBPTrickSpeed())
+ PlayTsSubtitle(Data, TS_SIZE);
+ }
+ }
+ }
+ Played += TS_SIZE;
+ Length -= TS_SIZE;
+ Data += TS_SIZE;
+ }
+ }
+ return Played;
}
int cDevice::Priority(void) const