Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: a couple patches for ttxtsubs from Luca Olivetti



Hi again,

I tried again to apply your patchs but had no success.

You mentionned Rolf Ahrenberg's patches so I got the 3 followings from http://www.hut.fi/u/rahrenbe/vdr/:
- vdr-ttxtsubs-0.0.5-charset_fix-custom_color.diff.gz
- vdr-ttxtsubs-0.0.5-charset_fix-custom_color-for-developer-vdr.diff.gz
- vdr-ttxtsubs-0.0.5-source_selection.diff.gz
Thoses patches apply to ttxtsubs-0.0.5 with some failed hunks.

After that I tried to apply patch1 and patch2 you provided and got 8/8 hunks failed and 3/3 hunks failed.

Could you provide the correct way to apply your patches because I am very interested in the independent thread or else provide your ttxtsubs plugin directory ?

Thanks,

Alain B.

----- Original Message ----- From: "Luca Olivetti" <luca@ventoso.org>
To: <vdr@linuxtv.org>
Sent: Saturday, November 20, 2004 2:20 PM
Subject: [vdr] a couple patches for ttxtsubs


The first patch makes the pluging look for the teletext info in a
separate thread. I had 3 reasons to write this patch:
1) I didn't like the fact that vdr was stuck while looking for the info
(unless it wasn't already cached)
1b) I wanted to get rid of the cache since it could contain stale info
(in case of channel renumbering due to manual edit or autoupdate)
2) the function would fail with a steerable dish (and since it's in a
separate thread I can go on looking for the info in a loop instead of
giving up after the first failure).

The patch is only for live subtitles, I wanted to do the same for
recordings but I couldn't decipher the path of events do do that in an
harmless and working manner (I hope that someday core vdr will work
better with steerable dishes). Besides, recorded subtitles are almost
useless to me since they show up a second earlier (live subtitles are
perfectly synched with the audio).

The second patch just removes the cache (see 1b above).

Bye
--
- Yo también quiero una Europa libre de Patentes de Software -
- I want a Software Patents Free Europe too! And you? -
---------------------------------------------------------------
EuropeSwPatentFree - http://EuropeSwPatentFree.hispalinux.es



--------------------------------------------------------------------------------


--- ttxtsubs.c.orig 2004-11-14 14:22:39.089703661 +0100
+++ ttxtsubs.c 2004-11-16 20:57:58.643895849 +0100
@@ -11,6 +11,7 @@
#include <vdr/vdrttxtsubshooks.h>
#include <vdr/menuitems.h>
#include <vdr/config.h>
+#include <semaphore.h>

#define TIMEMEASURE 0
#if TIMEMEASURE
@@ -106,7 +107,7 @@
};
int gNumLanguages = sizeof(gLanguages) / sizeof(gLanguages[0]);

-class cPluginTtxtsubs : public cPlugin, public cStatus, public cVDRTtxtsubsHookListener {
+class cPluginTtxtsubs : public cPlugin, public cStatus, public cVDRTtxtsubsHookListener, public cThread {
public:
cPluginTtxtsubs(void);
virtual ~cPluginTtxtsubs();
@@ -146,6 +147,9 @@
virtual void PlayerTeletextData(uint8_t *p, int length);
virtual cTtxtSubsRecorderBase *NewTtxtSubsRecorder(cDevice *dev, const cChannel *ch);

+ // -- cThread
+ void Action(void);
+
// -- internal
private:
void StartTtxtLive(const cDevice *Device, int pid, int page);
@@ -155,7 +159,7 @@
void HideTtxt(void);
void parseLanguages(const char *val);
void parseHIs(const char *val);
-
+
private:
cTtxtSubsDisplayer *mDispl;

@@ -164,6 +168,12 @@

// ugly hack for now
int mPage;
+ // wait for channel switch
+ sem_t chswitchwait;
+ cMutex getchmutex;
+ int switchChannel;
+ int lastc;
+ const cDevice *switchDevice;
};

class cMenuSetupTtxtsubs : public cMenuSetupPage {
@@ -197,11 +207,17 @@

memset(mOldLanguage, 0, 4);
strncpy(globals.mLanguages[0][0], "unk", 4);
+ sem_init(&chswitchwait,0,0);
+ lastc=0;
+ cThread::Start();
}

cPluginTtxtsubs::~cPluginTtxtsubs()
{
// Clean up after yourself!
+ cThread::Cancel();
+ StopTtxt();
+
}

const char *cPluginTtxtsubs::CommandLineHelp(void)
@@ -340,26 +356,38 @@
return true;
}

-void cPluginTtxtsubs::ChannelSwitch(const cDevice *Device, int ChannelNumber)
+void cPluginTtxtsubs::Action(void)
{
-#if TIMEMEASURE
- struct timeval tv, tv2;
- gettimeofday(&tv, NULL);
-#endif
- //dprint("cPluginTtxtsubs::ChannelSwitch(devicenr: %d, channelnr: %d) - mDispl: %x\n", Device->DeviceNumber(), ChannelNumber, mDispl); // XXX
-
- if(Device->IsPrimaryDevice()) {
- if(ChannelNumber) {
- cChannel *c = Channels.GetByNumber(ChannelNumber);
+ while(true) {
+ sem_wait(&chswitchwait);
+ int cn;
+ const cDevice *dev;
+ getchmutex.Lock();
+ cn=switchChannel;
+ dev=switchDevice;
+ getchmutex.Unlock();
+ if (cn!=lastc) {
+ StopTtxt();
+ lastc=0;
+ cChannel *c = Channels.GetByNumber(cn);
if(c) {
struct ttxtinfo info;
int pid, page;
char lang[4] = "";
-
+ bool geterror=true;
if((globals.dvbSources() == 0) || ((globals.dvbSources() == 1) && c->IsSat()) || ((globals.dvbSources() == 2) && c->IsTerr()) || ((globals.dvbSources() == 3) && c->IsCable()))
- if(GetTtxtInfo(Device->ActualDevice()->CardIndex(), ChannelNumber, c->Sid(), c->Vpid(), &info)) {
+ while(geterror=GetTtxtInfo(dev->ActualDevice()->CardIndex(), cn, c->Sid(), c->Vpid(), &info)) {
fprintf(stderr, "ttxtsubs: Error: GetTtxtInfo failed!\n");
- } else {
+ sleep(1);
+ getchmutex.Lock();
+ bool changed=(cn!=switchChannel);
+ getchmutex.Unlock();
+ if (changed) {
+ fprintf(stderr, "ttxtsubs: Channel changed in Action\n");
+ break;
+ }
+ }
+ if (!geterror) {
if(FindSubs(&info, &pid, &page, lang)) {
//fprintf(stderr, "CHANNELSWITCH, pid: %d page: %x\n", pid, page);
mPage = page; // XXX remember this for playback (temporary hack)!
@@ -371,13 +399,32 @@
}
if(globals.mI18nLanguage < 0 || globals.mI18nLanguage >= I18nNumLanguages)
globals.mI18nLanguage = 0; // default to iso8859-1 if no predefined charset
- StartTtxtLive(Device, pid, page);
+ StartTtxtLive(dev, pid, page);
}
FreeTtxtInfoData(&info);
+ lastc=cn;
}
}
- } else
- StopTtxt();
+ }
+ }
+}
+
+void cPluginTtxtsubs::ChannelSwitch(const cDevice *Device, int ChannelNumber)
+{
+#if TIMEMEASURE
+ struct timeval tv, tv2;
+ gettimeofday(&tv, NULL);
+#endif
+ //dprint("cPluginTtxtsubs::ChannelSwitch(devicenr: %d, channelnr: %d) - mDispl: %x\n", Device->DeviceNumber(), ChannelNumber, mDispl); // XXX
+
+ if(Device->IsPrimaryDevice()) {
+ if(ChannelNumber) {
+ getchmutex.Lock();
+ switchChannel=ChannelNumber;
+ switchDevice=Device;
+ getchmutex.Unlock();
+ sem_post(&chswitchwait);
+ }
}
#if TIMEMEASURE
gettimeofday(&tv2, NULL);


--------------------------------------------------------------------------------


--- siinfo.c.orig 2004-11-16 18:50:25.486145650 +0100
+++ siinfo.c 2004-11-16 18:52:10.361937476 +0100
@@ -484,6 +484,7 @@

memset((char *) info, 0, sizeof(*info));

+/*
cCache::iterator iter;
iter = gCache.find(channel);
if(iter != gCache.end()) {
@@ -491,6 +492,7 @@
ret = 0;
return ret;
}
+*/

for(retry = 0; retry <= 1 && !foundinfo; retry++) { // XXX retry two times due to flaky pat scanning with hw_sections=0

@@ -563,12 +565,14 @@

FreeSects(patsects);
}
-
+
+/*
if(foundinfo || (ret == 0 && retry == 2)) {
struct ttxtinfo info2;
DupTtxtInfo(info, &info2);
gCache[channel] = info2;
}
+*/

bail:
return ret;






Home | Main Index | Thread Index