summaryrefslogtreecommitdiff
blob: 074de7703c8e2073ea9b12b81ad2e32a10bda7e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
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. <song>.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. <song>.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);