1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

cDevice::PlayTs() now plays as many TS packets as possible in one call

This commit is contained in:
Klaus Schmidinger 2009-04-05 12:29:27 +02:00
parent 43d25f07de
commit 371a9a9025
4 changed files with 62 additions and 57 deletions

View File

@ -6020,3 +6020,4 @@ Video Disk Recorder Revision History
- Fixed a crash when jumping to an editing mark in an audio recording. - Fixed a crash when jumping to an editing mark in an audio recording.
- Fixed the 'VideoOnly' condition in the PlayPes() and PlayTs() calls in - Fixed the 'VideoOnly' condition in the PlayPes() and PlayTs() calls in
cDvbPlayer::Action() (thanks to Reinhard Nissl). cDvbPlayer::Action() (thanks to Reinhard Nissl).
- cDevice::PlayTs() now plays as many TS packets as possible in one call.

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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" #include "device.h"
@ -1315,43 +1315,54 @@ int cDevice::PlayTsSubtitle(const uchar *Data, int Length)
//TODO detect and report continuity errors? //TODO detect and report continuity errors?
int cDevice::PlayTs(const uchar *Data, int Length, bool VideoOnly) int cDevice::PlayTs(const uchar *Data, int Length, bool VideoOnly)
{ {
if (Length == TS_SIZE) { int Played = 0;
if (!TsHasPayload(Data)) if (Data == NULL) {
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) {
patPmtParser.Reset(); patPmtParser.Reset();
tsToPesVideo.Reset(); tsToPesVideo.Reset();
tsToPesAudio.Reset(); tsToPesAudio.Reset();
tsToPesSubtitle.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 int cDevice::Priority(void) const

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: device.h 2.8 2009/03/28 21:53:26 kls Exp $ * $Id: device.h 2.9 2009/04/05 12:12:44 kls Exp $
*/ */
#ifndef __DEVICE_H #ifndef __DEVICE_H
@ -619,9 +619,9 @@ public:
///< must be sent to the base class function. This applies especially ///< must be sent to the base class function. This applies especially
///< to the PAT/PMT packets. ///< to the PAT/PMT packets.
///< Returns -1 in case of error, otherwise the number of actually ///< Returns -1 in case of error, otherwise the number of actually
///< processed bytes is returned, which must be Length. ///< processed bytes is returned.
///< PlayTs() shall process the packet either as a whole (returning ///< PlayTs() shall process the TS packets either as a whole (returning
///< Length) or not at all returning 0 or -1 and setting 'errno' accordingly). ///< n*TS_SIZE) or not at all, returning 0 or -1 and setting 'errno' accordingly).
bool Replaying(void) const; bool Replaying(void) const;
///< Returns true if we are currently replaying. ///< Returns true if we are currently replaying.
bool Transferring(void) const; bool Transferring(void) const;

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: dvbplayer.c 2.9 2009/04/05 10:55:11 kls Exp $ * $Id: dvbplayer.c 2.10 2009/04/05 12:29:27 kls Exp $
*/ */
#include "dvbplayer.h" #include "dvbplayer.h"
@ -527,24 +527,17 @@ void cDvbPlayer::Action(void)
} }
} }
if (p) { if (p) {
//XXX maybe make PlayTs() play as much as possible, until w == 0? would save this extra code here (and the goto)...
while (pc > 0) {
int w; int w;
if (isPesRecording) if (isPesRecording)
w = PlayPes(p, pc, playMode != pmPlay && !(playMode == pmSlow && playDir == pdForward) && DeviceIsPlayingVideo()); w = PlayPes(p, pc, playMode != pmPlay && !(playMode == pmSlow && playDir == pdForward) && DeviceIsPlayingVideo());
else else
w = PlayTs(p, TS_SIZE, playMode != pmPlay && !(playMode == pmSlow && playDir == pdForward) && DeviceIsPlayingVideo()); w = PlayTs(p, pc, playMode != pmPlay && !(playMode == pmSlow && playDir == pdForward) && DeviceIsPlayingVideo());
if (w > 0) { if (w > 0) {
p += w; p += w;
pc -= w; pc -= w;
} }
else if (w == 0) else if (w < 0 && FATALERRNO)
break;
else if (w < 0 && FATALERRNO) {
LOG_ERROR; LOG_ERROR;
goto End;
}
}
} }
if (pc <= 0) { if (pc <= 0) {
if (!eof || (playDir != pdForward && playFrame->Index() > 0) || (playDir == pdForward && playFrame->Index() < readIndex)) if (!eof || (playDir != pdForward && playFrame->Index() > 0) || (playDir == pdForward && playFrame->Index() < readIndex))
@ -589,7 +582,7 @@ void cDvbPlayer::Action(void)
} }
} }
} }
End:
cNonBlockingFileReader *nbfr = nonBlockingFileReader; cNonBlockingFileReader *nbfr = nonBlockingFileReader;
nonBlockingFileReader = NULL; nonBlockingFileReader = NULL;
delete nbfr; delete nbfr;