comparison src/madplug/plugin.c @ 1978:fa9f85cebade

s/vfs_/aud_vfs_/g
author William Pitcock <nenolod@atheme.org>
date Sun, 07 Oct 2007 00:25:33 -0500
parents 5fa26178eaef
children 839804c3b3a4
comparison
equal deleted inserted replaced
1977:5a6b60ceaa0f 1978:fa9f85cebade
290 ((unsigned long) hbuf[2] << 8) | (unsigned long) hbuf[3]; 290 ((unsigned long) hbuf[2] << 8) | (unsigned long) hbuf[3];
291 } 291 }
292 292
293 gboolean audmad_is_remote(gchar *url) 293 gboolean audmad_is_remote(gchar *url)
294 { 294 {
295 gboolean rv = vfs_is_remote(url); 295 gboolean rv = aud_vfs_is_remote(url);
296 return rv; 296 return rv;
297 } 297 }
298 298
299 // audacious vfs fast version 299 // audacious vfs fast version
300 static int audmad_is_our_fd(char *filename, VFSFile *fin) 300 static int audmad_is_our_fd(char *filename, VFSFile *fin)
323 if (fin == NULL) { 323 if (fin == NULL) {
324 g_message("fin = NULL"); 324 g_message("fin = NULL");
325 return 0; 325 return 0;
326 } 326 }
327 327
328 if(vfs_fread(buf, 1, 4, fin) == 0) { 328 if(aud_vfs_fread(buf, 1, 4, fin) == 0) {
329 gchar *tmp = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); 329 gchar *tmp = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
330 g_message("vfs_fread failed @1 %s", tmp); 330 g_message("aud_vfs_fread failed @1 %s", tmp);
331 g_free(tmp); 331 g_free(tmp);
332 return 0; 332 return 0;
333 } 333 }
334 334
335 check = mp3_head_convert(buf); 335 check = mp3_head_convert(buf);
338 return 1; 338 return 1;
339 else if (memcmp(buf, "OggS", 4) == 0) 339 else if (memcmp(buf, "OggS", 4) == 0)
340 return 0; 340 return 0;
341 else if (memcmp(buf, "RIFF", 4) == 0) 341 else if (memcmp(buf, "RIFF", 4) == 0)
342 { 342 {
343 vfs_fseek(fin, 4, SEEK_CUR); 343 aud_vfs_fseek(fin, 4, SEEK_CUR);
344 if(vfs_fread(buf, 1, 4, fin) == 0) { 344 if(aud_vfs_fread(buf, 1, 4, fin) == 0) {
345 gchar *tmp = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); 345 gchar *tmp = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
346 g_message("vfs_fread failed @2 %s", tmp); 346 g_message("aud_vfs_fread failed @2 %s", tmp);
347 g_free(tmp); 347 g_free(tmp);
348 return 0; 348 return 0;
349 } 349 }
350 350
351 if (memcmp(buf, "RMP3", 4) == 0) 351 if (memcmp(buf, "RMP3", 4) == 0)
353 } 353 }
354 354
355 // check data for frame header 355 // check data for frame header
356 while (!mp3_head_check(check, &frameSize)) 356 while (!mp3_head_check(check, &frameSize))
357 { 357 {
358 if((ret = vfs_fread(tmp, 1, chksize, fin)) == 0){ 358 if((ret = aud_vfs_fread(tmp, 1, chksize, fin)) == 0){
359 gchar *tmp = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); 359 gchar *tmp = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
360 g_message("vfs_fread failed @3 %s", tmp); 360 g_message("aud_vfs_fread failed @3 %s", tmp);
361 g_free(tmp); 361 g_free(tmp);
362 return 0; 362 return 0;
363 } 363 }
364 for (i = 0; i < ret; i++) 364 for (i = 0; i < ret; i++)
365 { 365 {
370 /* when the first matching frame header is found, we check for 370 /* when the first matching frame header is found, we check for
371 * another frame by seeking to the approximate start of the 371 * another frame by seeking to the approximate start of the
372 * next header ... also reduce the check size. 372 * next header ... also reduce the check size.
373 */ 373 */
374 if (++chkcount >= 3) return 1; 374 if (++chkcount >= 3) return 1;
375 vfs_fseek(fin, frameSize-4, SEEK_CUR); 375 aud_vfs_fseek(fin, frameSize-4, SEEK_CUR);
376 check = 0; 376 check = 0;
377 chksize = 8; 377 chksize = 8;
378 } 378 }
379 } 379 }
380 380
389 static int audmad_is_our_file(char *filename) 389 static int audmad_is_our_file(char *filename)
390 { 390 {
391 VFSFile *fin = NULL; 391 VFSFile *fin = NULL;
392 gint rtn; 392 gint rtn;
393 393
394 fin = vfs_fopen(filename, "rb"); 394 fin = aud_vfs_fopen(filename, "rb");
395 395
396 if (fin == NULL) 396 if (fin == NULL)
397 return 0; 397 return 0;
398 398
399 rtn = audmad_is_our_fd(filename, fin); 399 rtn = audmad_is_our_fd(filename, fin);
400 vfs_fclose(fin); 400 aud_vfs_fclose(fin);
401 401
402 return rtn; 402 return rtn;
403 } 403 }
404 404
405 static void audmad_stop(InputPlayback *playback) 405 static void audmad_stop(InputPlayback *playback)
652 g_free(string); 652 g_free(string);
653 string = NULL; 653 string = NULL;
654 #endif 654 #endif
655 655
656 if(info.remote && mad_timer_count(info.duration, MAD_UNITS_SECONDS) <= 0){ 656 if(info.remote && mad_timer_count(info.duration, MAD_UNITS_SECONDS) <= 0){
657 if((fd && vfs_is_streaming(fd)) || (info.playback && info.playback->playing)) { 657 if((fd && aud_vfs_is_streaming(fd)) || (info.playback && info.playback->playing)) {
658 gchar *tmp = NULL; 658 gchar *tmp = NULL;
659 tuple = aud_tuple_new_from_filename(filename); 659 tuple = aud_tuple_new_from_filename(filename);
660 660
661 #ifdef DEBUG 661 #ifdef DEBUG
662 if(info.playback) 662 if(info.playback)
663 g_message("info.playback->playing = %d",info.playback->playing); 663 g_message("info.playback->playing = %d",info.playback->playing);
664 #endif 664 #endif
665 tmp = vfs_get_metadata(info.infile ? info.infile : fd, "track-name"); 665 tmp = aud_vfs_get_metadata(info.infile ? info.infile : fd, "track-name");
666 if(tmp){ 666 if(tmp){
667 gchar *scratch; 667 gchar *scratch;
668 668
669 scratch = str_to_utf8(tmp); 669 scratch = str_to_utf8(tmp);
670 aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, scratch); 670 aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, scratch);
671 g_free(tmp); 671 g_free(tmp);
672 g_free(scratch); 672 g_free(scratch);
673 673
674 tmp = NULL; 674 tmp = NULL;
675 } 675 }
676 tmp = vfs_get_metadata(info.infile ? info.infile : fd, "stream-name"); 676 tmp = aud_vfs_get_metadata(info.infile ? info.infile : fd, "stream-name");
677 if(tmp){ 677 if(tmp){
678 gchar *scratch; 678 gchar *scratch;
679 679
680 scratch = str_to_utf8(tmp); 680 scratch = str_to_utf8(tmp);
681 aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, scratch); 681 aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, scratch);
700 g_message("get_song_tuple: remote: NULL"); 700 g_message("get_song_tuple: remote: NULL");
701 #endif 701 #endif
702 // return NULL; 702 // return NULL;
703 } /* info.remote */ 703 } /* info.remote */
704 704
705 // if !fd, pre-open the file with vfs_fopen() and reuse fd. 705 // if !fd, pre-open the file with aud_vfs_fopen() and reuse fd.
706 if(!fd) { 706 if(!fd) {
707 fd = vfs_fopen(filename, "rb"); 707 fd = aud_vfs_fopen(filename, "rb");
708 if(!fd) 708 if(!fd)
709 return NULL; 709 return NULL;
710 local_fd = TRUE; 710 local_fd = TRUE;
711 } 711 }
712 712
794 794
795 aud_tuple_associate_string(tuple, FIELD_QUALITY, NULL, "lossy"); 795 aud_tuple_associate_string(tuple, FIELD_QUALITY, NULL, "lossy");
796 aud_tuple_associate_string(tuple, FIELD_CODEC, NULL, "MPEG Audio (MP3)"); 796 aud_tuple_associate_string(tuple, FIELD_CODEC, NULL, "MPEG Audio (MP3)");
797 797
798 if(local_fd) 798 if(local_fd)
799 vfs_fclose(fd); 799 aud_vfs_fclose(fd);
800 800
801 #ifdef DEBUG 801 #ifdef DEBUG
802 g_message("e: mad: audmad_get_song_tuple"); 802 g_message("e: mad: audmad_get_song_tuple");
803 #endif 803 #endif
804 return tuple; 804 return tuple;
812 static Tuple *audmad_probe_for_tuple(char *filename, VFSFile *fd) 812 static Tuple *audmad_probe_for_tuple(char *filename, VFSFile *fd)
813 { 813 {
814 if (!audmad_is_our_fd(filename, fd)) 814 if (!audmad_is_our_fd(filename, fd))
815 return NULL; 815 return NULL;
816 816
817 vfs_rewind(fd); 817 aud_vfs_rewind(fd);
818 818
819 return __audmad_get_song_tuple(filename, fd); 819 return __audmad_get_song_tuple(filename, fd);
820 } 820 }
821 821
822 static gchar *fmts[] = { "mp3", "mp2", "mpg", NULL }; 822 static gchar *fmts[] = { "mp3", "mp2", "mpg", NULL };
834 .cleanup = audmad_cleanup, 834 .cleanup = audmad_cleanup,
835 .get_song_info = audmad_get_song_info, 835 .get_song_info = audmad_get_song_info,
836 .file_info_box = audmad_get_file_info, 836 .file_info_box = audmad_get_file_info,
837 .get_song_tuple = audmad_get_song_tuple, 837 .get_song_tuple = audmad_get_song_tuple,
838 .is_our_file_from_vfs = audmad_is_our_fd, 838 .is_our_file_from_vfs = audmad_is_our_fd,
839 .vfs_extensions = fmts, 839 .aud_vfs_extensions = fmts,
840 .mseek = audmad_mseek, 840 .mseek = audmad_mseek,
841 .probe_for_tuple = audmad_probe_for_tuple 841 .probe_for_tuple = audmad_probe_for_tuple
842 }; 842 };
843 843
844 InputPlugin *madplug_iplist[] = { &mad_ip, NULL }; 844 InputPlugin *madplug_iplist[] = { &mad_ip, NULL };