From patchwork Sun Jan 25 22:53:38 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Udo Richter X-Patchwork-Id: 12700 Received: from mail.gmx.net ([213.165.64.20]) by www.linuxtv.org with smtp (Exim 4.63) (envelope-from ) id 1LRDsT-0003qa-5D for vdr@linuxtv.org; Sun, 25 Jan 2009 23:54:54 +0100 Received: (qmail invoked by alias); 25 Jan 2009 22:54:19 -0000 Received: from Wbf96.w.pppool.de (EHLO localhost) [89.58.191.150] by mail.gmx.net (mp028) with SMTP; 25 Jan 2009 23:54:19 +0100 X-Authenticated: #1417946 X-Provags-ID: V01U2FsdGVkX1+Ee4Q3dvqE3wp43mA8weAD9P82rAJoG3xS5cugUs uxybMl3nL3snjH Message-ID: <497CED72.8050006@gmx.de> Date: Sun, 25 Jan 2009 23:53:38 +0100 From: Udo Richter User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1b3pre) Gecko/20081204 Thunderbird/3.0b1 MIME-Version: 1.0 To: VDR Mailing List X-Y-GMX-Trusted: 0 X-FuHaFi: 0.68 X-LSpam-Score: -2.5 (--) X-LSpam-Report: No, score=-2.5 required=5.0 tests=AWL=0.136, BAYES_00=-2.599 autolearn=ham Subject: [vdr] [PATCH] Working PlayTsXXX to PlayXXX wrapper X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.9 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Jan 2009 22:54:54 -0000 Status: O X-Status: X-Keywords: X-UID: 19370 Hi list, Attached is a new version of cDevice::PlayTsVideo and cDevice::PlayTsAudio that properly handles partially accepted buffers of the PlayVideo and PlayAudio functions. The original functions would discard any partially written data. These two functions are only used by devices that do not implement their own PlayTsXXX functions. The FF DVB devices don't use them any more, since TS is passed to (patched) DVB drivers. Other devices will soon play TS directly too. However, it might still be useful for patches that restore support for older drivers. ;) Cheers, Udo Index: device.c =================================================================== --- device.c (revision 1083) +++ device.c (working copy) @@ -89,6 +89,10 @@ liveSubtitle = NULL; dvbSubtitleConverter = NULL; autoSelectPreferredSubtitleLanguage = true; + tsToPesVideoBuffer = NULL; + tsToPesVideoLength = 0; + tsToPesAudioBuffer = NULL; + tsToPesAudioLength = 0; for (int i = 0; i < MAXRECEIVERS; i++) receiver[i] = NULL; @@ -1270,14 +1274,33 @@ int cDevice::PlayTsVideo(const uchar *Data, int Length) { + // Play remains of last buffer if not completely played: + while (tsToPesVideoBuffer && tsToPesVideoLength > 0) { + int w = PlayVideo(tsToPesVideoBuffer, tsToPesVideoLength); + if (w <= 0) + return w; + tsToPesVideoBuffer += w; + tsToPesVideoLength -= w; + if (tsToPesVideoLength > 0) { + errno = EAGAIN; + return -1; + } + tsToPesVideoBuffer = tsToPesVideo.GetPes(tsToPesVideoLength); + } + // Video PES has no explicit length, so we can only determine the end of // a PES packet when the next TS packet that starts a payload comes in: if (TsPayloadStart(Data)) { - int l; - while (const uchar *p = tsToPesVideo.GetPes(l)) { - int w = PlayVideo(p, l); + while ((tsToPesVideoBuffer = tsToPesVideo.GetPes(tsToPesVideoLength))) { + int w = PlayVideo(tsToPesVideoBuffer, tsToPesVideoLength); if (w <= 0) return w; + tsToPesVideoBuffer += w; + tsToPesVideoLength -= w; + if (tsToPesVideoLength > 0) { + errno = EAGAIN; + return -1; + } } tsToPesVideo.Reset(); } @@ -1287,12 +1310,31 @@ int cDevice::PlayTsAudio(const uchar *Data, int Length) { + // Play remains of last buffer if not completely played: + if (tsToPesAudioBuffer && tsToPesAudioLength > 0) { + int w = PlayAudio(tsToPesAudioBuffer, tsToPesAudioLength, 0); + if (w <= 0) + return w; + tsToPesAudioBuffer += w; + tsToPesAudioLength -= w; + if (tsToPesAudioLength > 0) { + errno = EAGAIN; + return -1; + } + tsToPesAudio.Reset(); + } + // Audio PES always has an explicit length and consists of single packets: - int l; - if (const uchar *p = tsToPesAudio.GetPes(l)) { - int w = PlayAudio(p, l, 0); + if ((tsToPesAudioBuffer = tsToPesAudio.GetPes(tsToPesAudioLength))) { + int w = PlayAudio(tsToPesAudioBuffer, tsToPesAudioLength, 0); if (w <= 0) return w; + tsToPesAudioBuffer += w; + tsToPesAudioLength -= w; + if (tsToPesAudioLength > 0) { + errno = EAGAIN; + return -1; + } tsToPesAudio.Reset(); } tsToPesAudio.PutTs(Data, Length); @@ -1347,7 +1389,11 @@ else if (Data == NULL) { patPmtParser.Reset(); tsToPesVideo.Reset(); + tsToPesVideoBuffer = NULL; + tsToPesVideoLength = 0; tsToPesAudio.Reset(); + tsToPesAudioBuffer = NULL; + tsToPesAudioLength = 0; tsToPesSubtitle.Reset(); } return -1; Index: device.h =================================================================== --- device.h (revision 1083) +++ device.h (working copy) @@ -475,7 +475,11 @@ cPlayer *player; cPatPmtParser patPmtParser; cTsToPes tsToPesVideo; + const uchar *tsToPesVideoBuffer; + int tsToPesVideoLength; cTsToPes tsToPesAudio; + const uchar *tsToPesAudioBuffer; + int tsToPesAudioLength; cTsToPes tsToPesSubtitle; bool isPlayingVideo; protected: