remove unecessary compatibility code trunk
authornathan
Wed, 04 Feb 2009 12:30:14 +0800
branchtrunk
changeset 233b14b8aacaa0
parent 22 93aaf15c145a
child 24 0598c933ccae
remove unecessary compatibility code
common.h
mp3.c
mplayer.c
player-mp3.c
player-mplayer.c
     1.1 --- a/common.h	Tue Feb 03 20:33:04 2009 +0800
     1.2 +++ b/common.h	Wed Feb 04 12:30:14 2009 +0800
     1.3 @@ -31,14 +31,6 @@
     1.4  #endif
     1.5  #include "config.h"
     1.6  
     1.7 -#define SLEEP(x) cCondWait::SleepMs(x)
     1.8 -
     1.9 -#include <vdr/tools.h>
    1.10 -static cTimeMs __time;
    1.11 -#define time_ms() ((int)__time.Elapsed())
    1.12 -
    1.13 -#define BUTTON "Button$"
    1.14 -
    1.15  #if !defined(NO_DEBUG) && defined(DEBUG)
    1.16  #define d(x) { (x); }
    1.17  #else
     2.1 --- a/mp3.c	Tue Feb 03 20:33:04 2009 +0800
     2.2 +++ b/mp3.c	Wed Feb 04 12:30:14 2009 +0800
     2.3 @@ -187,17 +187,15 @@
     2.4  
     2.5  // --- --------------------------------------------------------------------
     2.6  
     2.7 -static const char *TitleArtist(const char *title, const char *artist)
     2.8 -{
     2.9 -  static char buf[256]; // clearly not multi-thread save!
    2.10 +static cString TitleArtist(const char *title, const char *artist)
    2.11 +{
    2.12    const char *fmt;
    2.13    if(artist && artist[0]) {
    2.14      if(MP3Setup.TitleArtistOrder) fmt="%2$s - %1$s";
    2.15      else  fmt="%s - %s";
    2.16      }
    2.17    else fmt="%s";
    2.18 -  snprintf(buf,sizeof(buf),fmt,title,artist);
    2.19 -  return buf;
    2.20 +  return cString::sprintf(fmt,title,artist);
    2.21  }
    2.22  
    2.23  // --- cMP3Control --------------------------------------------------------
    2.24 @@ -214,7 +212,8 @@
    2.25    cMP3Player *player;
    2.26    bool visible, shown, bigwin, statusActive;
    2.27    time_t timeoutShow, greentime, oktime;
    2.28 -  int lastkeytime, number;
    2.29 +  cTimeMs lastkeytime;
    2.30 +  int number;
    2.31    bool selecting;
    2.32    //
    2.33    cMP3PlayInfo *lastMode;
    2.34 @@ -254,7 +253,7 @@
    2.35  {
    2.36    visible=shown=bigwin=selecting=jumpactive=jumphide=statusActive=false;
    2.37    timeoutShow=greentime=oktime=0;
    2.38 -  lastkeytime=number=0;
    2.39 +  number=0;
    2.40    lastMode=0;
    2.41    framesPerSecond=SecondsToFrames(1);
    2.42    osd=0; disp=0;
    2.43 @@ -449,7 +448,7 @@
    2.44      if(valid) { // send progress to status monitor
    2.45        if(changed || mode->Loop!=lastMode->Loop || mode->Shuffle!=lastMode->Shuffle) {
    2.46          snprintf(buf,sizeof(buf),"[%c%c] (%d/%d) %s",
    2.47 -                  mode->Loop?'L':'.',mode->Shuffle?'S':'.',mode->Num,mode->MaxNum,TitleArtist(mode->Title,mode->Artist));
    2.48 +                  mode->Loop?'L':'.',mode->Shuffle?'S':'.',mode->Num,mode->MaxNum,*TitleArtist(mode->Title,mode->Artist));
    2.49          cStatus::MsgReplaying(this,buf,mode->Filename[0]?mode->Filename:0,true);
    2.50          }
    2.51        }
    2.52 @@ -519,7 +518,7 @@
    2.53  	      flip=0;
    2.54  	      // fall through
    2.55  	    case 0:
    2.56 -	      snprintf(buf,sizeof(buf),"%s",TitleArtist(mode->Title,mode->Artist));
    2.57 +	      snprintf(buf,sizeof(buf),"%s",*TitleArtist(mode->Title,mode->Artist));
    2.58  	      flipint=6;
    2.59  	      break;
    2.60  	    case 1:
    2.61 @@ -566,7 +565,7 @@
    2.62            for(int i=0 ; i<rows && i<MAXROWS && num<=mode->MaxNum ; i++,num++) {
    2.63              cMP3PlayInfo pi;
    2.64              mgr->Info(num,&pi); if(!pi.Title[0]) break;
    2.65 -            snprintf(buf,sizeof(buf),"%d.\t%s",num,TitleArtist(pi.Title,pi.Artist));
    2.66 +            snprintf(buf,sizeof(buf),"%d.\t%s",num,*TitleArtist(pi.Title,pi.Artist));
    2.67              int fg=clrWhite, bg=clrGray50;
    2.68              int hash=MakeHash(buf);
    2.69              if(num==mode->Num) { fg=clrBlack; bg=clrCyan; hash=(hash^77) + 23; }
    2.70 @@ -744,7 +743,7 @@
    2.71        if(lastMode && number>0 && number<=lastMode->MaxNum) {
    2.72          if(!visible) ShowTimed(SELECTHIDE_TIMEOUT);
    2.73          else if(timeoutShow>0) timeoutShow=time(0)+SELECTHIDE_TIMEOUT;
    2.74 -        selecting=true; lastkeytime=time_ms();
    2.75 +        selecting=true; lastkeytime.Set(SELECT_TIMEOUT);
    2.76          char buf[32];
    2.77          if(MP3Setup.ReplayDisplay) {
    2.78            snprintf(buf,sizeof(buf),"%s%d-/%d",trVDR("Jump: "),number,lastMode->MaxNum);
    2.79 @@ -757,10 +756,10 @@
    2.80          Flush();
    2.81          break;
    2.82          }
    2.83 -      number=0; lastkeytime=0;
    2.84 +      number=0; lastkeytime.Set();
    2.85        // fall through
    2.86      case kNone:
    2.87 -      if(selecting && time_ms()-lastkeytime>SELECT_TIMEOUT) {
    2.88 +      if(selecting && lastkeytime.TimedOut()) {
    2.89          if(number>0) { mgr->Goto(number); player->Play();  }
    2.90          if(lastMode) lastMode->Hash=-1;
    2.91          number=0; selecting=false;
    2.92 @@ -954,7 +953,7 @@
    2.93    cSongInfo *si=song->Info(false);
    2.94    if(showID3 && !si) si=song->Info();
    2.95    if(showID3 && si && si->Title)
    2.96 -    asprintf(&buffer, "%d.\t%s",song->Index()+1,TitleArtist(si->Title,si->Artist));
    2.97 +    asprintf(&buffer, "%d.\t%s",song->Index()+1,*TitleArtist(si->Title,si->Artist));
    2.98    else
    2.99      asprintf(&buffer, "%d.\t<%s>",song->Index()+1,song->Name());
   2.100    SetText(buffer,false);
   2.101 @@ -995,7 +994,7 @@
   2.102  
   2.103  void cMenuPlayList::Buttons(void)
   2.104  {
   2.105 -  SetHelp(tr("Add"), showid3?tr("Filenames"):tr("ID3 names"), tr("Remove"), trVDR(BUTTON"Mark"));
   2.106 +  SetHelp(tr("Add"), showid3?tr("Filenames"):tr("ID3 names"), tr("Remove"), trVDR("Button$Mark"));
   2.107  }
   2.108  
   2.109  void cMenuPlayList::Refresh(bool all)
   2.110 @@ -1213,10 +1212,10 @@
   2.111  {
   2.112    switch(num) {
   2.113      case 1:
   2.114 -      SetHelp(trVDR(BUTTON"Edit"), tr("Source"), tr("Browse"), ">>");
   2.115 +      SetHelp(trVDR("Button$Edit"), tr("Source"), tr("Browse"), ">>");
   2.116        break;
   2.117      case 2:
   2.118 -      SetHelp("<<", trVDR(BUTTON"New"), trVDR(BUTTON"Delete"), tr("Rename"));
   2.119 +      SetHelp("<<", trVDR("Button$New"), trVDR("Button$Delete"), tr("Rename"));
   2.120        break;
   2.121      }
   2.122    buttonnum=num; Display();
   2.123 @@ -1355,7 +1354,7 @@
   2.124  
   2.125    if(!second) {
   2.126      instanting=true;
   2.127 -    return AddSubMenu(new cMenuInstantBrowse(MP3Sources.GetSource(),trVDR(BUTTON"Play"),tr("Play all")));
   2.128 +    return AddSubMenu(new cMenuInstantBrowse(MP3Sources.GetSource(),trVDR("Button$Play"),tr("Play all")));
   2.129      }
   2.130    instanting=false;
   2.131    cFileObj *item=cMenuInstantBrowse::GetSelected();
     3.1 --- a/mplayer.c	Tue Feb 03 20:33:04 2009 +0800
     3.2 +++ b/mplayer.c	Wed Feb 04 12:30:14 2009 +0800
     3.3 @@ -471,7 +471,7 @@
     3.4  {
     3.5    static char blue[12];
     3.6    snprintf(blue,sizeof(blue),MPlayerAid>=0 ? "AID:%d" : "AID:def",MPlayerAid);
     3.7 -  SetHelp(trVDR(BUTTON"Play"), MPlayerSetup.ResumeMode ? trVDR(BUTTON"Rewind"):0, tr("Source"), blue);
     3.8 +  SetHelp(trVDR("Button$Play"), MPlayerSetup.ResumeMode ? trVDR("Button$Rewind"):0, tr("Source"), blue);
     3.9    Display();
    3.10  }
    3.11  
     4.1 --- a/player-mp3.c	Tue Feb 03 20:33:04 2009 +0800
     4.2 +++ b/player-mp3.c	Wed Feb 04 12:30:14 2009 +0800
     4.3 @@ -909,13 +909,13 @@
     4.4  {
     4.5    if(MP3Setup.BgrScan) {
     4.6      if(!thr && throttle) {
     4.7 -      db(printf("mgr: bgr-scan -> run (%d)\n",time_ms()))
     4.8 +      db(printf("mgr: bgr-scan -> run (%llu)\n",cTimeMs::Now()))
     4.9        listMutex.Lock();
    4.10        throttle=false; bgCond.Broadcast();
    4.11        listMutex.Unlock();
    4.12        }
    4.13      if(thr && !throttle) {
    4.14 -      db(printf("mgr: bgr-scan -> throttle (%d)\n",time_ms()))
    4.15 +      db(printf("mgr: bgr-scan -> throttle (%llu)\n",cTimeMs::Now()))
    4.16        throttle=true;
    4.17        }
    4.18      }
    4.19 @@ -1583,12 +1583,12 @@
    4.20    const unsigned char *p=0;
    4.21    int pc=0, readindex=0;
    4.22    bool imageValid=true;
    4.23 -  int imageCheck=0;
    4.24 +  cTimeMs imageCheck;
    4.25  #ifdef DEBUG
    4.26    int beat=0;
    4.27  #endif
    4.28  #ifdef DEBUG_DELAY
    4.29 -  int lastwrite=0;
    4.30 +  cTimeMs lastwrite(2000000);
    4.31  #endif
    4.32  
    4.33    dsyslog("mp3: player thread started (pid=%d)", getpid());
    4.34 @@ -1622,13 +1622,13 @@
    4.35      Lock();
    4.36  
    4.37  next:
    4.38 -    if(!pframe && playing && !imageValid && imageCheck<time_ms()) {
    4.39 +    if(!pframe && playing && !imageValid && imageCheck.Elapsed()) {
    4.40        unsigned char *mem;
    4.41        int len;
    4.42 -      imageCheck=time_ms()+250;
    4.43 +      imageCheck.Set(250);
    4.44        imageValid=playing->Image(mem,len);
    4.45        if(mem) {
    4.46 -        if(playindex) SLEEP(80); // stillpicture ioctl freezes without this
    4.47 +        if(playindex) cCondWait::SleepMs(80); // stillpicture ioctl freezes without this
    4.48          DeviceStillPicture(mem,len);
    4.49          free(mem);
    4.50          }
    4.51 @@ -1648,10 +1648,9 @@
    4.52      if(pframe) {
    4.53  #ifdef DEBUG_DELAY
    4.54        {
    4.55 -      int now=time_ms();
    4.56 -      if(lastwrite && lastwrite<now-(DEBUG_DELAY+50))
    4.57 -        printf("mp3: write delayed %d ms\n",now-lastwrite);
    4.58 -      lastwrite=now;
    4.59 +      if(lastwrite.TimedOut())
    4.60 +        printf("mp3: write delayed %llu ms\n",lastwrite.Elapsed());
    4.61 +      lastwrite.Set(DEBUG_DELAY+50);
    4.62        }
    4.63  #endif
    4.64        int w=output->Output(p,pc,SOF);
    4.65 @@ -1714,12 +1713,11 @@
    4.66          case msDecode:
    4.67            {
    4.68  #ifdef DEBUG_DELAY
    4.69 -          int now=time_ms();
    4.70 +          cTimeMs check(DEBUG_DELAY);
    4.71  #endif
    4.72            struct Decode *ds=decoder->Decode();
    4.73  #ifdef DEBUG_DELAY
    4.74 -          now=time_ms()-now;
    4.75 -          if(now>DEBUG_DELAY) printf("mp3: decode delayed %d ms\n",now);
    4.76 +          if(check.TimedOut()) printf("mp3: decode delayed %llu ms\n",check.Elapsed());
    4.77  #endif
    4.78            switch(ds->status) {
    4.79              case dsPlay:
    4.80 @@ -1837,14 +1835,14 @@
    4.81      else if(playMode!=pmPlay) {
    4.82        mgr->Throttle(false);
    4.83        if(!imageValid)
    4.84 -        SLEEP(100);
    4.85 +        cCondWait::SleepMs(100);
    4.86        else {
    4.87          playModeMutex.Lock();
    4.88          if(playMode!=pmPlay) WaitPlayMode(playMode,true);
    4.89          playModeMutex.Unlock();
    4.90          }
    4.91  #ifdef DEBUG_DELAY
    4.92 -      lastwrite=0;
    4.93 +      lastwrite.Set(2000000);
    4.94  #endif
    4.95        }
    4.96      else if(state!=msWait && ringBuffer->Available()<(MP3BUFSIZE*50/100)) {
     5.1 --- a/player-mplayer.c	Tue Feb 03 20:33:04 2009 +0800
     5.2 +++ b/player-mplayer.c	Wed Feb 04 12:30:14 2009 +0800
     5.3 @@ -323,15 +323,15 @@
     5.4        if(slave) {
     5.5          Play(); // MPlayer ignores "quit" while paused
     5.6          MPlayerControl("quit");
     5.7 -        int until=time_ms()+3000; // wait some time until MPlayer is gone
     5.8 +        cTimeMs until(3000); // wait some time until MPlayer is gone
     5.9          d(printf("mplayer: waiting for child exit"))
    5.10          while(Active()) {
    5.11 -          if(time_ms()>until) {
    5.12 +          if(until.TimedOut()) {
    5.13              kill(pid,SIGKILL); // kill it anyways
    5.14              d(printf(" SIGKILL"))
    5.15              break;
    5.16              }
    5.17 -          SLEEP(250);
    5.18 +          cCondWait::SleepMs(250);
    5.19            d(printf(".")) d(fflush(stdout))
    5.20            }
    5.21          d(printf("\n"))