Mercurial > audlegacy-plugins
comparison src/sid/xmms-sid.c @ 1688:d6d8e3cd23c5
Branch merge.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 06 Sep 2007 03:03:03 +0300 |
parents | d158ce84fda7 75b8e7737bcd |
children | 75e0c0e13ed3 |
comparison
equal
deleted
inserted
replaced
1687:d158ce84fda7 | 1688:d6d8e3cd23c5 |
---|---|
86 */ | 86 */ |
87 t_xs_status xs_status; | 87 t_xs_status xs_status; |
88 XS_MUTEX(xs_status); | 88 XS_MUTEX(xs_status); |
89 static XS_THREAD_T xs_decode_thread; | 89 static XS_THREAD_T xs_decode_thread; |
90 | 90 |
91 Tuple * xs_get_song_tuple_info(gchar *songFilename, gint subTune); | 91 void xs_get_song_tuple_info(Tuple *pResult, t_xs_tuneinfo *pInfo, gint subTune); |
92 | 92 |
93 /* | 93 /* |
94 * Error messages | 94 * Error messages |
95 */ | 95 */ |
96 void xs_error(const char *fmt, ...) | 96 void xs_error(const char *fmt, ...) |
458 audioOpen = TRUE; | 458 audioOpen = TRUE; |
459 | 459 |
460 /* Set song information for current subtune */ | 460 /* Set song information for current subtune */ |
461 XSDEBUG("foobar #1\n"); | 461 XSDEBUG("foobar #1\n"); |
462 xs_status.sidPlayer->plrUpdateSIDInfo(&xs_status); | 462 xs_status.sidPlayer->plrUpdateSIDInfo(&xs_status); |
463 XSDEBUG("foobar #2\n"); | |
464 XS_MUTEX_UNLOCK(xs_status); | 463 XS_MUTEX_UNLOCK(xs_status); |
465 tmpTuple = xs_get_song_tuple_info(tmpTune->sidFilename, xs_status.currSong); | 464 tmpTuple = tuple_new_from_filename(tmpTune->sidFilename); |
466 XSDEBUG("foobar #3\n"); | 465 xs_get_song_tuple_info(tmpTuple, tmpTune, xs_status.currSong); |
467 tmpTitle = tuple_formatter_process_string(tmpTuple, get_gentitle_format()); | 466 |
467 tmpTitle = tuple_formatter_process_string(tmpTuple, | |
468 xs_cfg.titleOverride ? xs_cfg.titleFormat : get_gentitle_format()); | |
468 | 469 |
469 XSDEBUG("foobar #4\n"); | 470 XSDEBUG("foobar #4\n"); |
470 XS_MUTEX_LOCK(xs_status); | 471 XS_MUTEX_LOCK(xs_status); |
471 xs_plugin_ip.set_info( | 472 xs_plugin_ip.set_info( |
472 tmpTitle, | 473 tmpTitle, |
653 } | 654 } |
654 | 655 |
655 | 656 |
656 /* Return song information Tuple | 657 /* Return song information Tuple |
657 */ | 658 */ |
658 Tuple * xs_get_song_tuple_info(gchar *songFilename, gint subTune) | 659 void xs_get_song_tuple_info(Tuple *pResult, t_xs_tuneinfo *pInfo, gint subTune) |
659 { | 660 { |
660 t_xs_tuneinfo *pInfo; | 661 gchar *tmpStr, tmpStr2[64]; |
661 Tuple *pResult; | 662 |
662 gchar *tmpStr; | 663 tuple_associate_string(pResult, FIELD_TITLE, NULL, pInfo->sidName); |
663 | 664 tuple_associate_string(pResult, FIELD_ARTIST, NULL, pInfo->sidComposer); |
664 pResult = tuple_new_from_filename(songFilename); | 665 tuple_associate_string(pResult, FIELD_GENRE, NULL, "SID-tune"); |
665 | 666 tuple_associate_string(pResult, FIELD_COPYRIGHT, NULL, pInfo->sidCopyright); |
666 /* Get tune information from emulation engine */ | 667 |
667 XS_MUTEX_LOCK(xs_status); | 668 tuple_associate_int(pResult, -1, "subtunes", pInfo->nsubTunes); |
668 pInfo = xs_status.sidPlayer->plrGetSIDInfo(songFilename); | |
669 if (!pInfo) { | |
670 XS_MUTEX_UNLOCK(xs_status); | |
671 return pResult; | |
672 } | |
673 XS_MUTEX_UNLOCK(xs_status); | |
674 | |
675 tuple_associate_string(pResult, FIELD_TITLE, "title", pInfo->sidName); | |
676 tuple_associate_string(pResult, FIELD_ARTIST, "artist", pInfo->sidComposer); | |
677 tuple_associate_string(pResult, FIELD_GENRE, "genre", "SID-tune"); | |
678 tuple_associate_string(pResult, FIELD_COPYRIGHT, "copyright", pInfo->sidCopyright); | |
679 tuple_associate_string(pResult, -1, "sid-format", pInfo->sidFormat); | 669 tuple_associate_string(pResult, -1, "sid-format", pInfo->sidFormat); |
680 tuple_associate_int(pResult, -1, "subtunes", pInfo->nsubTunes); | |
681 | 670 |
682 switch (pInfo->sidModel) { | 671 switch (pInfo->sidModel) { |
683 case XS_SIDMODEL_6581: tmpStr = "6581"; break; | 672 case XS_SIDMODEL_6581: tmpStr = "6581"; break; |
684 case XS_SIDMODEL_8580: tmpStr = "8580"; break; | 673 case XS_SIDMODEL_8580: tmpStr = "8580"; break; |
685 case XS_SIDMODEL_ANY: tmpStr = "ANY"; break; | 674 case XS_SIDMODEL_ANY: tmpStr = "ANY"; break; |
686 default: tmpStr = "?"; break; | 675 default: tmpStr = "?"; break; |
687 } | 676 } |
688 tuple_associate_string(pResult, -1, "sid-model", tmpStr); | 677 tuple_associate_string(pResult, -1, "sid-model", tmpStr); |
689 | 678 |
690 /* Get sub-tune information, if available */ | 679 /* Get sub-tune information, if available */ |
691 if (subTune < 0 || pInfo->startTune > pInfo->nsubTunes) | 680 if (subTune < 0 || pInfo->startTune > pInfo->nsubTunes) |
692 subTune = pInfo->startTune; | 681 subTune = pInfo->startTune; |
693 | 682 |
694 if ((subTune > 0) && (subTune <= pInfo->nsubTunes)) { | 683 if ((subTune > 0) && (subTune <= pInfo->nsubTunes)) { |
695 gint tmpInt = pInfo->subTunes[subTune - 1].tuneLength; | 684 gint tmpInt = pInfo->subTunes[subTune - 1].tuneLength; |
696 tuple_associate_int(pResult, FIELD_LENGTH, "length", (tmpInt < 0) ? -1 : tmpInt * 1000); | 685 tuple_associate_int(pResult, FIELD_LENGTH, NULL, (tmpInt < 0) ? -1 : tmpInt * 1000); |
686 | |
687 tmpInt = pInfo->subTunes[subTune - 1].tuneSpeed; | |
688 if (tmpInt > 0) { | |
689 switch (tmpInt) { | |
690 case XS_CLOCK_PAL: tmpStr = "PAL"; break; | |
691 case XS_CLOCK_NTSC: tmpStr = "NTSC"; break; | |
692 case XS_CLOCK_ANY: tmpStr = "ANY"; break; | |
693 case XS_CLOCK_VBI: tmpStr = "VBI"; break; | |
694 case XS_CLOCK_CIA: tmpStr = "CIA"; break; | |
695 default: | |
696 g_snprintf(tmpStr2, sizeof(tmpStr2), "%dHz", tmpInt); | |
697 tmpStr = tmpStr2; | |
698 break; | |
699 } | |
700 } else | |
701 tmpStr = "?"; | |
702 | |
703 tuple_associate_string(pResult, -1, "sid-speed", tmpStr); | |
697 } else | 704 } else |
698 subTune = 1; | 705 subTune = 1; |
699 | 706 |
700 tuple_associate_int(pResult, -1, "subtune", subTune); | 707 tuple_associate_int(pResult, -1, "subtune", subTune); |
701 tuple_associate_int(pResult, FIELD_TRACK_NUMBER, "track-number", subTune); | 708 tuple_associate_int(pResult, FIELD_TRACK_NUMBER, NULL, subTune); |
702 | 709 |
703 /* Free tune information */ | 710 if (xs_cfg.titleOverride) |
704 xs_tuneinfo_free(pInfo); | 711 tuple_associate_string(pResult, FIELD_FORMATTER, NULL, xs_cfg.titleFormat); |
705 return pResult; | |
706 } | 712 } |
707 | 713 |
708 Tuple * xs_get_song_tuple(gchar *songFilename) | 714 Tuple * xs_get_song_tuple(gchar *songFilename) |
709 { | 715 { |
710 Tuple *pResult; | 716 Tuple *tmpResult; |
711 gchar *tmpFilename; | 717 gchar *tmpFilename; |
718 t_xs_tuneinfo *tmpInfo; | |
712 gint subTune; | 719 gint subTune; |
713 | 720 |
721 /* Get information from URL */ | |
714 xs_get_trackinfo(songFilename, &tmpFilename, &subTune); | 722 xs_get_trackinfo(songFilename, &tmpFilename, &subTune); |
715 pResult = xs_get_song_tuple_info(tmpFilename, subTune); | 723 |
724 tmpResult = tuple_new_from_filename(tmpFilename); | |
725 if (!tmpResult) { | |
726 g_free(tmpFilename); | |
727 return NULL; | |
728 } | |
729 | |
730 /* Get tune information from emulation engine */ | |
731 XS_MUTEX_LOCK(xs_status); | |
732 tmpInfo = xs_status.sidPlayer->plrGetSIDInfo(tmpFilename); | |
733 XS_MUTEX_UNLOCK(xs_status); | |
716 g_free(tmpFilename); | 734 g_free(tmpFilename); |
717 | 735 |
718 return pResult; | 736 if (!tmpInfo) |
719 } | 737 return tmpResult; |
738 | |
739 xs_get_song_tuple_info(tmpResult, tmpInfo, subTune); | |
740 xs_tuneinfo_free(tmpInfo); | |
741 | |
742 return tmpResult; | |
743 } |