Mailing List archive

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

[vdr] Re: missing OSD lines in AIO patch fixed ?



On Thu, Jan 17, 2002 at 09:02:51PM +0100, Thilo Wunderlich wrote:
> anyone working on a fix for the missing OSD lines when using the AIO 
> patch ? I'm using the 01.01 AIO patch from 
> http://www.people.freenet.de/elchi/
> 
> and its quite annoing if two or more lines are missing. 
> I resized the OSD but some lines are always gone.

You may try the patch included. It does move from LCDproc 25.11.01 to
LCDproc 29.12.01, includes two fixes posted here (both for OSD), and
uses an usleep(500) after the ioctl OSD_SEND_CMD.

Beside this I'm using a pid file if vdr runs as root.

Btw. is anyone working on the teletext patch from Peter Seyringer
(I've found some BUGs therein and its currently not working).

          Werner


-----------------------------------------------------------------------------------
--- dvbapi.c
+++ dvbapi.c	Wed Jan 16 11:46:37 2002
@@ -565,7 +565,7 @@
 {
   dsyslog(LOG_INFO, "input thread started (pid=%d)", getpid());
 #ifdef LCD // LCDproc
-  LCDproc->SetCardStat(dvbApi->CardIndex(),2);
+   LCDproc->SetCardStat(dvbApi->CardIndex(),2);
 #endif // LCD
 #ifdef CATCH
    ulong mem[MINVIDEODATA/4+2];
@@ -2725,6 +2725,10 @@
 {
   dsyslog(LOG_INFO, "input thread started (pid=%d)", getpid());
 
+#ifdef LCD // LCDproc
+  LCDproc->SetCardStat(dvbApi->CardIndex(),2);
+#endif // LCD
+
   uchar b[MINVIDEODATA];
   int n = 0;
   while (Busy()) {
@@ -2760,6 +2764,9 @@
         }
 
   dsyslog(LOG_INFO, "input thread ended (pid=%d)", getpid());
+#ifdef LCD // LCDproc
+  LCDproc->SetCardStat(dvbApi->CardIndex(),1);
+#endif // LCD
 }
 
 void cTransferBuffer::Output(void)
@@ -2793,7 +2800,7 @@
                  }
            }
         else
-           usleep(1); // this keeps the CPU load low
+           usleep(100); // this keeps the CPU load low
         }
 
   dsyslog(LOG_INFO, "output thread ended (pid=%d)", getpid());
--- dvbosd.c
+++ dvbosd.c	Wed Jan 16 15:30:54 2002
@@ -76,7 +76,9 @@
 {
   for (FirstColor = 0; FirstColor < numColors; FirstColor++) {
       if (!fetched[FirstColor]) {
-         for (LastColor = FirstColor; LastColor < numColors && !fetched[LastColor]; LastColor++)
+         for (LastColor = FirstColor; LastColor < numColors &&
+				      !fetched[LastColor]   &&
+				      color[LastColor] == color[FirstColor]; LastColor++)
              fetched[LastColor] = true;
          LastColor--; // the loop ended one past the last one!
          return &color[FirstColor];
@@ -360,9 +362,11 @@
      // must block all signals, otherwise the command might not be fully executed
      sigset_t set, oldset;
      sigfillset(&set);
+     sigdelset(&set, SIGALRM);
      sigprocmask(SIG_BLOCK, &set, &oldset);
      CHECK( ioctl(videoDev, OSD_SEND_CMD, &dc) );
      //     usleep(5000); // XXX Workaround for a driver bug (cInterface::DisplayChannel() displayed texts at wrong places
+     usleep(500);
                    // XXX and sometimes the OSD was no longer displayed).
                    // XXX Increase the value if the problem still persists on your particular system.
                    // TODO Check if this is still necessary with driver versions after 0.7.
--- lcd.c
+++ lcd.c	Thu Jan 17 13:46:56 2002
@@ -30,8 +30,6 @@
   for (i=0;i<LCDMAXSTATEBUF;i++) LastState[i]=Title; LastStateP=0;
   ThreadStateData.barx=1, ThreadStateData.bary=1, ThreadStateData.barl=0; 
   for (i=0;i<LCDMAXCARDS;i++) ThreadStateData.CardStat[i]=0;
-
-  //ThreadStateData.CardStat[0]=1; ThreadStateData.CardStat[1]=2; ThreadStateData.CardStat[2]=3; 
 }
 
 cLcd::~cLcd() {
@@ -70,7 +68,6 @@
   sock_send_string(sock,"widget_add VDR prbar hbar\n"); sock_recv(sock, istring, 1024);
   sock_send_string(sock,"widget_set VDR prbar 1 1 0\n"); sock_recv(sock, istring, 1024);
  
-  pthread_mutex_init(&CriticalArea,NULL);
   cLcd::Start(); SetThreadState(Title); // Start thread
   return connected;
 }
@@ -358,11 +355,11 @@
 // should have exclusive access to ThreadStateData
 
 void cLcd::BeginMutualExclusion() {
-  pthread_mutex_lock(&CriticalArea);
+  cLcd::CriticalArea.Lock();
 }
 
 void cLcd::EndMutualExclusion() {
-  pthread_mutex_unlock(&CriticalArea);
+  cLcd::CriticalArea.Unlock();
 }
 
 void cLcd::Copy(char *to, const char *from, unsigned int max) { // eliminates tabs, double blanks ...
@@ -462,6 +459,34 @@
   sleep(5);
 
   while (true) { // main loop, wakes up every WakeUpCycle, any output to LCDd is done here  
+
+/*--------------------
+
+     const cEventInfo *Present = NULL, *Following = NULL;
+     cThreadLock ThreadLock;
+     const cSchedules *Schedules = cDvbApi::PrimaryDvbApi->Schedules(&ThreadLock);
+     if (Schedules) {
+        const cSchedule *Schedule = Schedules->GetSchedule();
+        if (Schedule) {
+           const char *PresentTitle = NULL, *PresentSubtitle = NULL, *FollowingTitle = NULL, *FollowingSubtitle = NULL;
+              if ( (!isempty(PresentTitle)) && (!isempty(PresentSubtitle)) )
+                 LCDproc->SetRunning(false,Present->GetTimeString(),PresentTitle,PresentSubtitle);
+              else if (!isempty(PresentTitle))
+                 LCDproc->SetRunning(false,Present->GetTimeString(),PresentTitle);
+              else
+                 LCDproc->SetRunning(false);
+
+              if ( (!isempty(FollowingTitle)) && (!isempty(FollowingSubtitle)) )
+                 LCDproc->SetRunning(true,Following->GetTimeString(),FollowingTitle,FollowingSubtitle);
+              else if (!isempty(FollowingTitle))
+                 LCDproc->SetRunning(true,Following->GetTimeString(),FollowingTitle);
+              else
+                 LCDproc->SetRunning(true);
+              }
+           }
+        }
+
+--------------------*/
 
     BeginMutualExclusion();  // all data needed for output are copied here  
       memcpy(&OutStateData,&ThreadStateData, sizeof (cLcd::StateData));  
--- lcd.h
+++ lcd.h	Wed Jan 16 11:46:37 2002
@@ -53,7 +53,7 @@
     bool connected;
     struct StateData ThreadStateData;
     time_t LastProgress;
-    pthread_mutex_t CriticalArea;
+    cMutex CriticalArea;
     unsigned int sock, wid, hgt, cellwid, cellhgt;
     char StringBuffer[2*LCDMAXWID+1];
     void BeginMutualExclusion();
--- menu.c
+++ menu.c	Thu Jan 17 16:10:45 2002
@@ -2139,11 +2139,13 @@
 #ifdef LCD // LCDproc
               if ( (!isempty(PresentTitle)) && (!isempty(PresentSubtitle)) )
                  LCDproc->SetRunning(false,Present->GetTimeString(),PresentTitle,PresentSubtitle);
-                 else if (!isempty(PresentTitle)) LCDproc->SetRunning(false,Present->GetTimeString(),PresentTitle); 
+              else if (!isempty(PresentTitle))
+                 LCDproc->SetRunning(false,Present->GetTimeString(),PresentTitle); 
 
               if ( (!isempty(FollowingTitle)) && (!isempty(FollowingSubtitle)) )
                  LCDproc->SetRunning(true,Following->GetTimeString(),FollowingTitle,FollowingSubtitle);
-                 else if (!isempty(FollowingTitle)) LCDproc->SetRunning(true,Following->GetTimeString(),FollowingTitle);
+              else if (!isempty(FollowingTitle))
+                 LCDproc->SetRunning(true,Following->GetTimeString(),FollowingTitle);
 #endif // LCD
               Interface->Flush();
               lines = Lines;
--- spu.c
+++ spu.c	Wed Jan 16 11:46:37 2002
@@ -74,8 +74,10 @@
 #include "spu.h"
 
 #define DISPLAY_INIT
-	
+
+#ifndef LOG_DEBUG
 #define LOG_DEBUG 1
+#endif
 
 #ifdef DEBUG
 #define LOG(lvl, fmt...)	fprintf (stderr, fmt);
--- vdr.c
+++ vdr.c	Thu Jan 17 16:13:32 2002
@@ -30,6 +30,8 @@
 #include <signal.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <paths.h>
+#include <errno.h>
 #include "config.h"
 #include "dvbapi.h"
 #ifdef DVDSUPPORT
@@ -85,6 +87,13 @@
   exit(1);
 }
 
+static const char pidfile[] = _PATH_VARRUN"vdr.pid";
+static void rmfpid()
+{
+  // Remove pidfile
+  unlink(pidfile);
+}
+
 int main(int argc, char *argv[])
 {
   // Initiate locale:
@@ -108,6 +117,9 @@
   int WatchdogTimeout = DEFAULTWATCHDOG;
   const char *Terminal = NULL;
   const char *Shutdown = NULL;
+#ifdef LCD // LCDproc
+  time_t lastLcdUpdate = time(NULL);
+#endif // LCD
 
   static struct option long_options[] = {
       { "audio",    required_argument, NULL, 'a' },
@@ -324,6 +336,7 @@
      fclose(stdin);
      fclose(stdout);
      fclose(stderr);
+     setsid(void); // Real daemons should do that
 #else
      fprintf(stderr, "vdr: can't run in daemon mode with DEBUG_OSD or REMOTE_KBD on!\n");
      return 2;
@@ -336,6 +349,20 @@
      stderr = freopen(Terminal, "w", stderr);
      }
 
+  // Handle pid file if run as root
+  if (getuid() == 0)
+  {
+     FILE * fpid;
+     if ((fpid = fopen (pidfile, "w")) == NULL)
+        fprintf(stderr, "vdr: can not open %s: %s\n", pidfile, strerror(errno));
+     else
+     {
+        fprintf(fpid, "%d\n", (int)getpid());
+        fclose(fpid);
+        atexit(rmfpid);
+     }
+  }
+
   isyslog(LOG_INFO, "VDR version %s started", VDRVERSION);
 #ifdef MP3SUPPORT
   isyslog(LOG_INFO, "MP3 extention version %s", MP3VERSION);
@@ -478,6 +505,33 @@
            EITScanner.Activity();
            LastActivity = time(NULL);
            }
+#ifdef LCD // LCDproc
+        Now = time(NULL);
+        if (Now - lastLcdUpdate > 59 && !EITScanner.Active()) {
+            const cEventInfo *Present = NULL;
+            cThreadLock *ThreadLock;
+            ThreadLock = new cThreadLock;
+            const cSchedules *Schedules = cDvbApi::PrimaryDvbApi->Schedules(ThreadLock);
+            if (Schedules) {
+               const cSchedule *Schedule = Schedules->GetSchedule();
+               if (Schedule) {
+                  const char *PresentTitle, *PresentSubtitle;
+                  PresentTitle = NULL; PresentSubtitle = NULL;
+                  if ((Present = Schedule->GetPresentEvent()) != NULL) {
+                     PresentTitle = Present->GetTitle();
+                     PresentSubtitle = Present->GetSubtitle();
+                     if (!isempty(PresentTitle) && !isempty(PresentSubtitle))
+                        LCDproc->SetRunning(false,Present->GetTimeString(),PresentTitle,PresentSubtitle);
+                     else if (!isempty(PresentTitle))
+                        LCDproc->SetRunning(false,Present->GetTimeString(),PresentTitle);
+                     }
+                  }
+               }
+            delete ThreadLock;
+            lastLcdUpdate = Now - time(NULL)%60;
+            }
+#endif // LCD 
+
         // Keys that must work independent of any interactive mode:
         switch (key) {
           // Volume Control:
-----------------------------------------------------------------------------------



Home | Main Index | Thread Index