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