diff options
-rw-r--r-- | dvbapi.c | 10 | ||||
-rw-r--r-- | dvbapi.h | 4 | ||||
-rw-r--r-- | menu.c | 6 | ||||
-rw-r--r-- | menu.h | 4 | ||||
-rw-r--r-- | tools.c | 21 | ||||
-rw-r--r-- | tools.h | 4 |
6 files changed, 37 insertions, 12 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: dvbapi.c 1.7 2000/04/24 13:27:38 kls Exp $ + * $Id: dvbapi.c 1.8 2000/04/24 15:30:35 kls Exp $ */ #include "dvbapi.h" @@ -1150,7 +1150,7 @@ void cDvbApi::Text(int x, int y, const char *s, eDvbColor colorFg, eDvbColor col #endif } -void cDvbApi::ShowProgress(bool Initial) +bool cDvbApi::ShowProgress(bool Initial) { int Current, Total; @@ -1191,7 +1191,9 @@ void cDvbApi::ShowProgress(bool Initial) } #endif Text(0, 2, cIndexFile::Str(Current)); + return true; } + return false; } bool cDvbApi::SetChannel(int FrequencyMHz, char Polarization, int Diseqc, int Srate, int Vpid, int Apid, int Ca, int Pnr) @@ -1538,6 +1540,7 @@ bool cDvbApi::GetIndex(int *Current, int *Total) { if (pidReplay) { int total; + purge(fromReplay); writechar(toReplay, dvbGetIndex); if (readint(fromReplay, *Current) && readint(fromReplay, total)) { if (Total) @@ -1545,7 +1548,8 @@ bool cDvbApi::GetIndex(int *Current, int *Total) } else *Current = -1; + return *Current >= 0; } - return *Current >= 0; + return false; } @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: dvbapi.h 1.7 2000/04/24 10:46:47 kls Exp $ + * $Id: dvbapi.h 1.8 2000/04/24 15:31:07 kls Exp $ */ #ifndef __DVBAPI_H @@ -75,7 +75,7 @@ private: int lastProgress; char *replayTitle; public: - void ShowProgress(bool Initial = false); + bool ShowProgress(bool Initial = false); // Channel facilities @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menu.c 1.7 2000/04/24 09:44:27 kls Exp $ + * $Id: menu.c 1.8 2000/04/24 15:32:11 kls Exp $ */ #include "menu.h" @@ -1018,7 +1018,7 @@ eOSState cMenuMain::ProcessKey(eKeys Key) cReplayDisplay::cReplayDisplay(void) { Interface.Open(MenuColumns, -3); - DvbApi.ShowProgress(true); + shown = DvbApi.ShowProgress(true); } cReplayDisplay::~cReplayDisplay() @@ -1030,7 +1030,7 @@ eKeys cReplayDisplay::ProcessKey(eKeys Key) { if (!DvbApi.Replaying()) return kOk; // will turn off replay display - DvbApi.ShowProgress(); + shown = DvbApi.ShowProgress(!shown); switch (Key) { case kBegin: case kPause: @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menu.h 1.4 2000/04/24 09:44:29 kls Exp $ + * $Id: menu.h 1.5 2000/04/24 15:31:53 kls Exp $ */ #ifndef _MENU_H @@ -19,6 +19,8 @@ public: }; class cReplayDisplay { +private: + bool shown; public: cReplayDisplay(void); ~cReplayDisplay(); @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.c 1.6 2000/04/24 13:54:23 kls Exp $ + * $Id: tools.c 1.7 2000/04/24 15:01:35 kls Exp $ */ #define _GNU_SOURCE @@ -22,6 +22,17 @@ int SysLogLevel = 3; +bool DataAvailable(int filedes) +{ + fd_set set; + FD_ZERO(&set); + FD_SET(filedes, &set); + struct timeval timeout; + timeout.tv_sec = 0; + timeout.tv_usec = 10000; + return select(FD_SETSIZE, &set, NULL, NULL, &timeout) > 0 && FD_ISSET(filedes, &set); +} + void writechar(int filedes, char c) { write(filedes, &c, sizeof(c)); @@ -41,7 +52,13 @@ char readchar(int filedes) bool readint(int filedes, int &n) { - return read(filedes, &n, sizeof(n)) == sizeof(n); + return DataAvailable(filedes) && read(filedes, &n, sizeof(n)) == sizeof(n); +} + +void purge(int filedes) +{ + while (DataAvailable(filedes)) + readchar(filedes); } char *readline(FILE *f) @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.h 1.6 2000/04/24 13:09:20 kls Exp $ + * $Id: tools.h 1.7 2000/04/24 15:01:49 kls Exp $ */ #ifndef __TOOLS_H @@ -30,10 +30,12 @@ extern int SysLogLevel; #define DELETENULL(p) (delete (p), p = NULL) +bool DataAvailable(int filedes); void writechar(int filedes, char c); void writeint(int filedes, int n); char readchar(int filedes); bool readint(int filedes, int &n); +void purge(int filedes); char *readline(FILE *f); int time_ms(void); void delay_ms(int ms); |