Mercurial > audlegacy-plugins
comparison src/madplug/plugin.c @ 1328:38fb3bb3e21e
- make probing for tuple completely reuse fd.
- fix bugs in __audmad_get_song_tuple() against remote sources.
| author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
|---|---|
| date | Sun, 22 Jul 2007 04:28:20 +0900 |
| parents | e991d29a9c9a |
| children | 4b07404814ca |
comparison
equal
deleted
inserted
replaced
| 1327:4f9bea634312 | 1328:38fb3bb3e21e |
|---|---|
| 445 g_message("playing %s", tmp); | 445 g_message("playing %s", tmp); |
| 446 g_free(tmp); | 446 g_free(tmp); |
| 447 } | 447 } |
| 448 #endif /* DEBUG */ | 448 #endif /* DEBUG */ |
| 449 | 449 |
| 450 if (input_init(&info, url) == FALSE) { | 450 if (input_init(&info, url, NULL) == FALSE) { |
| 451 g_message("error initialising input"); | 451 g_message("error initialising input"); |
| 452 return; | 452 return; |
| 453 } | 453 } |
| 454 | 454 |
| 455 // remote access must use fast scan. | 455 // remote access must use fast scan. |
| 504 gchar *tmp = g_filename_to_utf8(url, -1, NULL, NULL, NULL); | 504 gchar *tmp = g_filename_to_utf8(url, -1, NULL, NULL, NULL); |
| 505 g_message("f: audmad_get_song_info: %s", tmp); | 505 g_message("f: audmad_get_song_info: %s", tmp); |
| 506 g_free(tmp); | 506 g_free(tmp); |
| 507 #endif /* DEBUG */ | 507 #endif /* DEBUG */ |
| 508 | 508 |
| 509 if (input_init(&myinfo, url) == FALSE) { | 509 if (input_init(&myinfo, url, NULL) == FALSE) { |
| 510 #ifdef DEBUG | 510 #ifdef DEBUG |
| 511 g_message("error initialising input"); | 511 g_message("error initialising input"); |
| 512 #endif | 512 #endif |
| 513 return; | 513 return; |
| 514 } | 514 } |
| 523 else | 523 else |
| 524 *length = myinfo.tuple->length; | 524 *length = myinfo.tuple->length; |
| 525 } | 525 } |
| 526 else { | 526 else { |
| 527 *title = strdup(url); | 527 *title = strdup(url); |
| 528 *length = -1; | |
| 529 } | |
| 530 input_term(&myinfo); | |
| 531 #ifdef DEBUG | |
| 532 g_message("e: audmad_get_song_info"); | |
| 533 #endif /* DEBUG */ | |
| 534 } | |
| 535 | |
| 536 static void | |
| 537 audmad_get_song_length(char *url, int *length, VFSFile *fd) | |
| 538 { | |
| 539 struct mad_info_t myinfo; | |
| 540 #ifdef DEBUG | |
| 541 gchar *tmp = g_filename_to_utf8(url, -1, NULL, NULL, NULL); | |
| 542 g_message("f: audmad_get_song_length: %s", tmp); | |
| 543 g_free(tmp); | |
| 544 #endif /* DEBUG */ | |
| 545 | |
| 546 if (input_init(&myinfo, url, fd ? fd : NULL) == FALSE) { | |
| 547 #ifdef DEBUG | |
| 548 g_message("error initialising input"); | |
| 549 #endif | |
| 550 return; | |
| 551 } | |
| 552 | |
| 553 if (input_get_info(&myinfo, info.remote ? TRUE : audmad_config.fast_play_time_calc) == TRUE) { | |
| 554 if(myinfo.tuple->length == -1) | |
| 555 *length = mad_timer_count(myinfo.duration, MAD_UNITS_MILLISECONDS); | |
| 556 else | |
| 557 *length = myinfo.tuple->length; | |
| 558 } | |
| 559 else { | |
| 528 *length = -1; | 560 *length = -1; |
| 529 } | 561 } |
| 530 input_term(&myinfo); | 562 input_term(&myinfo); |
| 531 #ifdef DEBUG | 563 #ifdef DEBUG |
| 532 g_message("e: audmad_get_song_info"); | 564 g_message("e: audmad_get_song_info"); |
| 615 | 647 |
| 616 if(info.remote && mad_timer_count(info.duration, MAD_UNITS_SECONDS) <= 0){ | 648 if(info.remote && mad_timer_count(info.duration, MAD_UNITS_SECONDS) <= 0){ |
| 617 if(fd || (info.playback && info.playback->playing)) { | 649 if(fd || (info.playback && info.playback->playing)) { |
| 618 gchar *tmp = NULL; | 650 gchar *tmp = NULL; |
| 619 tuple = bmp_title_input_new(); | 651 tuple = bmp_title_input_new(); |
| 620 #ifdef DEBUG | 652 |
| 621 g_message("info.playback->playing = %d",info.playback->playing); | 653 #ifdef DEBUG |
| 622 #endif | 654 if(info.playback) |
| 623 tmp = vfs_get_metadata(info.infile, "track-name"); | 655 g_message("info.playback->playing = %d",info.playback->playing); |
| 656 #endif | |
| 657 tmp = vfs_get_metadata(info.infile ? info.infile : fd, "track-name"); | |
| 624 if(tmp){ | 658 if(tmp){ |
| 625 tuple->track_name = str_to_utf8(tmp); | 659 tuple->track_name = str_to_utf8(tmp); |
| 626 g_free(tmp); | 660 g_free(tmp); |
| 627 tmp = NULL; | 661 tmp = NULL; |
| 628 } | 662 } |
| 629 tmp = vfs_get_metadata(info.infile, "stream-name"); | 663 tmp = vfs_get_metadata(info.infile ? info.infile : fd, "stream-name"); |
| 630 if(tmp){ | 664 if(tmp){ |
| 631 tuple->album_name = str_to_utf8(tmp); | 665 tuple->album_name = str_to_utf8(tmp); |
| 632 g_free(tmp); | 666 g_free(tmp); |
| 633 tmp = NULL; | 667 tmp = NULL; |
| 634 } | 668 } |
| 669 | |
| 635 #ifdef DEBUG | 670 #ifdef DEBUG |
| 636 g_message("audmad_get_song_tuple: track_name = %s", tuple->track_name); | 671 g_message("audmad_get_song_tuple: track_name = %s", tuple->track_name); |
| 637 g_message("audmad_get_song_tuple: stream_name = %s", tuple->album_name); | 672 g_message("audmad_get_song_tuple: stream_name = %s", tuple->album_name); |
| 638 #endif | 673 #endif |
| 639 realfn = g_filename_from_uri(filename, NULL, NULL); | 674 realfn = g_filename_from_uri(filename, NULL, NULL); |
| 651 } | 686 } |
| 652 #ifdef DEBUG | 687 #ifdef DEBUG |
| 653 g_message("get_song_tuple: remote: NULL"); | 688 g_message("get_song_tuple: remote: NULL"); |
| 654 #endif | 689 #endif |
| 655 return NULL; | 690 return NULL; |
| 656 } | 691 } /* info.remote */ |
| 657 | 692 |
| 658 tuple = bmp_title_input_new(); | 693 tuple = bmp_title_input_new(); |
| 659 | 694 |
| 660 if (!fd) | 695 if (!fd) |
| 661 id3file = id3_file_open(filename, ID3_FILE_MODE_READONLY); | 696 id3file = id3_file_open(filename, ID3_FILE_MODE_READONLY); |
| 702 string = NULL; | 737 string = NULL; |
| 703 } | 738 } |
| 704 else { | 739 else { |
| 705 char *dummy = NULL; | 740 char *dummy = NULL; |
| 706 int length = 0; | 741 int length = 0; |
| 707 audmad_get_song_info(filename, &dummy, &length); | 742 audmad_get_song_length(filename, &length, fd ? fd : NULL); |
| 708 tuple->length = length; | 743 tuple->length = length; |
| 709 g_free(dummy); | 744 g_free(dummy); |
| 710 } | 745 } |
| 711 | 746 |
| 712 // track number | 747 // track number |
| 737 // length | 772 // length |
| 738 { | 773 { |
| 739 char *dummy = NULL; | 774 char *dummy = NULL; |
| 740 int length = 0; | 775 int length = 0; |
| 741 if(tuple->length == -1) { | 776 if(tuple->length == -1) { |
| 742 audmad_get_song_info(filename, &dummy, &length); | 777 audmad_get_song_length(filename, &length, fd ? fd : NULL); |
| 743 tuple->length = length; | 778 tuple->length = length; |
| 744 } | 779 } |
| 745 g_free(dummy); | 780 g_free(dummy); |
| 746 } | 781 } |
| 747 } | 782 } |
