Changeset 468 for audacious-musepack
- Timestamp:
- 08/21/10 19:01:58 (14 years ago)
- Location:
- audacious-musepack/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
audacious-musepack/trunk/CMakeLists.txt
r456 r468 24 24 ) 25 25 26 FIND_PATH(AUD_ INPUT_PLUGIN_DIR Input26 FIND_PATH(AUD_PLUGIN_DIR Input 27 27 /usr/local/lib/audacious 28 28 /usr/lib/audacious … … 41 41 SET_TARGET_PROPERTIES(musepack PROPERTIES PREFIX "") 42 42 43 install(TARGETS musepack LIBRARY DESTINATION "${AUD_ INPUT_PLUGIN_DIR}/Input/")43 install(TARGETS musepack LIBRARY DESTINATION "${AUD_PLUGIN_DIR}/Input/") -
audacious-musepack/trunk/libmpc.cpp
r456 r468 48 48 static Widgets widgets = {0}; 49 49 static MpcDecoder mpcDecoder = {0}; 50 static TrackInfo track= {0};50 static mpc_streaminfo streamInfo = {0}; 51 51 52 52 static GThread *threadHandle; … … 268 268 } 269 269 270 static gint mpcIsOurFD( gchar* p_Filename, VFSFile* file)270 static gint mpcIsOurFD(const gchar* p_Filename, VFSFile* file) 271 271 { 272 272 gchar magic[4]; … … 283 283 mpcDecoder.offset = -1; 284 284 mpcDecoder.isAlive = true; 285 mpcDecoder.isOutput = false;286 285 mpcDecoder.isPause = false; 287 286 threadHandle = g_thread_self(); … … 292 291 { 293 292 mpcDecoder.isAlive = false; 294 if (threadHandle)295 {296 g_thread_join(threadHandle);297 if (mpcDecoder.isOutput)298 {299 data->output->buffer_free();300 data->output->close_audio();301 mpcDecoder.isOutput = false;302 }303 }304 293 } 305 294 … … 424 413 } 425 414 426 static Tuple *mpcGetTuple( gchar* p_Filename, VFSFile *input)415 static Tuple *mpcGetTuple(const gchar* p_Filename, VFSFile *input) 427 416 { 428 417 Tuple *tuple = 0; … … 451 440 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, static_cast<int> (1000 * mpc_streaminfo_get_length(&info))); 452 441 453 //gchar *scratch = g_strdup_printf("Musepack v%d (encoder %s)", info.stream_version, info.encoder);454 //aud_tuple_associate_string(tuple, FIELD_CODEC, NULL, scratch);455 //g_free(scratch);456 457 //scratch = g_strdup_printf("lossy (%s)", info.profile_name);458 //aud_tuple_associate_string(tuple, FIELD_QUALITY, NULL, scratch);459 //g_free(scratch);442 gchar *scratch = g_strdup_printf("Musepack v%d (encoder %s)", info.stream_version, info.encoder); 443 aud_tuple_associate_string(tuple, FIELD_CODEC, NULL, scratch); 444 g_free(scratch); 445 446 scratch = g_strdup_printf("lossy (%s)", info.profile_name); 447 aud_tuple_associate_string(tuple, FIELD_QUALITY, NULL, scratch); 448 g_free(scratch); 460 449 461 450 aud_tuple_associate_int(tuple, FIELD_BITRATE, NULL, static_cast<int> (info.average_bitrate / 1000)); … … 463 452 MpcInfo tags = getTags(p_Filename); 464 453 465 //aud_tuple_associate_string(tuple, FIELD_DATE, NULL, tags.date);466 //aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, tags.title);467 //aud_tuple_associate_string(tuple, FIELD_ARTIST, NULL, tags.artist);468 //aud_tuple_associate_string(tuple, FIELD_ALBUM, NULL, tags.album);469 //aud_tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, tags.track);470 //aud_tuple_associate_int(tuple, FIELD_YEAR, NULL, tags.year);471 //aud_tuple_associate_string(tuple, FIELD_GENRE, NULL, tags.genre);472 //aud_tuple_associate_string(tuple, FIELD_COMMENT, NULL, tags.comment);454 aud_tuple_associate_string(tuple, FIELD_DATE, NULL, tags.date); 455 aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, tags.title); 456 aud_tuple_associate_string(tuple, FIELD_ARTIST, NULL, tags.artist); 457 aud_tuple_associate_string(tuple, FIELD_ALBUM, NULL, tags.album); 458 aud_tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, tags.track); 459 aud_tuple_associate_int(tuple, FIELD_YEAR, NULL, tags.year); 460 aud_tuple_associate_string(tuple, FIELD_GENRE, NULL, tags.genre); 461 aud_tuple_associate_string(tuple, FIELD_COMMENT, NULL, tags.comment); 473 462 474 463 freeTags(tags); … … 480 469 } 481 470 482 static Tuple *mpcProbeForTuple( gchar* p_Filename, VFSFile *input)471 static Tuple *mpcProbeForTuple(const gchar* p_Filename, VFSFile *input) 483 472 { 484 473 return mpcGetTuple(p_Filename, input); 485 474 } 486 475 487 static Tuple *mpcGetSongTuple( gchar* p_Filename)476 static Tuple *mpcGetSongTuple(const gchar* p_Filename) 488 477 { 489 478 return mpcGetTuple(p_Filename, 0); 490 }491 492 static char* mpcGenerateTitle(const MpcInfo& p_Tags, gchar* p_Filename)493 {494 Tuple* tuple = mpcGetSongTuple(p_Filename);495 496 gchar* title = aud_tuple_formatter_make_title_string(tuple, aud_get_gentitle_format());497 498 aud_tuple_free((void *) tuple);499 return title;500 479 } 501 480 … … 550 529 } 551 530 552 static void mpcFileInfoBox(c har* p_Filename)531 static void mpcFileInfoBox(const gchar* p_Filename) 553 532 { 554 533 GtkWidget* infoBox = widgets.infoBox; … … 737 716 static void* endThread(gchar* p_FileName, VFSFile * p_FileHandle, bool release) 738 717 { 739 if (release)718 if (release) 740 719 lockRelease(); 741 if (mpcDecoder.isError)720 if (mpcDecoder.isError) 742 721 { 743 722 perror(mpcDecoder.isError); … … 748 727 if(p_FileHandle) 749 728 aud_vfs_fclose(p_FileHandle); 750 if(track.display)751 {752 g_free(track.display);753 track.display = NULL;754 }755 729 return 0; 756 730 } … … 766 740 if (info.bits == -1) return -1; // end of stream 767 741 768 copyBuffer(sampleBuffer, xmmsBuffer, info.samples * track.channels);742 copyBuffer(sampleBuffer, xmmsBuffer, info.samples * streamInfo.channels); 769 743 770 744 if (pluginConfig.dynamicBitrate) 771 745 { 772 track.bitrate = static_cast<int> (info.bits * track.sampleFreq / 1152);746 mpcDecoder.dynbitrate = info.bits * streamInfo.sample_freq / 1152; 773 747 } 774 748 775 playback-> pass_audio(playback, FMT_S16_LE, track.channels, info.samples * 2 * track.channels, xmmsBuffer, NULL);749 playback->output->write_audio(xmmsBuffer, info.samples * 2 * streamInfo.channels); 776 750 return info.samples; 777 751 } … … 798 772 } 799 773 800 mpc_streaminfo info; 801 mpc_demux_get_info(demux, &info); 802 803 MpcInfo tags = getTags(filename); 804 track.display = mpcGenerateTitle(tags, filename); 805 track.length = static_cast<int> (1000 * mpc_streaminfo_get_length(&info)); 806 track.bitrate = static_cast<int> (info.average_bitrate); 807 track.sampleFreq = info.sample_freq; 808 track.channels = info.channels; 809 freeTags(tags); 810 811 data->set_params(data, track.display, track.length, track.bitrate, track.sampleFreq, track.channels); 774 mpc_demux_get_info(demux, &streamInfo); 775 776 data->set_tuple(data, mpcGetTuple(data->filename, input)); 777 data->set_params(data, 0, 0, static_cast<int> (streamInfo.average_bitrate), 778 streamInfo.sample_freq, streamInfo.channels); 812 779 813 780 mpc_set_replay_level(demux, MPC_OLD_GAIN_REF, pluginConfig.replaygain, … … 817 784 char xmmsBuffer[MPC_DECODER_BUFFER_LENGTH * 4]; 818 785 819 if (!data->output->open_audio(FMT_S16_LE, track.sampleFreq, track.channels))786 if (!data->output->open_audio(FMT_S16_LE, streamInfo.sample_freq, streamInfo.channels)) 820 787 { 821 788 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to open an audio output"); … … 823 790 } 824 791 825 mpcDecoder.isOutput = true;826 792 lockRelease(); 827 793 … … 829 795 data->playing = TRUE; 830 796 831 gint counter = 2 * track.sampleFreq / 3;797 gint counter = 2 * streamInfo.sample_freq / 3; 832 798 int status = 0; 833 799 while (mpcDecoder.isAlive) … … 837 803 if (mpcDecoder.offset != -1) 838 804 { 839 mpc_demux_seek_sample(demux, mpcDecoder.offset * track.sampleFreq / 1000);805 mpc_demux_seek_sample(demux, mpcDecoder.offset * streamInfo.sample_freq / 1000); 840 806 data->output->flush(mpcDecoder.offset); 841 807 mpcDecoder.offset = -1; 842 808 } 843 844 short iPlaying = data->output->buffer_playing()? 1 : 0; 845 gint iFree = data->output->buffer_free(); 846 if (!mpcDecoder.isPause && iFree >= ((1152 * 4) << iPlaying) && status != -1) 809 lockRelease(); 810 811 if (mpcDecoder.isPause == FALSE && status != -1) 847 812 { 848 813 status = processBuffer(data, sampleBuffer, xmmsBuffer, demux); 849 lockRelease();850 814 851 815 if(pluginConfig.dynamicBitrate) … … 854 818 if(counter < 0) 855 819 { 856 data->set_params(data, track.display, track.length, track.bitrate, track.sampleFreq, track.channels);857 counter = 2 * track.sampleFreq / 3;820 data->set_params(data, 0, 0, mpcDecoder.dynbitrate, streamInfo.sample_freq, streamInfo.channels); 821 counter = 2 * streamInfo.sample_freq / 3; 858 822 } 859 823 } … … 861 825 else 862 826 { 863 lockRelease();864 827 if (mpcDecoder.isPause == FALSE && status == -1 && 865 828 data->output->buffer_playing() == FALSE) … … 868 831 } 869 832 } 833 data->output->close_audio(); 870 834 mpc_demux_exit(demux); 871 835 return endThread(filename, input, false); … … 882 846 mpcAboutBox, // about : Show About box 883 847 mpcConfigBox, // configure : Show Configure box 884 TRUE, // enabled 848 0, // PluginPreferences *settings 849 850 0, // gboolean have_subtune : Plugin supports/uses subtunes. 851 (gchar **)mpc_fmts, // vfs_extensions 852 0, // GList *(*scan_dir) (gchar * dirname); 885 853 0, // is_our_file 886 0, // scan_dir 854 mpcIsOurFD, // is_our_file_from_vfs 855 mpcProbeForTuple, // Tuple *(*probe_for_tuple)(gchar *uri, VFSFile *fd); 887 856 mpcPlay, // play_file 888 857 mpcStop, // stop 889 858 mpcPause, // pause 890 859 mpcSeek, // seek 860 mpcSeekm, // void (*mseek) (InputPlayback * playback, gulong millisecond); 891 861 0, // get_time 892 862 0, // get_volume 893 863 0, // set_volume 894 0, // get_vis_type 895 0, // add_vis_pcm 896 0, // set_info 897 0, // set_info_text 898 0, // get_song_info : Get Title String callback 899 mpcFileInfoBox, // file_info_box : Show File Info Box 864 mpcFileInfoBox, // file_info_box : Show File Info Box 900 865 mpcGetSongTuple, // get_song_tuple : Acquire tuple for song 901 mpcIsOurFD, // is_our_file_from_vfs 902 (gchar **)mpc_fmts, // vfs_extensions 903 904 /* Added in Audacious 1.4.0 */ 905 mpcSeekm, // void (*mseek) (InputPlayback * playback, gulong millisecond); 906 mpcProbeForTuple, // Tuple *(*probe_for_tuple)(gchar *uri, VFSFile *fd); 907 908 /* Added in Audacious 1.4.1 */ 909 // gboolean have_subtune; 910 911 /* Added in Audacious 1.5.0 */ 912 // gboolean (*update_song_tuple)(Tuple *tuple, VFSFile *fd); 866 0, // gboolean (*update_song_tuple)(Tuple *tuple, VFSFile *fd); 867 0 //gint priority; /* 0 = first, 10 = last */ 913 868 }; 914 869 -
audacious-musepack/trunk/libmpc.h
r456 r468 59 59 { 60 60 gchar* isError; 61 unsigned dynbitrate; 61 62 long long offset; 62 bool isOutput;63 63 bool isAlive; 64 64 bool isPause; 65 };66 67 struct TrackInfo68 {69 gint bitrate;70 gchar* display;71 gint length;72 gint sampleFreq;73 gint channels;74 65 }; 75 66
Note: See TracChangeset
for help on using the changeset viewer.