1.1 --- a/mp3.c Tue Feb 03 20:33:04 2009 +0800
1.2 +++ b/mp3.c Wed Feb 04 12:30:14 2009 +0800
1.3 @@ -187,17 +187,15 @@
1.4
1.5 // --- --------------------------------------------------------------------
1.6
1.7 -static const char *TitleArtist(const char *title, const char *artist)
1.8 -{
1.9 - static char buf[256]; // clearly not multi-thread save!
1.10 +static cString TitleArtist(const char *title, const char *artist)
1.11 +{
1.12 const char *fmt;
1.13 if(artist && artist[0]) {
1.14 if(MP3Setup.TitleArtistOrder) fmt="%2$s - %1$s";
1.15 else fmt="%s - %s";
1.16 }
1.17 else fmt="%s";
1.18 - snprintf(buf,sizeof(buf),fmt,title,artist);
1.19 - return buf;
1.20 + return cString::sprintf(fmt,title,artist);
1.21 }
1.22
1.23 // --- cMP3Control --------------------------------------------------------
1.24 @@ -214,7 +212,8 @@
1.25 cMP3Player *player;
1.26 bool visible, shown, bigwin, statusActive;
1.27 time_t timeoutShow, greentime, oktime;
1.28 - int lastkeytime, number;
1.29 + cTimeMs lastkeytime;
1.30 + int number;
1.31 bool selecting;
1.32 //
1.33 cMP3PlayInfo *lastMode;
1.34 @@ -254,7 +253,7 @@
1.35 {
1.36 visible=shown=bigwin=selecting=jumpactive=jumphide=statusActive=false;
1.37 timeoutShow=greentime=oktime=0;
1.38 - lastkeytime=number=0;
1.39 + number=0;
1.40 lastMode=0;
1.41 framesPerSecond=SecondsToFrames(1);
1.42 osd=0; disp=0;
1.43 @@ -449,7 +448,7 @@
1.44 if(valid) { // send progress to status monitor
1.45 if(changed || mode->Loop!=lastMode->Loop || mode->Shuffle!=lastMode->Shuffle) {
1.46 snprintf(buf,sizeof(buf),"[%c%c] (%d/%d) %s",
1.47 - mode->Loop?'L':'.',mode->Shuffle?'S':'.',mode->Num,mode->MaxNum,TitleArtist(mode->Title,mode->Artist));
1.48 + mode->Loop?'L':'.',mode->Shuffle?'S':'.',mode->Num,mode->MaxNum,*TitleArtist(mode->Title,mode->Artist));
1.49 cStatus::MsgReplaying(this,buf,mode->Filename[0]?mode->Filename:0,true);
1.50 }
1.51 }
1.52 @@ -519,7 +518,7 @@
1.53 flip=0;
1.54 // fall through
1.55 case 0:
1.56 - snprintf(buf,sizeof(buf),"%s",TitleArtist(mode->Title,mode->Artist));
1.57 + snprintf(buf,sizeof(buf),"%s",*TitleArtist(mode->Title,mode->Artist));
1.58 flipint=6;
1.59 break;
1.60 case 1:
1.61 @@ -566,7 +565,7 @@
1.62 for(int i=0 ; i<rows && i<MAXROWS && num<=mode->MaxNum ; i++,num++) {
1.63 cMP3PlayInfo pi;
1.64 mgr->Info(num,&pi); if(!pi.Title[0]) break;
1.65 - snprintf(buf,sizeof(buf),"%d.\t%s",num,TitleArtist(pi.Title,pi.Artist));
1.66 + snprintf(buf,sizeof(buf),"%d.\t%s",num,*TitleArtist(pi.Title,pi.Artist));
1.67 int fg=clrWhite, bg=clrGray50;
1.68 int hash=MakeHash(buf);
1.69 if(num==mode->Num) { fg=clrBlack; bg=clrCyan; hash=(hash^77) + 23; }
1.70 @@ -744,7 +743,7 @@
1.71 if(lastMode && number>0 && number<=lastMode->MaxNum) {
1.72 if(!visible) ShowTimed(SELECTHIDE_TIMEOUT);
1.73 else if(timeoutShow>0) timeoutShow=time(0)+SELECTHIDE_TIMEOUT;
1.74 - selecting=true; lastkeytime=time_ms();
1.75 + selecting=true; lastkeytime.Set(SELECT_TIMEOUT);
1.76 char buf[32];
1.77 if(MP3Setup.ReplayDisplay) {
1.78 snprintf(buf,sizeof(buf),"%s%d-/%d",trVDR("Jump: "),number,lastMode->MaxNum);
1.79 @@ -757,10 +756,10 @@
1.80 Flush();
1.81 break;
1.82 }
1.83 - number=0; lastkeytime=0;
1.84 + number=0; lastkeytime.Set();
1.85 // fall through
1.86 case kNone:
1.87 - if(selecting && time_ms()-lastkeytime>SELECT_TIMEOUT) {
1.88 + if(selecting && lastkeytime.TimedOut()) {
1.89 if(number>0) { mgr->Goto(number); player->Play(); }
1.90 if(lastMode) lastMode->Hash=-1;
1.91 number=0; selecting=false;
1.92 @@ -954,7 +953,7 @@
1.93 cSongInfo *si=song->Info(false);
1.94 if(showID3 && !si) si=song->Info();
1.95 if(showID3 && si && si->Title)
1.96 - asprintf(&buffer, "%d.\t%s",song->Index()+1,TitleArtist(si->Title,si->Artist));
1.97 + asprintf(&buffer, "%d.\t%s",song->Index()+1,*TitleArtist(si->Title,si->Artist));
1.98 else
1.99 asprintf(&buffer, "%d.\t<%s>",song->Index()+1,song->Name());
1.100 SetText(buffer,false);
1.101 @@ -995,7 +994,7 @@
1.102
1.103 void cMenuPlayList::Buttons(void)
1.104 {
1.105 - SetHelp(tr("Add"), showid3?tr("Filenames"):tr("ID3 names"), tr("Remove"), trVDR(BUTTON"Mark"));
1.106 + SetHelp(tr("Add"), showid3?tr("Filenames"):tr("ID3 names"), tr("Remove"), trVDR("Button$Mark"));
1.107 }
1.108
1.109 void cMenuPlayList::Refresh(bool all)
1.110 @@ -1213,10 +1212,10 @@
1.111 {
1.112 switch(num) {
1.113 case 1:
1.114 - SetHelp(trVDR(BUTTON"Edit"), tr("Source"), tr("Browse"), ">>");
1.115 + SetHelp(trVDR("Button$Edit"), tr("Source"), tr("Browse"), ">>");
1.116 break;
1.117 case 2:
1.118 - SetHelp("<<", trVDR(BUTTON"New"), trVDR(BUTTON"Delete"), tr("Rename"));
1.119 + SetHelp("<<", trVDR("Button$New"), trVDR("Button$Delete"), tr("Rename"));
1.120 break;
1.121 }
1.122 buttonnum=num; Display();
1.123 @@ -1355,7 +1354,7 @@
1.124
1.125 if(!second) {
1.126 instanting=true;
1.127 - return AddSubMenu(new cMenuInstantBrowse(MP3Sources.GetSource(),trVDR(BUTTON"Play"),tr("Play all")));
1.128 + return AddSubMenu(new cMenuInstantBrowse(MP3Sources.GetSource(),trVDR("Button$Play"),tr("Play all")));
1.129 }
1.130 instanting=false;
1.131 cFileObj *item=cMenuInstantBrowse::GetSelected();