summaryrefslogtreecommitdiff
path: root/device.c
diff options
context:
space:
mode:
Diffstat (limited to 'device.c')
-rw-r--r--device.c82
1 files changed, 47 insertions, 35 deletions
diff --git a/device.c b/device.c
index 1f806e0..ccf176c 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.11 2009/01/25 11:10:56 kls Exp $
+ * $Id: device.c 2.13 2009/04/05 12:15:41 kls Exp $
*/
#include "device.h"
@@ -1304,8 +1304,9 @@ int cDevice::PlayTsSubtitle(const uchar *Data, int Length)
if (!dvbSubtitleConverter)
dvbSubtitleConverter = new cDvbSubtitleConverter;
tsToPesSubtitle.PutTs(Data, Length);
- if (const uchar *p = tsToPesSubtitle.GetPes(Length)) {
- dvbSubtitleConverter->Convert(p, Length);
+ int l;
+ if (const uchar *p = tsToPesSubtitle.GetPes(l)) {
+ dvbSubtitleConverter->Convert(p, l);
tsToPesSubtitle.Reset();
}
return Length;
@@ -1314,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