data-mp3.c
author nathan
Tue, 03 Feb 2009 20:33:04 +0800
branchtrunk
changeset 22 93aaf15c145a
parent 19 306cc35c7faa
child 29 640ce9201139
permissions -rw-r--r--
remove compatibility for VDR < 1.4.5
nathan@0
     1
/*
nathan@0
     2
 * MP3/MPlayer plugin to VDR (C++)
nathan@0
     3
 *
nathan@22
     4
 * (C) 2001-2009 Stefan Huelswitt <s.huelswitt@gmx.de>
nathan@0
     5
 *
nathan@0
     6
 * This code is free software; you can redistribute it and/or
nathan@0
     7
 * modify it under the terms of the GNU General Public License
nathan@0
     8
 * as published by the Free Software Foundation; either version 2
nathan@0
     9
 * of the License, or (at your option) any later version.
nathan@0
    10
 *
nathan@0
    11
 * This code is distributed in the hope that it will be useful,
nathan@0
    12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nathan@0
    13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nathan@0
    14
 * GNU General Public License for more details.
nathan@0
    15
 *
nathan@0
    16
 * You should have received a copy of the GNU General Public License
nathan@0
    17
 * along with this program; if not, write to the Free Software
nathan@0
    18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
nathan@0
    19
 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
nathan@0
    20
 */
nathan@0
    21
nathan@0
    22
#include <stdlib.h>
nathan@0
    23
#include <stdio.h>
nathan@0
    24
#include <unistd.h>
nathan@0
    25
nathan@0
    26
#include "common.h"
nathan@0
    27
#include "data-mp3.h"
nathan@0
    28
#include "data.h"
nathan@0
    29
#include "decoder.h"
nathan@0
    30
nathan@0
    31
#define DEBUG_IMAGE
nathan@0
    32
nathan@0
    33
#ifdef DEBUG_IMAGE
nathan@0
    34
#define di(x) { (x); }
nathan@0
    35
#else
nathan@0
    36
#define di(x) ; 
nathan@0
    37
#endif
nathan@0
    38
nathan@0
    39
const char *imagecache = "/var/cache/images/mp3";
nathan@0
    40
const char *imageconv  = "image_convert.sh";
nathan@19
    41
const char *def_usr_img = 0;
nathan@0
    42
nathan@0
    43
// image suffixes to search
nathan@0
    44
const char *img_suff[] = { "jpg","png","gif",0 };
nathan@0
    45
// exclude list for instant playlist creation
nathan@0
    46
const char *excl_pl[] = { "*"PLAYLISTEXT,"*.jpg","*.gif","*.png",0 };
nathan@0
    47
// exclude list for song browser
nathan@0
    48
const char *excl_br[] = { ".*","*.jpg","*.gif","*.png",0 };
nathan@0
    49
nathan@0
    50
// --- cImageConvert -----------------------------------------------------------
nathan@0
    51
nathan@0
    52
class cImageConvert : private cThread {
nathan@0
    53
private:
nathan@0
    54
  char *image;
nathan@0
    55
  enum eStatus { stNone, stRun, stFin };
nathan@0
    56
  eStatus status;
nathan@0
    57
protected:
nathan@0
    58
  virtual void Action(void);
nathan@0
    59
public:
nathan@0
    60
  cImageConvert(void);
nathan@0
    61
  ~cImageConvert();
nathan@0
    62
  bool Convert(const char *Image);
nathan@0
    63
  bool Status(void);
nathan@0
    64
  };
nathan@0
    65
nathan@0
    66
cImageConvert::cImageConvert(void)
nathan@0
    67
{
nathan@0
    68
  image=0; status=stNone;
nathan@0
    69
}
nathan@0
    70
nathan@0
    71
cImageConvert::~cImageConvert()
nathan@0
    72
{
nathan@0
    73
  if(status==stRun) Cancel(10);
nathan@0
    74
  free(image);
nathan@0
    75
}
nathan@0
    76
nathan@0
    77
bool cImageConvert::Convert(const char *Image)
nathan@0
    78
{
nathan@0
    79
  if(status==stNone) {
nathan@0
    80
    image=strdup(Image);
nathan@0
    81
    status=stRun;
nathan@0
    82
    Start();
nathan@0
    83
    return true;
nathan@0
    84
    }
nathan@0
    85
  return false;
nathan@0
    86
}
nathan@0
    87
nathan@0
    88
bool cImageConvert::Status(void)
nathan@0
    89
{
nathan@0
    90
  if(status==stRun && !Active()) status=stFin;
nathan@0
    91
  return status==stFin;
nathan@0
    92
}
nathan@0
    93
nathan@0
    94
void cImageConvert::Action(void)
nathan@0
    95
{
nathan@0
    96
  nice(3);
nathan@0
    97
  char *m, *cmd, *qp, *qm;
nathan@0
    98
  asprintf(&m,"%s%s.mpg",imagecache,image);
nathan@0
    99
  di(printf("image: convert started %s -> %s\n",image,m))
nathan@0
   100
  asprintf(&cmd,"%s \"%s\" \"%s\"",imageconv,qp=Quote(image),qm=Quote(m));
nathan@0
   101
  int r=system(cmd);
nathan@0
   102
  if(r!=0) di(printf("image: convert returned with code %d. Failed?\n",r))
nathan@0
   103
  free(cmd); free(qp); free(qm); free(m);
nathan@0
   104
  di(printf("image: convert finished\n"))
nathan@0
   105
  status=stFin;
nathan@0
   106
}
nathan@0
   107
nathan@0
   108
// --- cSong -------------------------------------------------------------------
nathan@0
   109
nathan@0
   110
cSong::cSong(cFileObj *Obj)
nathan@0
   111
{
nathan@0
   112
  obj=new cFileObj(Obj);
nathan@0
   113
  Init();
nathan@0
   114
}
nathan@0
   115
nathan@0
   116
cSong::cSong(cFileSource *Source, const char *Subdir, const char *Name)
nathan@0
   117
{
nathan@0
   118
  obj=new cFileObj(Source,Subdir,Name,otFile);
nathan@0
   119
  Init();
nathan@0
   120
}
nathan@0
   121
nathan@0
   122
cSong::cSong(cSong *Song)
nathan@0
   123
{
nathan@0
   124
  obj=new cFileObj(Song->obj);
nathan@0
   125
  Init();
nathan@0
   126
}
nathan@0
   127
nathan@0
   128
cSong::~cSong()
nathan@0
   129
{
nathan@0
   130
  delete conv;
nathan@0
   131
  delete decoder;
nathan@0
   132
  obj->Source()->Unblock();
nathan@0
   133
  delete obj;
nathan@0
   134
  free((char *)image);
nathan@0
   135
}
nathan@0
   136
nathan@0
   137
void cSong::Init(void)
nathan@0
   138
{
nathan@0
   139
  decoder=0; user=0; image=0; conv=0; queueStat=0;
nathan@0
   140
  fromDOS=decoderFailed=false;
nathan@0
   141
  obj->Source()->Block();
nathan@0
   142
}
nathan@0
   143
nathan@0
   144
int cSong::Compare(const cListObject &ListObject) const
nathan@0
   145
{
nathan@0
   146
  cSong *song=(cSong *)&ListObject;
nathan@0
   147
  return strcasecmp(obj->Path(),song->obj->Path());
nathan@0
   148
}
nathan@0
   149
nathan@0
   150
cSongInfo *cSong::Info(bool get)
nathan@0
   151
{
nathan@0
   152
  Decoder();
nathan@0
   153
  cSongInfo *si=0;
nathan@0
   154
  if(decoder) si=decoder->SongInfo(get);
nathan@0
   155
  return si;
nathan@0
   156
}
nathan@0
   157
nathan@0
   158
cDecoder *cSong::Decoder(void)
nathan@0
   159
{
nathan@0
   160
  decLock.Lock();
nathan@0
   161
  if(!decoder && !decoderFailed) {
nathan@0
   162
    decoder=cDecoders::FindDecoder(obj);
nathan@0
   163
    if(!decoder) decoderFailed=true;
nathan@0
   164
    }
nathan@0
   165
  decLock.Unlock();
nathan@0
   166
  return decoder;
nathan@0
   167
}
nathan@0
   168
nathan@0
   169
void cSong::Convert(void)
nathan@0
   170
{
nathan@0
   171
  char *Name=Convert2Unix(obj->Name());
nathan@0
   172
  obj->SetName(Name);
nathan@0
   173
  fromDOS=true;
nathan@0
   174
  free(Name);
nathan@0
   175
}
nathan@0
   176
nathan@0
   177
char *cSong::Convert2Unix(const char *name) const
nathan@0
   178
{
nathan@0
   179
  char *Name=strdup(name);
nathan@0
   180
  char *p=Name;
nathan@0
   181
  while(*p) {
nathan@0
   182
    if(*p=='/') *p='?';
nathan@0
   183
    if(*p=='\\') *p='/';
nathan@0
   184
    p++;
nathan@0
   185
    }
nathan@0
   186
  return Name;
nathan@0
   187
}
nathan@0
   188
nathan@0
   189
/*
nathan@0
   190
char *cSong::Convert2Dos(const char *name)
nathan@0
   191
{
nathan@0
   192
  char *Name=strdup(name);
nathan@0
   193
  char *p=Name;
nathan@0
   194
  while(*p) {
nathan@0
   195
    if(*p=='\\') *p='?';
nathan@0
   196
    if(*p=='/') *p='\\';
nathan@0
   197
    p++;
nathan@0
   198
    }
nathan@0
   199
  return Name;
nathan@0
   200
}
nathan@0
   201
*/
nathan@0
   202
nathan@0
   203
bool cSong::Parse(char *s, const char *reldir) const
nathan@0
   204
{
nathan@0
   205
  s=skipspace(stripspace(s));
nathan@0
   206
  if(*s) {
nathan@0
   207
    if(s[0]=='/' || !reldir)
nathan@0
   208
      obj->SplitAndSet(s);
nathan@0
   209
    else {
nathan@0
   210
      s=AddPath(reldir,s);
nathan@0
   211
      obj->SplitAndSet(s);
nathan@0
   212
      free(s);
nathan@0
   213
      }
nathan@0
   214
    return true;
nathan@0
   215
    }
nathan@0
   216
  return false;
nathan@0
   217
}
nathan@0
   218
nathan@0
   219
bool cSong::Save(FILE *f, const char *reldir) const
nathan@0
   220
{
nathan@0
   221
  const char *path=obj->Path();
nathan@0
   222
  if(reldir) {
nathan@0
   223
    int l=strlen(reldir);
nathan@0
   224
    if(!strncasecmp(path,reldir,l)) path+=l+1;
nathan@0
   225
    }
nathan@0
   226
  return fprintf(f,"%s\n",path)>0;
nathan@0
   227
}
nathan@0
   228
nathan@0
   229
bool cSong::FindImage(void)
nathan@0
   230
{
nathan@0
   231
  if(image) return true;
nathan@0
   232
nathan@0
   233
  char base[strlen(obj->Path())+32];
nathan@0
   234
  strcpy(base,obj->Path());
nathan@0
   235
  di(printf("image: checking image for %s\n",obj->Path()))
nathan@0
   236
nathan@0
   237
  // song specific image
nathan@0
   238
  char *m=rindex(base,'.');
nathan@0
   239
  if(m) *m=0;
nathan@0
   240
  if((image=CheckImage(base))) return true;
nathan@0
   241
nathan@0
   242
  // album specific image in song directory
nathan@0
   243
  if(!(m=rindex(base,'/'))) m=base-1;
nathan@0
   244
  strcpy(m+1,"cover");
nathan@0
   245
  if((image=CheckImage(base))) return true;
nathan@0
   246
nathan@0
   247
  // artist specific image in parent directory
nathan@0
   248
  if((m=rindex(base,'/'))) {
nathan@0
   249
    *m=0;
nathan@0
   250
    if(!(m=rindex(base,'/'))) m=base-1;
nathan@0
   251
    strcpy(m+1,"artist");
nathan@0
   252
    if((image=CheckImage(base))) return true;
nathan@0
   253
    }
nathan@0
   254
nathan@0
   255
  // default image in source basedir
nathan@0
   256
  if((image=CheckImage("background"))) return true;
nathan@0
   257
nathan@19
   258
  // default user supplied image
nathan@19
   259
  if(def_usr_img && (image=strdup(def_usr_img))) return true;
nathan@19
   260
nathan@0
   261
  di(printf("image: no image for %s\n",obj->Path()))
nathan@0
   262
  return false;
nathan@0
   263
}
nathan@0
   264
nathan@0
   265
const char *cSong::CheckImage(const char *base) const
nathan@0
   266
{
nathan@0
   267
  char *p;
nathan@0
   268
  int n;
nathan@0
   269
  asprintf(&p,"%s/%s.%n     ",obj->Source()->BaseDir(),base,&n);
nathan@0
   270
  for(const char **s=img_suff; *s; s++) {
nathan@0
   271
#ifdef DEBUG
nathan@0
   272
    if(strlen(*s)>5) printf("ERROR: buffer overflow in CheckImage ext=%s\n",*s);
nathan@0
   273
#endif
nathan@0
   274
    strcpy(&p[n],*s);
nathan@0
   275
    di(printf("image: check %s\n",p))
nathan@0
   276
    if(!access(p,R_OK)) {
nathan@0
   277
      di(printf("image: found\n"))
nathan@0
   278
      return p;
nathan@0
   279
      }
nathan@0
   280
    }
nathan@0
   281
  free(p);
nathan@0
   282
  return 0;
nathan@0
   283
}
nathan@0
   284
nathan@0
   285
#include "data-mp3-image.c"
nathan@0
   286
extern void PropagateImage(const char *image);
nathan@0
   287
nathan@0
   288
bool cSong::Image(unsigned char * &mem, int &len)
nathan@0
   289
{
nathan@0
   290
  mem=0;
nathan@0
   291
  if(queueStat>0) {
nathan@0
   292
    if(!conv->Status()) {
nathan@0
   293
      di(printf("image: still queued\n"))
nathan@0
   294
      return false;
nathan@0
   295
      }
nathan@0
   296
    queueStat=-1;
nathan@0
   297
    delete conv; conv=0;
nathan@0
   298
    }
nathan@0
   299
nathan@0
   300
  int res=0;
nathan@0
   301
  if(image || FindImage()) {
nathan@0
   302
    di(printf("image: loading image %s\n",image))
nathan@0
   303
    char *m;
nathan@0
   304
    asprintf(&m,"%s%s.mpg",imagecache,image);
nathan@0
   305
    if(access(m,R_OK)) {
nathan@0
   306
      di(printf("image: not cached\n"))
nathan@0
   307
      if(queueStat<0) {
nathan@0
   308
        di(printf("image: obviously convert failed...\n"))
nathan@0
   309
        }
nathan@0
   310
      else {
nathan@0
   311
        if(!conv) conv=new cImageConvert;
nathan@0
   312
        if(conv && conv->Convert(image)) {
nathan@0
   313
          di(printf("image: convert queued\n"))
nathan@0
   314
          queueStat=1;
nathan@0
   315
          res=-1;
nathan@0
   316
          }
nathan@0
   317
        else {
nathan@0
   318
          di(printf("image: queueing failed\n"))
nathan@0
   319
          queueStat=-1;
nathan@0
   320
          }
nathan@0
   321
        }
nathan@0
   322
      }
nathan@0
   323
    else {
nathan@0
   324
      di(printf("image: cached\n"))
nathan@0
   325
      int f=open(m,O_RDONLY);
nathan@0
   326
      if(f>=0) {
nathan@0
   327
        struct stat64 st;
nathan@0
   328
        fstat64(f,&st);
nathan@0
   329
        len=st.st_size;
nathan@0
   330
        mem=MALLOC(unsigned char,len);
nathan@0
   331
        if(mem) {
nathan@0
   332
          if(read(f,mem,len)==len) res=1;
nathan@0
   333
          else free(mem);
nathan@0
   334
          }
nathan@0
   335
        close(f);
nathan@0
   336
        }
nathan@0
   337
      }
nathan@0
   338
    free(m);
nathan@0
   339
    }
nathan@0
   340
nathan@0
   341
  PropagateImage(res==1 ? image : 0);
nathan@0
   342
nathan@0
   343
  if(res<=0) {
nathan@0
   344
    di(printf("image: using static default image\n"))
nathan@0
   345
    len=sizeof(defaultImage);
nathan@0
   346
    mem=MALLOC(unsigned char,len);
nathan@0
   347
    if(mem) {
nathan@0
   348
      memcpy(mem,defaultImage,len);
nathan@0
   349
      }
nathan@0
   350
    }
nathan@0
   351
  return res>=0;
nathan@0
   352
}
nathan@0
   353
nathan@0
   354
// -- cPlayList --------------------------------------------------------------
nathan@0
   355
nathan@0
   356
cPlayList::cPlayList(cFileObj *Obj)
nathan@0
   357
{
nathan@0
   358
  obj=new cFileObj(Obj);
nathan@0
   359
  Init();
nathan@0
   360
}
nathan@0
   361
nathan@0
   362
cPlayList::cPlayList(cFileSource *Source, const char *Subdir, const char *Name)
nathan@0
   363
{
nathan@0
   364
  obj=new cFileObj(Source,Subdir,Name,otFile);
nathan@0
   365
  Init();
nathan@0
   366
}
nathan@0
   367
nathan@0
   368
cPlayList::cPlayList(cPlayList *List)
nathan@0
   369
{
nathan@0
   370
  obj=new cFileObj(List->obj);
nathan@0
   371
  Init();
nathan@0
   372
}
nathan@0
   373
nathan@0
   374
cPlayList::~cPlayList()
nathan@0
   375
{
nathan@0
   376
  free(basename);
nathan@0
   377
  free(extbuffer);
nathan@0
   378
  obj->Source()->Unblock();
nathan@0
   379
  delete obj;
nathan@0
   380
}
nathan@0
   381
nathan@0
   382
void cPlayList::Init(void)
nathan@0
   383
{
nathan@0
   384
  extbuffer=basename=0;
nathan@0
   385
  isWinAmp=false;
nathan@0
   386
  obj->Source()->Block();
nathan@0
   387
  Set();
nathan@0
   388
}
nathan@0
   389
nathan@0
   390
void cPlayList::Set(void)
nathan@0
   391
{
nathan@0
   392
  free(basename); basename=0;
nathan@0
   393
  if(obj->Name()) {
nathan@0
   394
    basename=strdup(obj->Name());
nathan@0
   395
    int l=strlen(basename)-strlen(PLAYLISTEXT);
nathan@0
   396
    if(l>0 && !strcasecmp(basename+l,PLAYLISTEXT)) basename[l]=0;
nathan@0
   397
    }
nathan@0
   398
}
nathan@0
   399
nathan@0
   400
int cPlayList::Compare(const cListObject &ListObject) const
nathan@0
   401
{
nathan@0
   402
  cPlayList *list=(cPlayList *)&ListObject;
nathan@0
   403
  return strcasecmp(obj->Name(),list->obj->Name());
nathan@0
   404
}
nathan@0
   405
nathan@0
   406
bool cPlayList::Load(void)
nathan@0
   407
{
nathan@0
   408
  Clear();
nathan@0
   409
  bool result=false;
nathan@0
   410
  FILE *f=fopen(obj->FullPath(),"r");
nathan@0
   411
  if(f) {
nathan@0
   412
    char buffer[512];
nathan@0
   413
    result=true;
nathan@0
   414
    while(fgets(buffer,sizeof(buffer),f)>0) {
nathan@0
   415
      if(buffer[0]=='#') {
nathan@0
   416
        if(!strncmp(buffer,WINAMPEXT,strlen(WINAMPEXT))) {
nathan@0
   417
          d(printf("mp3: detected WinAmp style playlist\n"))
nathan@0
   418
          isWinAmp=true;
nathan@0
   419
          }
nathan@0
   420
        continue;
nathan@0
   421
        }
nathan@0
   422
      if(!isempty(buffer)) {
nathan@0
   423
        cSong *song=new cSong(obj->Source(),0,0);
nathan@0
   424
        if(song->Parse(buffer,obj->Subdir())) Add(song);
nathan@0
   425
        else {
nathan@0
   426
          esyslog("error loading playlist %s\n",obj->FullPath());
nathan@0
   427
          delete song;
nathan@0
   428
          result=false;
nathan@0
   429
          break;
nathan@0
   430
          }
nathan@0
   431
        }
nathan@0
   432
      }
nathan@0
   433
    fclose(f);
nathan@0
   434
    }
nathan@0
   435
  else LOG_ERROR_STR(obj->FullPath());
nathan@0
   436
nathan@0
   437
  if(result && isWinAmp) {
nathan@0
   438
    cSong *song=First();
nathan@0
   439
    while(song) {   // if this is a WinAmp playlist, convert \ to /
nathan@0
   440
      song->Convert();
nathan@0
   441
      song=cList<cSong>::Next(song);
nathan@0
   442
      }
nathan@0
   443
    }
nathan@0
   444
  return result;
nathan@0
   445
}
nathan@0
   446
nathan@0
   447
bool cPlayList::Save(void)
nathan@0
   448
{
nathan@0
   449
  bool result=true;
nathan@0
   450
  cSafeFile f(obj->FullPath());
nathan@0
   451
  if(f.Open()) {
nathan@0
   452
    cSong *song=First();
nathan@0
   453
    while(song) {
nathan@0
   454
      if(!song->Save(f,obj->Subdir())) {
nathan@0
   455
         result=false;
nathan@0
   456
         break;
nathan@0
   457
         }
nathan@0
   458
      song=cList<cSong>::Next(song);
nathan@0
   459
      }
nathan@0
   460
    if(!f.Close()) result=false;
nathan@0
   461
    }
nathan@0
   462
  else result=false;
nathan@0
   463
  return result;
nathan@0
   464
}
nathan@0
   465
 
nathan@0
   466
bool cPlayList::Exists(void)
nathan@0
   467
{
nathan@0
   468
  return obj->Exists();
nathan@0
   469
}
nathan@0
   470
nathan@0
   471
bool cPlayList::TestName(const char *newName)
nathan@0
   472
{
nathan@0
   473
  return obj->TestName(AddExt(newName,PLAYLISTEXT));
nathan@0
   474
}
nathan@0
   475
nathan@0
   476
bool cPlayList::Rename(const char *newName)
nathan@0
   477
{
nathan@0
   478
  bool r=obj->Rename(AddExt(newName,PLAYLISTEXT));
nathan@0
   479
  if(r) Set();
nathan@0
   480
  return r;
nathan@0
   481
}
nathan@0
   482
nathan@0
   483
bool cPlayList::Create(const char *newName)
nathan@0
   484
{
nathan@0
   485
  bool r=obj->Create(AddExt(newName,PLAYLISTEXT));
nathan@0
   486
  if(r) {
nathan@0
   487
    Set();
nathan@0
   488
    r=Load();
nathan@0
   489
    }
nathan@0
   490
  return r;
nathan@0
   491
}
nathan@0
   492
nathan@0
   493
bool cPlayList::Delete(void)
nathan@0
   494
{
nathan@0
   495
  return obj->Delete();
nathan@0
   496
}
nathan@0
   497
nathan@0
   498
const char *cPlayList::AddExt(const char *FileName, const char *Ext)
nathan@0
   499
{
nathan@0
   500
  free(extbuffer); extbuffer=0;
nathan@0
   501
  asprintf(&extbuffer,"%s%s",FileName,Ext);
nathan@0
   502
  return extbuffer;
nathan@0
   503
}
nathan@0
   504
nathan@0
   505
// -- cInstantPlayList ------------------------------------------------------
nathan@0
   506
nathan@0
   507
cInstantPlayList::cInstantPlayList(cFileObj *Obj)
nathan@0
   508
:cPlayList(Obj)
nathan@0
   509
{
nathan@0
   510
  if(!Obj->Name()) Obj->SetName("instant");
nathan@0
   511
}
nathan@0
   512
nathan@0
   513
bool cInstantPlayList::Load(void)
nathan@0
   514
{
nathan@0
   515
  bool res=false;
nathan@0
   516
  Clear();
nathan@0
   517
  switch(obj->Type()) {
nathan@0
   518
    case otFile:
nathan@0
   519
      d(printf("instant: file %s\n",obj->Name()))
nathan@0
   520
      if(strcasecmp(obj->Name(),basename)) {
nathan@0
   521
        d(printf("instant: detected as playlist\n"))
nathan@0
   522
        res=cPlayList::Load();
nathan@0
   523
        }
nathan@0
   524
      else {
nathan@0
   525
        Add(new cSong(obj));
nathan@0
   526
        res=true;
nathan@0
   527
        }
nathan@0
   528
      break;
nathan@0
   529
    case otDir:
nathan@0
   530
      {
nathan@0
   531
      d(printf("instant: dir %s\n",obj->Name()))
nathan@0
   532
      res=ScanDir(obj->Source(),obj->Path(),stFile,obj->Source()->Include(),excl_pl,true);
nathan@0
   533
      Sort();
nathan@0
   534
      break;
nathan@0
   535
      }
nathan@0
   536
    case otBase:
nathan@0
   537
      d(printf("instant: base\n"))
nathan@0
   538
      res=ScanDir(obj->Source(),0,stFile,obj->Source()->Include(),excl_pl,true);
nathan@0
   539
      Sort();
nathan@0
   540
      break;
nathan@0
   541
    default: break;
nathan@0
   542
    }
nathan@0
   543
  return res;
nathan@0
   544
}
nathan@0
   545
nathan@0
   546
void cInstantPlayList::DoItem(cFileSource *src, const char *subdir, const char *name)
nathan@0
   547
{
nathan@0
   548
  Add(new cSong(src,subdir,name));
nathan@0
   549
}
nathan@0
   550
nathan@0
   551
// -- cPlayLists --------------------------------------------------------------
nathan@0
   552
nathan@0
   553
bool cPlayLists::Load(cFileSource *Source)
nathan@0
   554
{
nathan@0
   555
  static const char *spec[] = { "*"PLAYLISTEXT,0 };
nathan@0
   556
  Clear();
nathan@0
   557
  bool res=ScanDir(Source,0,stFile,spec,0,false);
nathan@0
   558
  Sort();
nathan@0
   559
  return res;
nathan@0
   560
}
nathan@0
   561
nathan@0
   562
void cPlayLists::DoItem(cFileSource *src, const char *subdir, const char *name)
nathan@0
   563
{
nathan@0
   564
  Add(new cPlayList(src,subdir,name));
nathan@0
   565
}