diff -ruN music-0.2.0-orig/Makefile music-0.2.0/Makefile --- music-0.2.0-orig/Makefile 2007-05-18 15:29:15.000000000 +0200 +++ music-0.2.0/Makefile 2007-07-29 13:14:03.000000000 +0200 @@ -52,7 +52,7 @@ # INTERNAL USE , DONT UNCOMMENT OR PLUGIN WILL NOT COMPILE #IM_A_MORON=1 -#HAVE_TUNED_GTFT=1 +HAVE_GRAPHTFT=1 ### The C++ compiler and options: CXX ?= g++ @@ -159,8 +159,8 @@ DEFINES += -DIM_A_MORON endif -ifdef HAVE_TUNED_GTFT - DEFINES += -DHAVE_TUNED_GTFT +ifdef HAVE_GRAPHTFT + DEFINES += -DHAVE_GRAPHTFT endif ifndef WITHOUT_LIBSNDFILE diff -ruN music-0.2.0-orig/mp3control.c music-0.2.0/mp3control.c --- music-0.2.0-orig/mp3control.c 2007-05-18 14:32:37.000000000 +0200 +++ music-0.2.0/mp3control.c 2007-07-29 13:14:03.000000000 +0200 @@ -156,14 +156,6 @@ cMP3Control::~cMP3Control() { -#ifdef HAVE_TUNED_GTFT - cPlugin *graphtft=cPluginManager::GetPlugin("graphtft"); - if(graphtft) cStatus::MsgImageFile(""); -#else - cPlugin *graphtft=cPluginManager::GetPlugin("graphtft"); - if(graphtft) graphtft->SetupParse("CoverImage", ""); -#endif - if(cmdMenu) {delete cmdMenu;} cmdMenu = NULL; @@ -372,15 +364,6 @@ } } - -#ifdef HAVE_TUNED_GTFT - cPlugin *graphtft=cPluginManager::GetPlugin("graphtft"); - if(graphtft) cStatus::MsgImageFile(coverpicture ? coverpicture:""); -#else - cPlugin *graphtft=cPluginManager::GetPlugin("graphtft"); - if(graphtft) graphtft->SetupParse("CoverImage", coverpicture ? coverpicture:""); -#endif - } CanLoadCover = false; } diff -ruN music-0.2.0-orig/player-mp3.c music-0.2.0/player-mp3.c --- music-0.2.0-orig/player-mp3.c 2007-07-05 19:48:54.000000000 +0200 +++ music-0.2.0/player-mp3.c 2007-07-29 13:14:03.000000000 +0200 @@ -1974,6 +1974,9 @@ ExistsLyrics(playing->Fullname()); // Cover + Backgroundstuff +#ifdef HAVE_GRAPHTFT + LoadGraphtftImage(playing->Fullname()); +#endif if( (!MP3Setup.EnableVis) || ((showcoveronly) && (!MP3Setup.VisInCoverMode)) ) { LoadImage(playing->Fullname(), true); @@ -2171,6 +2174,7 @@ playModeMutex.Unlock(); Lock(); } + Unlock(); } void cMP3Player::Pause(void) @@ -2403,6 +2407,7 @@ strcpy (imageFile, fullname); strcpy (coverpicture, ""); + // Spectrum-Analyzer enabled if((MP3Setup.EnableVis) && (!coveronly) ) { p = strncpy(imageFile, MP3VisLoader.VisLoaderBackground(), sizeof(imageFile)); @@ -2416,11 +2421,6 @@ } } } - - - - - // // track specific image, e.g. .jpg // @@ -2524,13 +2524,160 @@ if (!strlen (coverpicture)) { DefaultImage(); } - - if (!(strcmp(coverpicture, oldimagefile))==0) + // + // path to cover changed ? + if (!(strcmp(coverpicture, oldimagefile))==0) { CanLoadCover=true; - else + } + else { CanLoadCover=false; + } +} + + +#ifdef HAVE_GRAPHTFT +void cMP3Player::LoadGraphtftImage(const char *fullsongpath) +{ + size_t i; + char graphcover[256]; + char imageFile[256]; + char oldimagefile[256]; + char *p, *q = NULL; + char Artist[256]; + char *imageSuffixes[] = { "jpg", "png" }; + d(printf("music[%d]: player: gtft: checking (%s) for images\n", getpid (), fullsongpath)); + + + strcpy (oldimagefile, graphcover); + strcpy (imageFile, fullsongpath); + strcpy (graphcover, ""); + + + // + // track specific image, e.g. .jpg + // + + if (!strlen (graphcover)) + { + + p = strrchr (imageFile, '.'); + if (p) + { + for (i = 0; i < sizeof (imageSuffixes) / sizeof (imageSuffixes[0]); i++) + { + strcpy (p + 1, imageSuffixes[i]); + d(printf("music[%d]: player: gtft: (%s)\n", getpid (), imageFile)); + q = CheckImage (imageFile); + if (q) + { + strcpy (graphcover, q); + } + } + } + } + // + // album specific image, e.g. cover-/front-/folder.jpg in song directory + // + + if (!strlen (graphcover)) + { + std::string fullfilename; + std::string Base; + + fullfilename = imageFile; + int len = fullfilename.length(); + + std::string::size_type pos = fullfilename.rfind('/',len); + if(pos!=std::string::npos) { + //BaseDir + Base = fullfilename.substr(0,pos+1); + } + + d(printf("music[%d]: player: gtft: directory='%s'\n", getpid(), Base.c_str())); + + std::string jpegs =""; + std::string b_jpegs =""; + std::string pngs =""; + std::string b_pngs =""; + + jpegs = Base + "*.jpg"; + b_jpegs = Base + "*.JPG"; + pngs = Base + "*.png"; + b_pngs = Base + "*.PNG"; + + d(printf("music[%d]: player: gtft: search for Cover in (%s)\n", getpid (), Base.c_str())); + + unsigned int i; + glob_t glob_buffer; + glob_buffer.gl_offs = 4; + glob( jpegs.c_str(), 0 , NULL, &glob_buffer); + glob(b_jpegs.c_str(), GLOB_APPEND , NULL, &glob_buffer); + glob( pngs.c_str() , GLOB_APPEND , NULL, &glob_buffer); + glob(b_pngs.c_str() , GLOB_APPEND , NULL, &glob_buffer); + + for (i=0; i < glob_buffer.gl_pathc; ++i) { + d(printf("music[%d]: player: gtft: (%s)\n", getpid(), glob_buffer.gl_pathv[i])); + + if(strcasestr(glob_buffer.gl_pathv[i], "cover")) { + q = CheckImage (glob_buffer.gl_pathv[i]); + } + else if(strcasestr(glob_buffer.gl_pathv[i], "front")) { + q = CheckImage (glob_buffer.gl_pathv[i]); + } + else if(strcasestr(glob_buffer.gl_pathv[i], "folder")) { + q = CheckImage (glob_buffer.gl_pathv[i]); + } + + if (q) { strcpy (graphcover, q); } + } + globfree(&glob_buffer); + } + // + // Artist specific image, e.g. Acdc.jpg in Artistcover directory + // + if (!strlen (graphcover)) { + if(artist !=NULL) { + strcpy(Artist, MP3Setup.CoverDir); + strcat(Artist, "/"); + strcat(Artist,artist); + strcat(Artist, ".jpg"); + if (Artist) { + d(printf("music[%d]: player: gtft: (%s)\n", getpid (), Artist)); + q = CheckImage (Artist); + if (q) { + strcpy (graphcover, q); + } + } + } + } + // + // Default image + // + if (!strlen (graphcover)) { + if (!isStream) { + file = config; + file = file + "/themes/defaultcover"; + file = file + MP3Skin.localcover; + strcpy(graphcover, file.c_str()); + } + else { + file = config; + file = file + "/themes/defaultcover"; + file = file + MP3Skin.streamcover; + strcpy(graphcover, file.c_str()); + } + } + // + // Write imagepath to /tmp + if( FILE *f = fopen("/tmp/graphTFT.cover", "w")) { + d(printf("music: player-mp3.c: write imagepath '%s' to /tmp/graphTFT.cover\n", graphcover)); + fprintf(f, "%s\n", graphcover); + fclose(f); + } + } +#endif void cMP3Player::CheckMpeg(void) { @@ -2646,4 +2793,3 @@ ptslen = 1; } } - diff -ruN music-0.2.0-orig/player-mp3.h music-0.2.0/player-mp3.h --- music-0.2.0-orig/player-mp3.h 2007-05-02 19:43:54.000000000 +0200 +++ music-0.2.0/player-mp3.h 2007-07-29 13:14:03.000000000 +0200 @@ -200,6 +200,9 @@ void WaitPlayMode(ePlayMode mode, bool inv); void ExistsLyrics(const char *songpath); void DefaultImage(void); +#ifdef HAVE_GRAPHTFT + void LoadGraphtftImage(const char *fullsongpath); +#endif protected: virtual void Activate(bool On); virtual void Action(void);