1.1 --- a/mp3.c Tue Feb 03 12:28:53 2009 +0800
1.2 +++ b/mp3.c Tue Feb 03 20:33:04 2009 +0800
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * MP3/MPlayer plugin to VDR (C++)
1.6 *
1.7 - * (C) 2001-2007 Stefan Huelswitt <s.huelswitt@gmx.de>
1.8 + * (C) 2001-2009 Stefan Huelswitt <s.huelswitt@gmx.de>
1.9 *
1.10 * This code is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License
1.12 @@ -29,10 +29,8 @@
1.13 #include <vdr/menuitems.h>
1.14 #include <vdr/status.h>
1.15 #include <vdr/plugin.h>
1.16 -#if APIVERSNUM >= 10307
1.17 #include <vdr/interface.h>
1.18 #include <vdr/skins.h>
1.19 -#endif
1.20
1.21 #include "setup.h"
1.22 #include "setup-mp3.h"
1.23 @@ -88,11 +86,9 @@
1.24 Add(new cMenuEditStraItem(tr("Setup.MP3$Audio output mode"), &amode,numModes,aout));
1.25 Add(new cMenuEditBoolItem(tr("Setup.MP3$Audio mode"), &data.AudioMode, tr("Round"), tr("Dither")));
1.26 Add(new cMenuEditBoolItem(tr("Setup.MP3$Use 48kHz mode only"), &data.Only48kHz));
1.27 -#if APIVERSNUM >= 10307
1.28 disp[0]=tr("classic");
1.29 disp[1]=tr("via skin");
1.30 Add(new cMenuEditStraItem(tr("Setup.MP3$Replay display"), &data.ReplayDisplay, 2, disp));
1.31 -#endif
1.32 Add(new cMenuEditIntItem( tr("Setup.MP3$Display mode"), &data.DisplayMode, 1, 3));
1.33 bgr[0]=tr("Black");
1.34 bgr[1]=tr("Live");
1.35 @@ -147,9 +143,7 @@
1.36 SetupStore("CddbHost", MP3Setup.CddbHost );
1.37 SetupStore("CddbPort", MP3Setup.CddbPort );
1.38 SetupStore("AbortAtEOL", MP3Setup.AbortAtEOL );
1.39 -#if APIVERSNUM >= 10307
1.40 SetupStore("ReplayDisplay", MP3Setup.ReplayDisplay );
1.41 -#endif
1.42 SetupStore("HideMainMenu", MP3Setup.HideMainMenu );
1.43 SetupStore("KeepSelect", MP3Setup.KeepSelect );
1.44 SetupStore("TitleArtistOrder", MP3Setup.TitleArtistOrder);
1.45 @@ -208,25 +202,13 @@
1.46
1.47 // --- cMP3Control --------------------------------------------------------
1.48
1.49 -#if APIVERSNUM >= 10307
1.50 -#define clrBackground clrGray50
1.51 -#define eDvbColor int
1.52 #define MAXROWS 120
1.53 -#define INLINE
1.54 -#else
1.55 -#define MAXROWS MAXOSDHEIGHT
1.56 -#define INLINE inline
1.57 -#endif
1.58
1.59 class cMP3Control : public cControl {
1.60 private:
1.61 -#if APIVERSNUM >= 10307
1.62 cOsd *osd;
1.63 const cFont *font;
1.64 cSkinDisplayReplay *disp;
1.65 -#else
1.66 - bool statusInterfaceOpen;
1.67 -#endif
1.68 int bw, bh, bwc, fw, fh;
1.69 //
1.70 cMP3Player *player;
1.71 @@ -254,8 +236,8 @@
1.72 void JumpProcess(eKeys Key);
1.73 void Jump(void);
1.74 void Stop(void);
1.75 - INLINE void Write(int x, int y, int w, const char *text, eDvbColor fg=clrWhite, eDvbColor bg=clrBackground);
1.76 - INLINE void Fill(int x, int y, int w, int h, eDvbColor fg);
1.77 + void Write(int x, int y, int w, const char *text, int fg=clrWhite, int bg=clrGray50);
1.78 + void Fill(int x, int y, int w, int h, int fg);
1.79 inline void Flush(void);
1.80 public:
1.81 cMP3Control(void);
1.82 @@ -275,17 +257,9 @@
1.83 lastkeytime=number=0;
1.84 lastMode=0;
1.85 framesPerSecond=SecondsToFrames(1);
1.86 -#if APIVERSNUM >= 10307
1.87 osd=0; disp=0;
1.88 font=cFont::GetFont(fontOsd);
1.89 -#else
1.90 - statusInterfaceOpen=false;
1.91 -#endif
1.92 -#if APIVERSNUM >= 10338
1.93 cStatus::MsgReplaying(this,"MP3",0,true);
1.94 -#else
1.95 - cStatus::MsgReplaying(this,"MP3");
1.96 -#endif
1.97 }
1.98
1.99 cMP3Control::~cMP3Control()
1.100 @@ -297,11 +271,7 @@
1.101
1.102 void cMP3Control::Stop(void)
1.103 {
1.104 -#if APIVERSNUM >= 10338
1.105 cStatus::MsgReplaying(this,0,0,false);
1.106 -#else
1.107 - cStatus::MsgReplaying(this,0);
1.108 -#endif
1.109 delete player; player=0;
1.110 mgr->Halt();
1.111 mgr->Flush(); //XXX remove later
1.112 @@ -340,12 +310,8 @@
1.113 HideStatus();
1.114 timeoutShow=0;
1.115 if(visible) {
1.116 -#if APIVERSNUM >= 10307
1.117 delete osd; osd=0;
1.118 delete disp; disp=0;
1.119 -#else
1.120 - Interface->Close();
1.121 -#endif
1.122 visible=bigwin=false;
1.123 #if APIVERSNUM >= 10500
1.124 SetNeedsFastResponse(false);
1.125 @@ -360,7 +326,6 @@
1.126 if((asyncStatus.Changed() || (force && !statusActive)) && !jumpactive) {
1.127 const char *text=asyncStatus.Begin();
1.128 if(text) {
1.129 -#if APIVERSNUM >= 10307
1.130 if(MP3Setup.ReplayDisplay || !osd) {
1.131 if(statusActive) Skins.Message(mtStatus,0);
1.132 Skins.Message(mtStatus,text);
1.133 @@ -370,14 +335,6 @@
1.134 osd->DrawText(0,bh-2*fh,text,clrBlack,clrCyan,font,bw,fh,taCenter);
1.135 osd->Flush();
1.136 }
1.137 -#else
1.138 - if(!Interface->IsOpen()) {
1.139 - Interface->Open(0,-1);
1.140 - statusInterfaceOpen=true;
1.141 - }
1.142 - Interface->Status(text);
1.143 - Interface->Flush();
1.144 -#endif
1.145 statusActive=true;
1.146 }
1.147 else
1.148 @@ -389,23 +346,12 @@
1.149 void cMP3Control::HideStatus(void)
1.150 {
1.151 if(statusActive) {
1.152 -#if APIVERSNUM >= 10307
1.153 if(MP3Setup.ReplayDisplay || !osd)
1.154 Skins.Message(mtStatus,0);
1.155 else {
1.156 osd->RestoreRegion();
1.157 osd->Flush();
1.158 }
1.159 -#else
1.160 - if(statusInterfaceOpen) {
1.161 - Interface->Close();
1.162 - statusInterfaceOpen=false;
1.163 - }
1.164 - else {
1.165 - Interface->Status(0);
1.166 - Interface->Flush();
1.167 - }
1.168 -#endif
1.169 }
1.170 statusActive=false;
1.171 }
1.172 @@ -413,45 +359,28 @@
1.173 #define CTAB 11 // some tabbing values for the progress display
1.174 #define CTAB2 5
1.175
1.176 -void cMP3Control::Write(int x, int y, int w, const char *text, eDvbColor fg, eDvbColor bg)
1.177 -{
1.178 -#if APIVERSNUM >= 10307
1.179 +void cMP3Control::Write(int x, int y, int w, const char *text, int fg, int bg)
1.180 +{
1.181 if(osd) {
1.182 - //d(printf("write x=%d y=%d w=%d ->",x,y,w))
1.183 x*=fw; if(x<0) x+=bw;
1.184 y*=fh; if(y<0) y+=bh;
1.185 osd->DrawText(x,y,text,fg,bg,font,w*fw);
1.186 - //d(printf(" x=%d y=%d w=%d\n",x,y,w*fw))
1.187 - }
1.188 -#else
1.189 - if(w>0) Fill(x,y,w,1,bg);
1.190 - Interface->Write(x,y,text,fg,bg);
1.191 -#endif
1.192 -}
1.193 -
1.194 -void cMP3Control::Fill(int x, int y, int w, int h, eDvbColor fg)
1.195 -{
1.196 -#if APIVERSNUM >= 10307
1.197 + }
1.198 +}
1.199 +
1.200 +void cMP3Control::Fill(int x, int y, int w, int h, int fg)
1.201 +{
1.202 if(osd) {
1.203 - //d(printf("fill x=%d y=%d w=%d h=%d ->",x,y,w,h))
1.204 x*=fw; if(x<0) x+=bw;
1.205 y*=fh; if(y<0) y+=bh;
1.206 osd->DrawRectangle(x,y,x+w*fw-1,y+h*fh-1,fg);
1.207 - //d(printf(" x=%d y=%d x2=%d y2=%d\n",x,y,x+h*fh-1,y+w*fw-1))
1.208 - }
1.209 -#else
1.210 - Interface->Fill(x,y,w,h,fg);
1.211 -#endif
1.212 + }
1.213 }
1.214
1.215 void cMP3Control::Flush(void)
1.216 {
1.217 -#if APIVERSNUM >= 10307
1.218 if(MP3Setup.ReplayDisplay) Skins.Flush();
1.219 else if(osd) osd->Flush();
1.220 -#else
1.221 - Interface->Flush();
1.222 -#endif
1.223 }
1.224
1.225 void cMP3Control::ShowProgress(bool open, bool bigWin)
1.226 @@ -461,7 +390,6 @@
1.227 if(player->GetIndex(index,total) && total>=0) {
1.228 if(!visible && open) {
1.229 HideStatus();
1.230 -#if APIVERSNUM >= 10307
1.231 if(MP3Setup.ReplayDisplay) {
1.232 disp=Skins.Current()->DisplayReplay(false);
1.233 if(!disp) return;
1.234 @@ -500,15 +428,6 @@
1.235 osd->DrawRectangle(0,0,bw-1,bh-1,clrGray50);
1.236 osd->Flush();
1.237 }
1.238 -#else
1.239 - fw=cOsd::CellWidth();
1.240 - fh=cOsd::LineHeight();
1.241 - bh=bigWin ? Setup.OSDheight : -2;
1.242 - bw=bwc=Setup.OSDwidth;
1.243 - rows=Setup.OSDheight-3;
1.244 - Interface->Open(bw,bh);
1.245 - Interface->Clear();
1.246 -#endif
1.247 ShowStatus(true);
1.248 bigwin=bigWin;
1.249 visible=true;
1.250 @@ -531,18 +450,13 @@
1.251 if(changed || mode->Loop!=lastMode->Loop || mode->Shuffle!=lastMode->Shuffle) {
1.252 snprintf(buf,sizeof(buf),"[%c%c] (%d/%d) %s",
1.253 mode->Loop?'L':'.',mode->Shuffle?'S':'.',mode->Num,mode->MaxNum,TitleArtist(mode->Title,mode->Artist));
1.254 -#if APIVERSNUM >= 10338
1.255 cStatus::MsgReplaying(this,buf,mode->Filename[0]?mode->Filename:0,true);
1.256 -#else
1.257 - cStatus::MsgReplaying(this,buf);
1.258 -#endif
1.259 }
1.260 }
1.261
1.262 if(visible) { // refresh the OSD progress display
1.263 bool flush=false;
1.264
1.265 -#if APIVERSNUM >= 10307
1.266 if(MP3Setup.ReplayDisplay) {
1.267 if(!statusActive) {
1.268 if(total>0) disp->SetProgress(index,total);
1.269 @@ -556,7 +470,6 @@
1.270 }
1.271 }
1.272 else {
1.273 -#endif
1.274 if(!selecting && changed && !statusActive) {
1.275 snprintf(buf,sizeof(buf),"(%d/%d)",mode->Num,mode->MaxNum);
1.276 Write(0,-2,CTAB,buf);
1.277 @@ -565,33 +478,26 @@
1.278
1.279 if(!lastMode || mode->Loop!=lastMode->Loop) {
1.280 if(mode->Loop) Write(-4,-1,0,"L",clrBlack,clrYellow);
1.281 - else Fill(-4,-1,2,1,clrBackground);
1.282 + else Fill(-4,-1,2,1,clrGray50);
1.283 flush=true;
1.284 }
1.285 if(!lastMode || mode->Shuffle!=lastMode->Shuffle) {
1.286 if(mode->Shuffle) Write(-2,-1,0,"S",clrWhite,clrRed);
1.287 - else Fill(-2,-1,2,1,clrBackground);
1.288 + else Fill(-2,-1,2,1,clrGray50);
1.289 flush=true;
1.290 }
1.291
1.292 index/=framesPerSecond; total/=framesPerSecond;
1.293 if(index!=lastIndex || total!=lastTotal) {
1.294 if(total>0) {
1.295 -#if APIVERSNUM >= 10307
1.296 cProgressBar ProgressBar(bw-(CTAB+CTAB2)*fw,fh,index,total);
1.297 osd->DrawBitmap(CTAB*fw,bh-fh,ProgressBar);
1.298 -#else
1.299 - cProgressBar ProgressBar((bw-CTAB-CTAB2)*fw,fh,index,total);
1.300 - Interface->SetBitmap(CTAB*fw,(abs(bh)-1)*fh,ProgressBar);
1.301 -#endif
1.302 }
1.303 snprintf(buf,sizeof(buf),total?"%02d:%02d/%02d:%02d":"%02d:%02d",index/60,index%60,total/60,total%60);
1.304 Write(0,-1,11,buf);
1.305 flush=true;
1.306 }
1.307 -#if APIVERSNUM >= 10307
1.308 - }
1.309 -#endif
1.310 + }
1.311
1.312 if(!jumpactive) {
1.313 bool doflip=false;
1.314 @@ -632,7 +538,6 @@
1.315 break;
1.316 }
1.317 if(buf[0]) {
1.318 -#if APIVERSNUM >= 10307
1.319 if(MP3Setup.ReplayDisplay) {
1.320 char buf2[256];
1.321 snprintf(buf2,sizeof(buf2),"[%c%c] (%d/%d) %s",
1.322 @@ -641,15 +546,12 @@
1.323 flush=true;
1.324 }
1.325 else {
1.326 -#endif
1.327 if(!statusActive) {
1.328 DisplayInfo(buf);
1.329 flush=true;
1.330 }
1.331 else { d(printf("mp3-ctrl: display info skip due to status active\n")) }
1.332 -#if APIVERSNUM >= 10307
1.333 }
1.334 -#endif
1.335 }
1.336 }
1.337 }
1.338 @@ -665,7 +567,7 @@
1.339 cMP3PlayInfo pi;
1.340 mgr->Info(num,&pi); if(!pi.Title[0]) break;
1.341 snprintf(buf,sizeof(buf),"%d.\t%s",num,TitleArtist(pi.Title,pi.Artist));
1.342 - eDvbColor fg=clrWhite, bg=clrBackground;
1.343 + int fg=clrWhite, bg=clrGray50;
1.344 int hash=MakeHash(buf);
1.345 if(num==mode->Num) { fg=clrBlack; bg=clrCyan; hash=(hash^77) + 23; }
1.346 if(all || hash!=hashlist[i]) {
1.347 @@ -696,7 +598,7 @@
1.348 void cMP3Control::DisplayInfo(const char *s)
1.349 {
1.350 if(s) Write(CTAB,-2,bwc-CTAB,s);
1.351 - else Fill(CTAB,-2,bwc-CTAB,1,clrBackground);
1.352 + else Fill(CTAB,-2,bwc-CTAB,1,clrGray50);
1.353 }
1.354
1.355 void cMP3Control::JumpDisplay(void)
1.356 @@ -705,16 +607,12 @@
1.357 const char *j=trVDR("Jump: "), u=jumpsecs?'s':'m';
1.358 if(!jumpmm) sprintf(buf,"%s- %c", j,u);
1.359 else sprintf(buf,"%s%d- %c",j,jumpmm,u);
1.360 -#if APIVERSNUM >= 10307
1.361 if(MP3Setup.ReplayDisplay) {
1.362 disp->SetJump(buf);
1.363 }
1.364 else {
1.365 -#endif
1.366 DisplayInfo(buf);
1.367 -#if APIVERSNUM >= 10307
1.368 - }
1.369 -#endif
1.370 + }
1.371 }
1.372
1.373 void cMP3Control::JumpProcess(eKeys Key)
1.374 @@ -746,9 +644,7 @@
1.375
1.376 if(!jumpactive) {
1.377 if(jumphide) Hide();
1.378 -#if APIVERSNUM >= 10307
1.379 else if(MP3Setup.ReplayDisplay) disp->SetJump(0);
1.380 -#endif
1.381 }
1.382 }
1.383
1.384 @@ -769,29 +665,21 @@
1.385
1.386 if(timeoutShow && time(0)>timeoutShow) Hide();
1.387 ShowProgress();
1.388 -#if APIVERSNUM >= 10307
1.389 ShowStatus(Key==kNone && !Skins.IsOpen());
1.390 -#else
1.391 - ShowStatus(Key==kNone && !Interface->IsOpen());
1.392 -#endif
1.393
1.394 if(jumpactive && Key!=kNone) { JumpProcess(Key); return osContinue; }
1.395
1.396 switch(Key) {
1.397 case kUp:
1.398 case kUp|k_Repeat:
1.399 -#if APIVERSNUM >= 10347
1.400 case kNext:
1.401 case kNext|k_Repeat:
1.402 -#endif
1.403 mgr->Next(); player->Play();
1.404 break;
1.405 case kDown:
1.406 case kDown|k_Repeat:
1.407 -#if APIVERSNUM >= 10347
1.408 case kPrev:
1.409 case kPrev|k_Repeat:
1.410 -#endif
1.411 if(!player->PrevCheck()) mgr->Prev();
1.412 player->Play();
1.413 break;
1.414 @@ -848,12 +736,8 @@
1.415 return osEnd;
1.416 case kBack:
1.417 Hide();
1.418 -#if APIVERSNUM >= 10332
1.419 cRemote::CallPlugin(plugin_name);
1.420 return osBack;
1.421 -#else
1.422 - return osEnd;
1.423 -#endif
1.424
1.425 case k0 ... k9:
1.426 number=number*10+Key-k0;
1.427 @@ -862,18 +746,14 @@
1.428 else if(timeoutShow>0) timeoutShow=time(0)+SELECTHIDE_TIMEOUT;
1.429 selecting=true; lastkeytime=time_ms();
1.430 char buf[32];
1.431 -#if APIVERSNUM >= 10307
1.432 if(MP3Setup.ReplayDisplay) {
1.433 snprintf(buf,sizeof(buf),"%s%d-/%d",trVDR("Jump: "),number,lastMode->MaxNum);
1.434 disp->SetJump(buf);
1.435 }
1.436 else {
1.437 -#endif
1.438 snprintf(buf,sizeof(buf),"(%d-/%d)",number,lastMode->MaxNum);
1.439 Write(0,-2,CTAB,buf);
1.440 -#if APIVERSNUM >= 10307
1.441 }
1.442 -#endif
1.443 Flush();
1.444 break;
1.445 }
1.446 @@ -884,9 +764,7 @@
1.447 if(number>0) { mgr->Goto(number); player->Play(); }
1.448 if(lastMode) lastMode->Hash=-1;
1.449 number=0; selecting=false;
1.450 -#if APIVERSNUM >= 10307
1.451 if(MP3Setup.ReplayDisplay && disp) disp->SetJump(0);
1.452 -#endif
1.453 }
1.454 break;
1.455 case kOk:
1.456 @@ -970,11 +848,7 @@
1.457 char *buf=0;
1.458 asprintf(&buf,"%s:\t%s",name,text?text:"");
1.459 cOsdItem *item = new cOsdItem(buf,osBack);
1.460 -#if APIVERSNUM >= 10307
1.461 item->SetSelectable(false);
1.462 -#else
1.463 - item->SetColor(clrWhite, clrBackground);
1.464 -#endif
1.465 free(buf);
1.466 Add(item); return item;
1.467 }
1.468 @@ -1249,11 +1123,7 @@
1.469 char *buf=NULL;
1.470 asprintf(&buf,"%s\t%s",tr("Old name:"),oldname);
1.471 cOsdItem *old = new cOsdItem(buf,osContinue);
1.472 -#if APIVERSNUM >= 10307
1.473 old->SetSelectable(false);
1.474 -#else
1.475 - old->SetColor(clrWhite, clrBackground);
1.476 -#endif
1.477 Add(old);
1.478 free(buf);
1.479
1.480 @@ -1544,9 +1414,7 @@
1.481
1.482 class cPluginMp3 : public cPlugin {
1.483 private:
1.484 -#if APIVERSNUM >= 10330
1.485 bool ExternalPlay(const char *path, bool test);
1.486 -#endif
1.487 public:
1.488 cPluginMp3(void);
1.489 virtual ~cPluginMp3();
1.490 @@ -1554,23 +1422,15 @@
1.491 virtual const char *Description(void) { return tr(DESCRIPTION); }
1.492 virtual const char *CommandLineHelp(void);
1.493 virtual bool ProcessArgs(int argc, char *argv[]);
1.494 -#if APIVERSNUM >= 10131
1.495 virtual bool Initialize(void);
1.496 -#else
1.497 - virtual bool Start(void);
1.498 -#endif
1.499 virtual void Housekeeping(void);
1.500 virtual const char *MainMenuEntry(void);
1.501 virtual cOsdObject *MainMenuAction(void);
1.502 virtual cMenuSetupPage *SetupMenu(void);
1.503 virtual bool SetupParse(const char *Name, const char *Value);
1.504 -#if APIVERSNUM >= 10330
1.505 virtual bool Service(const char *Id, void *Data);
1.506 -#if APIVERSNUM >= 10331
1.507 virtual const char **SVDRPHelpPages(void);
1.508 virtual cString SVDRPCommand(const char *Command, const char *Option, int &ReplyCode);
1.509 -#endif
1.510 -#endif
1.511 };
1.512
1.513 cPluginMp3::cPluginMp3(void)
1.514 @@ -1673,13 +1533,9 @@
1.515 return true;
1.516 }
1.517
1.518 -#if APIVERSNUM >= 10131
1.519 bool cPluginMp3::Initialize(void)
1.520 -#else
1.521 -bool cPluginMp3::Start(void)
1.522 -#endif
1.523 -{
1.524 - if(!CheckVDRVersion(1,1,29,"mp3")) return false;
1.525 +{
1.526 + if(!CheckVDRVersion(1,4,5,"mp3")) return false;
1.527 plugin_name="mp3";
1.528 #if APIVERSNUM < 10507
1.529 i18n_name="mp3";
1.530 @@ -1756,9 +1612,7 @@
1.531 }
1.532 #endif
1.533 }
1.534 -#if APIVERSNUM >= 10307
1.535 else if (!strcasecmp(Name, "ReplayDisplay")) MP3Setup.ReplayDisplay = atoi(Value);
1.536 -#endif
1.537 else if (!strcasecmp(Name, "HideMainMenu")) MP3Setup.HideMainMenu = atoi(Value);
1.538 else if (!strcasecmp(Name, "KeepSelect")) MP3Setup.KeepSelect = atoi(Value);
1.539 else if (!strcasecmp(Name, "TitleArtistOrder")) MP3Setup.TitleArtistOrder = atoi(Value);
1.540 @@ -1766,8 +1620,6 @@
1.541 return true;
1.542 }
1.543
1.544 -#if APIVERSNUM >= 10330
1.545 -
1.546 bool cPluginMp3::ExternalPlay(const char *path, bool test)
1.547 {
1.548 char real[PATH_MAX+1];
1.549 @@ -1821,8 +1673,6 @@
1.550 return false;
1.551 }
1.552
1.553 -#if APIVERSNUM >= 10331
1.554 -
1.555 const char **cPluginMp3::SVDRPHelpPages(void)
1.556 {
1.557 static const char *HelpPages[] = {
1.558 @@ -1865,7 +1715,4 @@
1.559 return NULL;
1.560 }
1.561
1.562 -#endif // 1.3.31
1.563 -#endif // 1.3.30
1.564 -
1.565 VDRPLUGINCREATOR(cPluginMp3); // Don't touch this!