comparison src/madplug/plugin.c @ 2276:d25cd7e7eddb

append '\n' to format string for AUDDBG()
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Tue, 01 Jan 2008 23:12:46 +0900
parents a5c96af75300
children 1457b35713d9
comparison
equal deleted inserted replaced
2275:e09d9633d6aa 2276:d25cd7e7eddb
102 if ( text != NULL ) 102 if ( text != NULL )
103 x = g_strtod(text, NULL); 103 x = g_strtod(text, NULL);
104 else 104 else
105 x = 0; 105 x = 0;
106 config->pregain_scale = (x != 0) ? pow(10.0, x / 20) : 1; 106 config->pregain_scale = (x != 0) ? pow(10.0, x / 20) : 1;
107 AUDDBG("pregain=[%s] -> %g -> %g", text, x, config->pregain_scale); 107 AUDDBG("pregain=[%s] -> %g -> %g\n", text, x, config->pregain_scale);
108 text = config->replaygain.default_db; 108 text = config->replaygain.default_db;
109 if ( text != NULL ) 109 if ( text != NULL )
110 x = g_strtod(text, NULL); 110 x = g_strtod(text, NULL);
111 else 111 else
112 x = 0; 112 x = 0;
113 config->replaygain.default_scale = (x != 0) ? pow(10.0, x / 20) : 1; 113 config->replaygain.default_scale = (x != 0) ? pow(10.0, x / 20) : 1;
114 AUDDBG("RG.default=[%s] -> %g -> %g", text, x, 114 AUDDBG("RG.default=[%s] -> %g -> %g\n", text, x,
115 config->replaygain.default_scale); 115 config->replaygain.default_scale);
116 } 116 }
117 117
118 static void audmad_init() 118 static void audmad_init()
119 { 119 {
401 return rtn; 401 return rtn;
402 } 402 }
403 403
404 static void audmad_stop(InputPlayback *playback) 404 static void audmad_stop(InputPlayback *playback)
405 { 405 {
406 AUDDBG("f: audmad_stop"); 406 AUDDBG("f: audmad_stop\n");
407 g_mutex_lock(mad_mutex); 407 g_mutex_lock(mad_mutex);
408 info.playback = playback; 408 info.playback = playback;
409 g_mutex_unlock(mad_mutex); 409 g_mutex_unlock(mad_mutex);
410 410
411 if (decode_thread) { 411 if (decode_thread) {
413 g_mutex_lock(mad_mutex); 413 g_mutex_lock(mad_mutex);
414 info.playback->playing = 0; 414 info.playback->playing = 0;
415 g_mutex_unlock(mad_mutex); 415 g_mutex_unlock(mad_mutex);
416 g_cond_signal(mad_cond); 416 g_cond_signal(mad_cond);
417 417
418 AUDDBG("waiting for thread"); 418 AUDDBG("waiting for thread\n");
419 g_thread_join(decode_thread); 419 g_thread_join(decode_thread);
420 AUDDBG("thread done"); 420 AUDDBG("thread done\n");
421 421
422 input_term(&info); 422 input_term(&info);
423 decode_thread = NULL; 423 decode_thread = NULL;
424 424
425 } 425 }
426 AUDDBG("e: audmad_stop"); 426 AUDDBG("e: audmad_stop\n");
427 } 427 }
428 428
429 static void audmad_play_file(InputPlayback *playback) 429 static void audmad_play_file(InputPlayback *playback)
430 { 430 {
431 gboolean rtn; 431 gboolean rtn;
432 gchar *url = playback->filename; 432 gchar *url = playback->filename;
433 433
434 #ifdef AUD_DEBUG 434 #ifdef AUD_DEBUG
435 { 435 {
436 gchar *tmp = g_filename_to_utf8(url, -1, NULL, NULL, NULL); 436 gchar *tmp = g_filename_to_utf8(url, -1, NULL, NULL, NULL);
437 AUDDBG("playing %s", tmp); 437 AUDDBG("playing %s\n", tmp);
438 g_free(tmp); 438 g_free(tmp);
439 } 439 }
440 #endif /* DEBUG */ 440 #endif /* DEBUG */
441 441
442 if (input_init(&info, url, NULL) == FALSE) { 442 if (input_init(&info, url, NULL) == FALSE) {
494 audmad_get_song_info(char *url, char **title, int *length) 494 audmad_get_song_info(char *url, char **title, int *length)
495 { 495 {
496 struct mad_info_t myinfo; 496 struct mad_info_t myinfo;
497 #ifdef AUD_DEBUG 497 #ifdef AUD_DEBUG
498 gchar *tmp = g_filename_to_utf8(url, -1, NULL, NULL, NULL); 498 gchar *tmp = g_filename_to_utf8(url, -1, NULL, NULL, NULL);
499 AUDDBG("f: audmad_get_song_info: %s", tmp); 499 AUDDBG("f: audmad_get_song_info: %s\n", tmp);
500 g_free(tmp); 500 g_free(tmp);
501 #endif /* DEBUG */ 501 #endif /* DEBUG */
502 502
503 if (input_init(&myinfo, url, NULL) == FALSE) { 503 if (input_init(&myinfo, url, NULL) == FALSE) {
504 AUDDBG("error initialising input"); 504 AUDDBG("error initialising input\n");
505 return; 505 return;
506 } 506 }
507 507
508 if (input_get_info(&myinfo, info.remote ? TRUE : audmad_config.fast_play_time_calc) == TRUE) { 508 if (input_get_info(&myinfo, info.remote ? TRUE : audmad_config.fast_play_time_calc) == TRUE) {
509 if(aud_tuple_get_string(myinfo.tuple, -1, "track-name")) 509 if(aud_tuple_get_string(myinfo.tuple, -1, "track-name"))
518 else { 518 else {
519 *title = g_strdup(url); 519 *title = g_strdup(url);
520 *length = -1; 520 *length = -1;
521 } 521 }
522 input_term(&myinfo); 522 input_term(&myinfo);
523 AUDDBG("e: audmad_get_song_info"); 523 AUDDBG("e: audmad_get_song_info\n");
524 } 524 }
525 525
526 static gboolean 526 static gboolean
527 audmad_fill_info(struct mad_info_t *info, VFSFile *fd) 527 audmad_fill_info(struct mad_info_t *info, VFSFile *fd)
528 { 528 {
529 if (fd == NULL || info == NULL) return FALSE; 529 if (fd == NULL || info == NULL) return FALSE;
530 AUDDBG("f: audmad_fill_info(): %s", fd->uri); 530 AUDDBG("f: audmad_fill_info(): %s\n", fd->uri);
531 531
532 if (input_init(info, fd->uri, fd) == FALSE) { 532 if (input_init(info, fd->uri, fd) == FALSE) {
533 AUDDBG("audmad_fill_info(): error initialising input"); 533 AUDDBG("audmad_fill_info(): error initialising input\n");
534 return FALSE; 534 return FALSE;
535 } 535 }
536 536
537 info->fileinfo_request = FALSE; /* we don't need to read tuple again */ 537 info->fileinfo_request = FALSE; /* we don't need to read tuple again */
538 return input_get_info(info, aud_vfs_is_remote(fd->uri) ? TRUE : audmad_config.fast_play_time_calc); 538 return input_get_info(info, aud_vfs_is_remote(fd->uri) ? TRUE : audmad_config.fast_play_time_calc);
619 gboolean local_fd = FALSE; 619 gboolean local_fd = FALSE;
620 int length; 620 int length;
621 621
622 #ifdef AUD_DEBUG 622 #ifdef AUD_DEBUG
623 string = aud_str_to_utf8(filename); 623 string = aud_str_to_utf8(filename);
624 AUDDBG("f: mad: audmad_get_song_tuple: %s", string); 624 AUDDBG("f: mad: audmad_get_song_tuple: %s\n", string);
625 g_free(string); 625 g_free(string);
626 string = NULL; 626 string = NULL;
627 #endif 627 #endif
628 628
629 /* isn't is obfuscated? --eugene */ 629 /* isn't is obfuscated? --eugene */
633 gchar *tmp = NULL; 633 gchar *tmp = NULL;
634 tuple = aud_tuple_new_from_filename(filename); 634 tuple = aud_tuple_new_from_filename(filename);
635 635
636 #ifdef AUD_DEBUG 636 #ifdef AUD_DEBUG
637 if(info.playback) 637 if(info.playback)
638 AUDDBG("info.playback->playing = %d",info.playback->playing); 638 AUDDBG("info.playback->playing = %d\n",info.playback->playing);
639 #endif 639 #endif
640 tmp = aud_vfs_get_metadata(info.infile ? info.infile : fd, "track-name"); 640 tmp = aud_vfs_get_metadata(info.infile ? info.infile : fd, "track-name");
641 if(tmp){ 641 if(tmp){
642 gchar *scratch; 642 gchar *scratch;
643 643
658 g_free(scratch); 658 g_free(scratch);
659 659
660 tmp = NULL; 660 tmp = NULL;
661 } 661 }
662 662
663 AUDDBG("audmad_get_song_tuple: track_name = %s", aud_tuple_get_string(tuple, -1, "track-name")); 663 AUDDBG("audmad_get_song_tuple: track_name = %s\n", aud_tuple_get_string(tuple, -1, "track-name"));
664 AUDDBG("audmad_get_song_tuple: stream_name = %s", aud_tuple_get_string(tuple, -1, "stream-name")); 664 AUDDBG("audmad_get_song_tuple: stream_name = %s\n", aud_tuple_get_string(tuple, -1, "stream-name"));
665 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1); 665 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1);
666 aud_tuple_associate_int(tuple, FIELD_MTIME, NULL, 0); // this indicates streaming 666 aud_tuple_associate_int(tuple, FIELD_MTIME, NULL, 0); // this indicates streaming
667 AUDDBG("get_song_tuple: remote: tuple"); 667 AUDDBG("get_song_tuple: remote: tuple\n");
668 return tuple; 668 return tuple;
669 } 669 }
670 AUDDBG("get_song_tuple: remote: NULL"); 670 AUDDBG("get_song_tuple: remote: NULL\n");
671 } /* info.remote */ 671 } /* info.remote */
672 672
673 // if !fd, pre-open the file with aud_vfs_fopen() and reuse fd. 673 // if !fd, pre-open the file with aud_vfs_fopen() and reuse fd.
674 if(!fd) { 674 if(!fd) {
675 fd = aud_vfs_fopen(filename, "rb"); 675 fd = aud_vfs_fopen(filename, "rb");
725 string = NULL; 725 string = NULL;
726 } 726 }
727 // genre 727 // genre
728 __set_and_free(tuple, FIELD_GENRE, NULL, input_id3_get_string(tag, ID3_FRAME_GENRE)); 728 __set_and_free(tuple, FIELD_GENRE, NULL, input_id3_get_string(tag, ID3_FRAME_GENRE));
729 __set_and_free(tuple, FIELD_COMMENT, NULL, input_id3_get_string(tag, ID3_FRAME_COMMENT)); 729 __set_and_free(tuple, FIELD_COMMENT, NULL, input_id3_get_string(tag, ID3_FRAME_COMMENT));
730 AUDDBG("genre = %s", aud_tuple_get_string(tuple, FIELD_GENRE, NULL)); 730 AUDDBG("genre = %s\n", aud_tuple_get_string(tuple, FIELD_GENRE, NULL));
731 } 731 }
732 id3_file_close(id3file); 732 id3_file_close(id3file);
733 } // id3file 733 } // id3file
734 else { // no id3tag 734 else { // no id3tag
735 __set_and_free(tuple, FIELD_FILE_NAME, NULL, aud_uri_to_display_basename(filename)); 735 __set_and_free(tuple, FIELD_FILE_NAME, NULL, aud_uri_to_display_basename(filename));
753 input_term(&myinfo); 753 input_term(&myinfo);
754 754
755 if(local_fd) 755 if(local_fd)
756 aud_vfs_fclose(fd); 756 aud_vfs_fclose(fd);
757 757
758 AUDDBG("e: mad: audmad_get_song_tuple"); 758 AUDDBG("e: mad: audmad_get_song_tuple\n");
759 return tuple; 759 return tuple;
760 } 760 }
761 761
762 static Tuple *audmad_get_song_tuple(char *filename) 762 static Tuple *audmad_get_song_tuple(char *filename)
763 { 763 {