Changeset 102 for xmms-musepack/trunk
- Timestamp:
- 11/08/06 00:00:58 (18 years ago)
- Location:
- xmms-musepack/trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
xmms-musepack/trunk/src/libmpc.cpp
r79 r102 326 326 static void mpcGetSongInfo(char* p_Filename, char** p_Title, int* p_Length) 327 327 { 328 mpc_reader reader; 329 if (mpc_reader_init_stdio(&reader, p_Filename) == MPC_STATUS_OK) { 328 FILE* input = fopen(p_Filename, "rb"); 329 if(input) 330 { 330 331 MpcInfo tags = getTags(p_Filename); 331 332 *p_Title = mpcGenerateTitle(tags, p_Filename); 332 333 freeTags(tags); 333 334 mpc_streaminfo info; 334 mpc_streaminfo_init(&info, &reader); 335 mpc_reader_file reader; 336 mpc_reader_setup_file_reader(&reader, input); 337 mpc_streaminfo_read(&info, &reader.reader); 335 338 *p_Length = static_cast<int> (1000 * mpc_streaminfo_get_length(&info)); 336 mpc_reader_exit_stdio(&reader); 337 } else { 339 fclose(input); 340 } 341 else 342 { 338 343 char* temp = g_strdup_printf("[xmms-musepack] mpcGetSongInfo is unable to open %s\n", p_Filename); 339 344 perror(temp); … … 521 526 GtkWidget* albumGainLabel = mpcGtkLabel(infoVbox); 522 527 523 mpc_reader reader; 524 if (mpc_reader_init_stdio(&reader, p_Filename) == MPC_STATUS_OK) { 528 FILE* input = fopen(p_Filename, "rb"); 529 if(input) 530 { 525 531 mpc_streaminfo info; 526 mpc_streaminfo_init(&info, &reader); 532 mpc_reader_file reader; 533 mpc_reader_setup_file_reader(&reader, input); 534 mpc_streaminfo_read(&info, &reader.reader); 527 535 528 536 int time = static_cast<int> (mpc_streaminfo_get_length(&info)); … … 559 567 free(entry); 560 568 freeTags(tags); 561 mpc_reader_exit_stdio(&reader);569 fclose(input); 562 570 } 563 571 else … … 746 754 lockAcquire(); 747 755 const char* filename = static_cast<const char*> (data); 748 mpc_reader reader; 749 if (mpc_reader_init_stdio(&reader, filename) != MPC_STATUS_OK) { 756 FILE* input = fopen(filename, "rb"); 757 if (!input) 758 { 750 759 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to open %s", filename); 751 return endThread(0, true); 752 } 760 return endThread(input, true); 761 } 762 763 mpc_reader_file reader; 764 mpc_reader_setup_file_reader(&reader, input); 753 765 754 766 mpc_streaminfo info; 755 if (mpc_streaminfo_init(&info, &reader) != MPC_STATUS_OK) { 767 if (mpc_streaminfo_read(&info, &reader.reader) != ERROR_CODE_OK) 768 { 756 769 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to read %s", filename); 757 mpc_reader_exit_stdio(&reader); 758 return endThread(0, true); 770 return endThread(input, true); 759 771 } 760 772 … … 769 781 MpcPlugin.set_info(track.display, track.length, track.bitrate, track.sampleFreq, track.channels); 770 782 771 mpc_decoder * decoder; 772 if (mpc_decoder_init(&decoder, &reader, &info) != MPC_STATUS_OK) { 783 mpc_decoder decoder; 784 mpc_decoder_setup(&decoder, &reader.reader); 785 if (!mpc_decoder_initialize(&decoder, &info)) 786 { 773 787 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to initialize decoder on %s", filename); 774 mpc_reader_exit_stdio(&reader); 775 return endThread(0, true); 776 } 777 778 mpc_decoder_set_seeking(decoder, &info, pluginConfig.fastSeek); 779 setReplaygain(info, *decoder); 788 return endThread(input, true); 789 } 790 791 mpc_decoder_set_seeking(&decoder, &info, pluginConfig.fastSeek); 792 setReplaygain(info, decoder); 780 793 781 794 MPC_SAMPLE_FORMAT sampleBuffer[MPC_DECODER_BUFFER_LENGTH]; … … 784 797 if (!MpcPlugin.output->open_audio(FMT_S16_LE, track.sampleFreq, track.channels)) 785 798 { 786 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to open an audio output"); 787 mpc_reader_exit_stdio(&reader); 788 return endThread(0, true); 799 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to open an audio output"); 800 return endThread(input, true); 789 801 } 790 802 else … … 800 812 if (getOffset() != -1) 801 813 { 802 mpc_decoder_seek_seconds( decoder, mpcDecoder.offset);814 mpc_decoder_seek_seconds(&decoder, mpcDecoder.offset); 803 815 setOffset(-1); 804 816 } … … 809 821 if (!mpcDecoder.isPause && iFree >= ((1152 * 4) << iPlaying)) 810 822 { 811 unsigned status = processBuffer(sampleBuffer, xmmsBuffer, *decoder);823 unsigned status = processBuffer(sampleBuffer, xmmsBuffer, decoder); 812 824 if (status == (unsigned) (-1)) 813 825 { 814 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] error from internal decoder on %s", filename); 815 mpc_reader_exit_stdio(&reader); 816 return endThread(0, true); 826 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] error from internal decoder on %s", filename); 827 return endThread(input, true); 817 828 } 818 829 else if (status == 0) 819 830 { 820 831 //mpcDecoder.isError = g_strdup_printf("[xmms-musepack] null output from internal decoder on %s", filename); 821 mpc_reader_exit_stdio(&reader); 822 return endThread(0, true); 832 return endThread(input, true); 823 833 } 824 834 lockRelease(); … … 839 849 xmms_usleep(10000); 840 850 } 841 } 842 mpc_reader_exit_stdio(&reader); 843 return endThread(0, false); 851 } 852 return endThread(input, false); 844 853 } 845 854 -
xmms-musepack/trunk/src/libmpc.h
r79 r102 56 56 #include <iconv.h> 57 57 58 #undef FALSE59 #undef TRUE60 58 //libmpcdec headers 61 59 #include <mpcdec/mpcdec.h> … … 111 109 { 112 110 char* isError; 113 double offset; 111 double offset; 114 112 bool isOutput; 115 113 bool isAlive;
Note: See TracChangeset
for help on using the changeset viewer.