comparison src/madplug/plugin.c @ 789:354c69a939bc trunk

[svn] revising vfs_fread() check code. - check vfs handle code has been restored to original position. - accidentally removed substitution to ret has been restored. - in audmad_is_our_fd(), check code just puts log message instead of return. please let me know if log message would be put upon proper mp3 file. - in scan_file(), check code returns if vfs_fread() fails. this fixes open audio with bogus parameters problem.
author yaz
date Tue, 06 Mar 2007 22:08:18 -0800
parents 2461b711162b
children d200de50a1fc
comparison
equal deleted inserted replaced
788:2461b711162b 789:354c69a939bc
233 so let's exclude known non-mp3 filename extensions */ 233 so let's exclude known non-mp3 filename extensions */
234 if ((ext != NULL) && 234 if ((ext != NULL) &&
235 (!strcasecmp("flac", ext) || !strcasecmp("mpc", ext) || 235 (!strcasecmp("flac", ext) || !strcasecmp("mpc", ext) ||
236 !strcasecmp("tta", ext) || !strcasecmp("ogg", ext) || 236 !strcasecmp("tta", ext) || !strcasecmp("ogg", ext) ||
237 !strcasecmp("wma", ext) ) 237 !strcasecmp("wma", ext) )
238 ) 238 )
239 return FALSE; 239 return 0;
240 240
241 if (fin == NULL) 241 if (fin == NULL) {
242 return FALSE; 242 g_message("fin = NULL");
243 243 return 0;
244 vfs_fread(buf, 1, 4, fin); 244 }
245
246 if(vfs_fread(buf, 1, 4, fin) == 0) {
247 g_message("vfs_fread failed @1 %s", g_filename_to_utf8(filename, -1, NULL, NULL, NULL));
248 }
245 249
246 check = mp3_head_convert(buf); 250 check = mp3_head_convert(buf);
247 251
248 if (memcmp(buf, "ID3", 3) == 0) 252 if (memcmp(buf, "ID3", 3) == 0)
249 return 1; 253 return 1;
250 else if (memcmp(buf, "OggS", 4) == 0) 254 else if (memcmp(buf, "OggS", 4) == 0)
251 return 0; 255 return 0;
252 else if (memcmp(buf, "RIFF", 4) == 0) 256 else if (memcmp(buf, "RIFF", 4) == 0)
253 { 257 {
254 vfs_fseek(fin, 4, SEEK_CUR); 258 vfs_fseek(fin, 4, SEEK_CUR);
255 vfs_fread(buf, 1, 4, fin); 259 if(vfs_fread(buf, 1, 4, fin) == 0) {
260 g_message("vfs_fread failed @2 %s", g_filename_to_utf8(filename, -1, NULL, NULL, NULL));
261 }
256 262
257 if (memcmp(buf, "RMP3", 4) == 0) 263 if (memcmp(buf, "RMP3", 4) == 0)
258 return 1; 264 return 1;
259 } 265 }
260 266
261 while (!mp3_head_check(check)) 267 while (!mp3_head_check(check))
262 { 268 {
263 ret = vfs_fread(tmp, 1, 4096, fin); 269 if((ret = vfs_fread(tmp, 1, 4096, fin)) == 0){
264 if (ret == 0) 270 g_message("vfs_fread failed @3 %s", g_filename_to_utf8(filename, -1, NULL, NULL, NULL));
265 return 0; 271 }
266
267 for (i = 0; i < ret; i++) 272 for (i = 0; i < ret; i++)
268 { 273 {
269 check <<= 8; 274 check <<= 8;
270 check |= tmp[i]; 275 check |= tmp[i];
271 276