decoder.c
branchtrunk
changeset 33 65ed49cbc08b
parent 29 640ce9201139
child 34 afc13760179b
equal deleted inserted replaced
32:cea1b4f741be 33:65ed49cbc08b
    34 #include "decoder-core.h"
    34 #include "decoder-core.h"
    35 #include "decoder-mp3.h"
    35 #include "decoder-mp3.h"
    36 #include "decoder-mp3-stream.h"
    36 #include "decoder-mp3-stream.h"
    37 #include "decoder-snd.h"
    37 #include "decoder-snd.h"
    38 #include "decoder-ogg.h"
    38 #include "decoder-ogg.h"
       
    39 #include "decoder-ogg-stream.h"
    39 
    40 
    40 #define CACHEFILENAME     "id3info.cache"
    41 #define CACHEFILENAME     "id3info.cache"
    41 #define CACHESAVETIMEOUT  120 // secs
    42 #define CACHESAVETIMEOUT  120 // secs
    42 #define CACHEPURGETIMEOUT 120 // days
    43 #define CACHEPURGETIMEOUT 120 // days
    43 
    44 
   256 #ifdef HAVE_SNDFILE
   257 #ifdef HAVE_SNDFILE
   257         case DEC_SND:  decoder=new cSndDecoder(full); break;
   258         case DEC_SND:  decoder=new cSndDecoder(full); break;
   258 #endif
   259 #endif
   259 #ifdef HAVE_VORBISFILE
   260 #ifdef HAVE_VORBISFILE
   260         case DEC_OGG:  decoder=new cOggDecoder(full); break;
   261         case DEC_OGG:  decoder=new cOggDecoder(full); break;
       
   262         case DEC_OGGS: decoder=new cOggStreamDecoder(full); break;
   261 #endif
   263 #endif
   262         default:       esyslog("ERROR: bad DecoderID '%s' from info cache: %s",cDecoders::ID2Str(dat->DecoderID),full); break;
   264         default:       esyslog("ERROR: bad DecoderID '%s' from info cache: %s",cDecoders::ID2Str(dat->DecoderID),full); break;
   263         }
   265         }
   264       }
   266       }
   265     dat->Unlock();
   267     dat->Unlock();
   279 #ifdef HAVE_VORBISFILE
   281 #ifdef HAVE_VORBISFILE
   280     if(!decoder) {
   282     if(!decoder) {
   281       decoder=new cOggDecoder(full);
   283       decoder=new cOggDecoder(full);
   282       if(!decoder || !decoder->Valid()) { delete decoder; decoder=0; }
   284       if(!decoder || !decoder->Valid()) { delete decoder; decoder=0; }
   283       }
   285       }
       
   286     if(!decoder) {
       
   287       decoder=new cOggStreamDecoder(full);
       
   288       if(!decoder || !decoder->Valid()) { delete decoder; decoder=0; }
       
   289       }
   284 #endif
   290 #endif
   285     if(!decoder) {
   291     if(!decoder) {
   286       decoder=new cMP3StreamDecoder(full);
   292       decoder=new cMP3StreamDecoder(full);
   287       if(!decoder || !decoder->Valid()) { delete decoder; decoder=0; }
   293       if(!decoder || !decoder->Valid()) { delete decoder; decoder=0; }
   288       }
   294       }
   300   switch(id) {
   306   switch(id) {
   301     case DEC_MP3:  return DEC_MP3_STR;
   307     case DEC_MP3:  return DEC_MP3_STR;
   302     case DEC_MP3S: return DEC_MP3S_STR;
   308     case DEC_MP3S: return DEC_MP3S_STR;
   303     case DEC_SND:  return DEC_SND_STR;
   309     case DEC_SND:  return DEC_SND_STR;
   304     case DEC_OGG:  return DEC_OGG_STR;
   310     case DEC_OGG:  return DEC_OGG_STR;
       
   311     case DEC_OGGS: return DEC_OGGS_STR;
   305     }
   312     }
   306   return 0;
   313   return 0;
   307 }
   314 }
   308 
   315 
   309 int cDecoders::Str2ID(const char *str)
   316 int cDecoders::Str2ID(const char *str)
   310 {
   317 {
   311   if     (!strcmp(str,DEC_MP3_STR )) return DEC_MP3;
   318   if     (!strcmp(str,DEC_MP3_STR )) return DEC_MP3;
   312   else if(!strcmp(str,DEC_MP3S_STR)) return DEC_MP3S;
   319   else if(!strcmp(str,DEC_MP3S_STR)) return DEC_MP3S;
   313   else if(!strcmp(str,DEC_SND_STR )) return DEC_SND;
   320   else if(!strcmp(str,DEC_SND_STR )) return DEC_SND;
   314   else if(!strcmp(str,DEC_OGG_STR )) return DEC_OGG;
   321   else if(!strcmp(str,DEC_OGG_STR )) return DEC_OGG;
       
   322   else if(!strcmp(str,DEC_OGGS_STR)) return DEC_OGGS;
   315   return 0;
   323   return 0;
   316 }
   324 }
   317 
   325 
   318 // --- cDecoder ----------------------------------------------------------------
   326 // --- cDecoder ----------------------------------------------------------------
   319 
   327