data-mp3.c
author nathan
Sun, 12 Dec 2010 12:15:17 +0100
branchtrunk
changeset 40 31537cd8ec5e
parent 29 640ce9201139
permissions -rw-r--r--
fixed image_convert.sh for newer mjpegtools
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@29
    96
  if(nice(3)<0);
nathan@29
    97
  char *qp, *qm;
nathan@29
    98
  char *m=aprintf("%s%s.mpg",imagecache,image);
nathan@0
    99
  di(printf("image: convert started %s -> %s\n",image,m))
nathan@29
   100
  char *cmd=aprintf("%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
  int n;
nathan@29
   268
  char *p=aprintf("%s/%s.%n     ",obj->Source()->BaseDir(),base,&n);
nathan@0
   269
  for(const char **s=img_suff; *s; s++) {
nathan@0
   270
#ifdef DEBUG
nathan@0
   271
    if(strlen(*s)>5) printf("ERROR: buffer overflow in CheckImage ext=%s\n",*s);
nathan@0
   272
#endif
nathan@0
   273
    strcpy(&p[n],*s);
nathan@0
   274
    di(printf("image: check %s\n",p))
nathan@0
   275
    if(!access(p,R_OK)) {
nathan@0
   276
      di(printf("image: found\n"))
nathan@0
   277
      return p;
nathan@0
   278
      }
nathan@0
   279
    }
nathan@0
   280
  free(p);
nathan@0
   281
  return 0;
nathan@0
   282
}
nathan@0
   283
nathan@0
   284
#include "data-mp3-image.c"
nathan@0
   285
extern void PropagateImage(const char *image);
nathan@0
   286
nathan@0
   287
bool cSong::Image(unsigned char * &mem, int &len)
nathan@0
   288
{
nathan@0
   289
  mem=0;
nathan@0
   290
  if(queueStat>0) {
nathan@0
   291
    if(!conv->Status()) {
nathan@0
   292
      di(printf("image: still queued\n"))
nathan@0
   293
      return false;
nathan@0
   294
      }
nathan@0
   295
    queueStat=-1;
nathan@0
   296
    delete conv; conv=0;
nathan@0
   297
    }
nathan@0
   298
nathan@0
   299
  int res=0;
nathan@0
   300
  if(image || FindImage()) {
nathan@0
   301
    di(printf("image: loading image %s\n",image))
nathan@29
   302
    char *m=aprintf("%s%s.mpg",imagecache,image);
nathan@0
   303
    if(access(m,R_OK)) {
nathan@0
   304
      di(printf("image: not cached\n"))
nathan@0
   305
      if(queueStat<0) {
nathan@0
   306
        di(printf("image: obviously convert failed...\n"))
nathan@0
   307
        }
nathan@0
   308
      else {
nathan@0
   309
        if(!conv) conv=new cImageConvert;
nathan@0
   310
        if(conv && conv->Convert(image)) {
nathan@0
   311
          di(printf("image: convert queued\n"))
nathan@0
   312
          queueStat=1;
nathan@0
   313
          res=-1;
nathan@0
   314
          }
nathan@0
   315
        else {
nathan@0
   316
          di(printf("image: queueing failed\n"))
nathan@0
   317
          queueStat=-1;
nathan@0
   318
          }
nathan@0
   319
        }
nathan@0
   320
      }
nathan@0
   321
    else {
nathan@0
   322
      di(printf("image: cached\n"))
nathan@0
   323
      int f=open(m,O_RDONLY);
nathan@0
   324
      if(f>=0) {
nathan@0
   325
        struct stat64 st;
nathan@0
   326
        fstat64(f,&st);
nathan@0
   327
        len=st.st_size;
nathan@0
   328
        mem=MALLOC(unsigned char,len);
nathan@0
   329
        if(mem) {
nathan@0
   330
          if(read(f,mem,len)==len) res=1;
nathan@0
   331
          else free(mem);
nathan@0
   332
          }
nathan@0
   333
        close(f);
nathan@0
   334
        }
nathan@0
   335
      }
nathan@0
   336
    free(m);
nathan@0
   337
    }
nathan@0
   338
nathan@0
   339
  PropagateImage(res==1 ? image : 0);
nathan@0
   340
nathan@0
   341
  if(res<=0) {
nathan@0
   342
    di(printf("image: using static default image\n"))
nathan@0
   343
    len=sizeof(defaultImage);
nathan@0
   344
    mem=MALLOC(unsigned char,len);
nathan@0
   345
    if(mem) {
nathan@0
   346
      memcpy(mem,defaultImage,len);
nathan@0
   347
      }
nathan@0
   348
    }
nathan@0
   349
  return res>=0;
nathan@0
   350
}
nathan@0
   351
nathan@0
   352
// -- cPlayList --------------------------------------------------------------
nathan@0
   353
nathan@0
   354
cPlayList::cPlayList(cFileObj *Obj)
nathan@0
   355
{
nathan@0
   356
  obj=new cFileObj(Obj);
nathan@0
   357
  Init();
nathan@0
   358
}
nathan@0
   359
nathan@0
   360
cPlayList::cPlayList(cFileSource *Source, const char *Subdir, const char *Name)
nathan@0
   361
{
nathan@0
   362
  obj=new cFileObj(Source,Subdir,Name,otFile);
nathan@0
   363
  Init();
nathan@0
   364
}
nathan@0
   365
nathan@0
   366
cPlayList::cPlayList(cPlayList *List)
nathan@0
   367
{
nathan@0
   368
  obj=new cFileObj(List->obj);
nathan@0
   369
  Init();
nathan@0
   370
}
nathan@0
   371
nathan@0
   372
cPlayList::~cPlayList()
nathan@0
   373
{
nathan@0
   374
  free(basename);
nathan@0
   375
  free(extbuffer);
nathan@0
   376
  obj->Source()->Unblock();
nathan@0
   377
  delete obj;
nathan@0
   378
}
nathan@0
   379
nathan@0
   380
void cPlayList::Init(void)
nathan@0
   381
{
nathan@0
   382
  extbuffer=basename=0;
nathan@0
   383
  isWinAmp=false;
nathan@0
   384
  obj->Source()->Block();
nathan@0
   385
  Set();
nathan@0
   386
}
nathan@0
   387
nathan@0
   388
void cPlayList::Set(void)
nathan@0
   389
{
nathan@0
   390
  free(basename); basename=0;
nathan@0
   391
  if(obj->Name()) {
nathan@0
   392
    basename=strdup(obj->Name());
nathan@0
   393
    int l=strlen(basename)-strlen(PLAYLISTEXT);
nathan@0
   394
    if(l>0 && !strcasecmp(basename+l,PLAYLISTEXT)) basename[l]=0;
nathan@0
   395
    }
nathan@0
   396
}
nathan@0
   397
nathan@0
   398
int cPlayList::Compare(const cListObject &ListObject) const
nathan@0
   399
{
nathan@0
   400
  cPlayList *list=(cPlayList *)&ListObject;
nathan@0
   401
  return strcasecmp(obj->Name(),list->obj->Name());
nathan@0
   402
}
nathan@0
   403
nathan@0
   404
bool cPlayList::Load(void)
nathan@0
   405
{
nathan@0
   406
  Clear();
nathan@0
   407
  bool result=false;
nathan@0
   408
  FILE *f=fopen(obj->FullPath(),"r");
nathan@0
   409
  if(f) {
nathan@0
   410
    char buffer[512];
nathan@0
   411
    result=true;
nathan@0
   412
    while(fgets(buffer,sizeof(buffer),f)>0) {
nathan@0
   413
      if(buffer[0]=='#') {
nathan@0
   414
        if(!strncmp(buffer,WINAMPEXT,strlen(WINAMPEXT))) {
nathan@0
   415
          d(printf("mp3: detected WinAmp style playlist\n"))
nathan@0
   416
          isWinAmp=true;
nathan@0
   417
          }
nathan@0
   418
        continue;
nathan@0
   419
        }
nathan@0
   420
      if(!isempty(buffer)) {
nathan@0
   421
        cSong *song=new cSong(obj->Source(),0,0);
nathan@0
   422
        if(song->Parse(buffer,obj->Subdir())) Add(song);
nathan@0
   423
        else {
nathan@0
   424
          esyslog("error loading playlist %s\n",obj->FullPath());
nathan@0
   425
          delete song;
nathan@0
   426
          result=false;
nathan@0
   427
          break;
nathan@0
   428
          }
nathan@0
   429
        }
nathan@0
   430
      }
nathan@0
   431
    fclose(f);
nathan@0
   432
    }
nathan@0
   433
  else LOG_ERROR_STR(obj->FullPath());
nathan@0
   434
nathan@0
   435
  if(result && isWinAmp) {
nathan@0
   436
    cSong *song=First();
nathan@0
   437
    while(song) {   // if this is a WinAmp playlist, convert \ to /
nathan@0
   438
      song->Convert();
nathan@0
   439
      song=cList<cSong>::Next(song);
nathan@0
   440
      }
nathan@0
   441
    }
nathan@0
   442
  return result;
nathan@0
   443
}
nathan@0
   444
nathan@0
   445
bool cPlayList::Save(void)
nathan@0
   446
{
nathan@0
   447
  bool result=true;
nathan@0
   448
  cSafeFile f(obj->FullPath());
nathan@0
   449
  if(f.Open()) {
nathan@0
   450
    cSong *song=First();
nathan@0
   451
    while(song) {
nathan@0
   452
      if(!song->Save(f,obj->Subdir())) {
nathan@0
   453
         result=false;
nathan@0
   454
         break;
nathan@0
   455
         }
nathan@0
   456
      song=cList<cSong>::Next(song);
nathan@0
   457
      }
nathan@0
   458
    if(!f.Close()) result=false;
nathan@0
   459
    }
nathan@0
   460
  else result=false;
nathan@0
   461
  return result;
nathan@0
   462
}
nathan@0
   463
 
nathan@0
   464
bool cPlayList::Exists(void)
nathan@0
   465
{
nathan@0
   466
  return obj->Exists();
nathan@0
   467
}
nathan@0
   468
nathan@0
   469
bool cPlayList::TestName(const char *newName)
nathan@0
   470
{
nathan@0
   471
  return obj->TestName(AddExt(newName,PLAYLISTEXT));
nathan@0
   472
}
nathan@0
   473
nathan@0
   474
bool cPlayList::Rename(const char *newName)
nathan@0
   475
{
nathan@0
   476
  bool r=obj->Rename(AddExt(newName,PLAYLISTEXT));
nathan@0
   477
  if(r) Set();
nathan@0
   478
  return r;
nathan@0
   479
}
nathan@0
   480
nathan@0
   481
bool cPlayList::Create(const char *newName)
nathan@0
   482
{
nathan@0
   483
  bool r=obj->Create(AddExt(newName,PLAYLISTEXT));
nathan@0
   484
  if(r) {
nathan@0
   485
    Set();
nathan@0
   486
    r=Load();
nathan@0
   487
    }
nathan@0
   488
  return r;
nathan@0
   489
}
nathan@0
   490
nathan@0
   491
bool cPlayList::Delete(void)
nathan@0
   492
{
nathan@0
   493
  return obj->Delete();
nathan@0
   494
}
nathan@0
   495
nathan@0
   496
const char *cPlayList::AddExt(const char *FileName, const char *Ext)
nathan@0
   497
{
nathan@29
   498
  free(extbuffer);
nathan@29
   499
  extbuffer=aprintf("%s%s",FileName,Ext);
nathan@0
   500
  return extbuffer;
nathan@0
   501
}
nathan@0
   502
nathan@0
   503
// -- cInstantPlayList ------------------------------------------------------
nathan@0
   504
nathan@0
   505
cInstantPlayList::cInstantPlayList(cFileObj *Obj)
nathan@0
   506
:cPlayList(Obj)
nathan@0
   507
{
nathan@0
   508
  if(!Obj->Name()) Obj->SetName("instant");
nathan@0
   509
}
nathan@0
   510
nathan@0
   511
bool cInstantPlayList::Load(void)
nathan@0
   512
{
nathan@0
   513
  bool res=false;
nathan@0
   514
  Clear();
nathan@0
   515
  switch(obj->Type()) {
nathan@0
   516
    case otFile:
nathan@0
   517
      d(printf("instant: file %s\n",obj->Name()))
nathan@0
   518
      if(strcasecmp(obj->Name(),basename)) {
nathan@0
   519
        d(printf("instant: detected as playlist\n"))
nathan@0
   520
        res=cPlayList::Load();
nathan@0
   521
        }
nathan@0
   522
      else {
nathan@0
   523
        Add(new cSong(obj));
nathan@0
   524
        res=true;
nathan@0
   525
        }
nathan@0
   526
      break;
nathan@0
   527
    case otDir:
nathan@0
   528
      {
nathan@0
   529
      d(printf("instant: dir %s\n",obj->Name()))
nathan@0
   530
      res=ScanDir(obj->Source(),obj->Path(),stFile,obj->Source()->Include(),excl_pl,true);
nathan@0
   531
      Sort();
nathan@0
   532
      break;
nathan@0
   533
      }
nathan@0
   534
    case otBase:
nathan@0
   535
      d(printf("instant: base\n"))
nathan@0
   536
      res=ScanDir(obj->Source(),0,stFile,obj->Source()->Include(),excl_pl,true);
nathan@0
   537
      Sort();
nathan@0
   538
      break;
nathan@0
   539
    default: break;
nathan@0
   540
    }
nathan@0
   541
  return res;
nathan@0
   542
}
nathan@0
   543
nathan@0
   544
void cInstantPlayList::DoItem(cFileSource *src, const char *subdir, const char *name)
nathan@0
   545
{
nathan@0
   546
  Add(new cSong(src,subdir,name));
nathan@0
   547
}
nathan@0
   548
nathan@0
   549
// -- cPlayLists --------------------------------------------------------------
nathan@0
   550
nathan@0
   551
bool cPlayLists::Load(cFileSource *Source)
nathan@0
   552
{
nathan@0
   553
  static const char *spec[] = { "*"PLAYLISTEXT,0 };
nathan@0
   554
  Clear();
nathan@0
   555
  bool res=ScanDir(Source,0,stFile,spec,0,false);
nathan@0
   556
  Sort();
nathan@0
   557
  return res;
nathan@0
   558
}
nathan@0
   559
nathan@0
   560
void cPlayLists::DoItem(cFileSource *src, const char *subdir, const char *name)
nathan@0
   561
{
nathan@0
   562
  Add(new cPlayList(src,subdir,name));
nathan@0
   563
}