Changeset 103 for xmms-musepack/branches/r2d
- Timestamp:
- 11/08/06 00:05:52 (18 years ago)
- Location:
- xmms-musepack/branches/r2d/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
xmms-musepack/branches/r2d/src/config.h.in
r34 r103 13 13 #undef HAVE_MEMORY_H 14 14 15 /* Define to 1 if you have the <mpcdec/ config_types.h> header file. */16 #undef HAVE_MPCDEC_ CONFIG_TYPES_H15 /* Define to 1 if you have the <mpcdec/mpc_types.h> header file. */ 16 #undef HAVE_MPCDEC_MPC_TYPES_H 17 17 18 18 /* Define to 1 if stdbool.h conforms to C99. */ -
xmms-musepack/branches/r2d/src/libmpc.cpp
r79 r103 2 2 * Copyright (c) 2005, The Musepack Development Team 3 3 * All rights reserved. 4 * 4 * 5 5 * Redistribution and use in source and binary forms, with or without 6 6 * modification, are permitted provided that the following conditions are 7 7 * met: 8 * 8 * 9 9 * * Redistributions of source code must retain the above copyright 10 10 * notice, this list of conditions and the following disclaimer. 11 * 11 * 12 12 * * Redistributions in binary form must reproduce the above 13 13 * copyright notice, this list of conditions and the following 14 14 * disclaimer in the documentation and/or other materials provided 15 15 * with the distribution. 16 * 16 * 17 17 * * Neither the name of the The Musepack Development Team nor the 18 18 * names of its contributors may be used to endorse or promote 19 19 * products derived from this software without specific prior 20 20 * written permission. 21 * 21 * 22 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT … … 327 327 { 328 328 mpc_reader reader; 329 if (mpc_reader_init_stdio(&reader, p_Filename) == MPC_STATUS_OK) { 329 mpc_demux * demux; 330 if (mpc_reader_init_stdio(&reader, p_Filename) == MPC_STATUS_OK && (demux = mpc_demux_init(&reader))) { 330 331 MpcInfo tags = getTags(p_Filename); 331 332 *p_Title = mpcGenerateTitle(tags, p_Filename); 332 333 freeTags(tags); 333 mpc_streaminfo info; 334 mpc_streaminfo_init(&info, &reader); 335 *p_Length = static_cast<int> (1000 * mpc_streaminfo_get_length(&info)); 334 mpc_streaminfo info; 335 mpc_demux_get_info(demux, &info); 336 *p_Length = static_cast<int> (1000 * mpc_streaminfo_get_length(&info)); 337 mpc_demux_exit(demux); 336 338 mpc_reader_exit_stdio(&reader); 337 339 } else { … … 522 524 523 525 mpc_reader reader; 524 if (mpc_reader_init_stdio(&reader, p_Filename) == MPC_STATUS_OK) { 526 mpc_demux * demux; 527 if (mpc_reader_init_stdio(&reader, p_Filename) == MPC_STATUS_OK && (demux = mpc_demux_init(&reader))) { 525 528 mpc_streaminfo info; 526 mpc_ streaminfo_init(&info, &reader);529 mpc_demux_get_info(demux, &info); 527 530 528 531 int time = static_cast<int> (mpc_streaminfo_get_length(&info)); … … 559 562 free(entry); 560 563 freeTags(tags); 564 mpc_demux_exit(demux); 561 565 mpc_reader_exit_stdio(&reader); 562 566 } … … 750 754 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to open %s", filename); 751 755 return endThread(0, true); 752 } 753 754 mpc_streaminfo info; 755 if (mpc_streaminfo_init(&info, &reader) != MPC_STATUS_OK) { 756 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to read %s", filename); 756 } 757 758 mpc_demux * demux = 0; 759 demux = mpc_demux_init(&reader); 760 761 if ( demux == 0 ) { 762 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to initialize decoder on %s", filename); 757 763 mpc_reader_exit_stdio(&reader); 758 return endThread(0, true); 759 } 760 764 return endThread(0, true); 765 } 766 767 mpc_streaminfo info; 768 mpc_demux_get_info(demux, &info); 761 769 MpcInfo tags = getTags(filename); 762 770 track.display = mpcGenerateTitle(tags, filename); 763 764 765 766 771 track.length = static_cast<int> (1000 * mpc_streaminfo_get_length(&info)); 772 track.bitrate = static_cast<int> (info.average_bitrate); 773 track.sampleFreq = info.sample_freq; 774 track.channels = info.channels; 767 775 freeTags(tags); 768 776 769 777 MpcPlugin.set_info(track.display, track.length, track.bitrate, track.sampleFreq, track.channels); 770 778 771 mpc_decoder * decoder; 772 if (mpc_decoder_init(&decoder, &reader, &info) != MPC_STATUS_OK) { 773 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); 779 // mpc_decoder_set_seeking(decoder, &info, pluginConfig.fastSeek); 780 // setReplaygain(info, *decoder); 780 781 781 782 MPC_SAMPLE_FORMAT sampleBuffer[MPC_DECODER_BUFFER_LENGTH]; … … 795 796 lockRelease(); 796 797 797 int counter = 2 * track.sampleFreq / 3; 798 int counter = 2 * track.sampleFreq / 3; 799 unsigned status = 1; 798 800 while (isAlive()) 799 801 { 800 802 if (getOffset() != -1) 801 803 { 802 mpc_decoder_seek_seconds(decoder, mpcDecoder.offset);804 // mpc_decoder_seek_seconds(decoder, mpcDecoder.offset); 803 805 setOffset(-1); 804 806 } … … 807 809 short iPlaying = MpcPlugin.output->buffer_playing()? 1 : 0; 808 810 int iFree = MpcPlugin.output->buffer_free(); 809 if (!mpcDecoder.isPause && iFree >= ((1152 * 4) << iPlaying) )811 if (!mpcDecoder.isPause && iFree >= ((1152 * 4) << iPlaying) && status != 0) 810 812 { 811 unsigned status = processBuffer(sampleBuffer, xmmsBuffer, *decoder); 812 if (status == (unsigned) (-1)) 813 { 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); 817 } 818 else if (status == 0) 819 { 820 //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); 823 } 824 lockRelease(); 825 826 if(pluginConfig.dynamicBitrate) 827 { 828 counter -= status; 829 if(counter < 0) 830 { 831 MpcPlugin.set_info(track.display, track.length, track.bitrate, track.sampleFreq, track.channels); 832 counter = 2 * track.sampleFreq / 3; 833 } 834 } 813 status = processBuffer(sampleBuffer, xmmsBuffer, *demux); 814 lockRelease(); 815 816 if(pluginConfig.dynamicBitrate) { 817 counter -= status; 818 if(counter < 0) { 819 MpcPlugin.set_info(track.display, track.length, track.bitrate, track.sampleFreq, track.channels); 820 counter = 2 * track.sampleFreq / 3; 821 } 822 } 835 823 } 836 824 else 837 825 { 838 lockRelease(); 826 lockRelease(); 827 if (!mpcDecoder.isPause && status == 0 && MpcPlugin.output->output_time() == 0) 828 break; 839 829 xmms_usleep(10000); 840 830 } 841 831 } 832 mpc_demux_exit(demux); 842 833 mpc_reader_exit_stdio(&reader); 843 834 return endThread(0, false); 844 835 } 845 836 846 static int processBuffer(MPC_SAMPLE_FORMAT* sampleBuffer, char* xmmsBuffer, mpc_de coder& decoder)837 static int processBuffer(MPC_SAMPLE_FORMAT* sampleBuffer, char* xmmsBuffer, mpc_demux& demux) 847 838 { 848 839 mpc_uint32_t vbrAcc = 0; 849 840 mpc_uint32_t vbrUpd = 0; 850 851 unsigned status = mpc_decoder_decode(&decoder, sampleBuffer, &vbrAcc, &vbrUpd); 852 copyBuffer(sampleBuffer, xmmsBuffer, status); 841 mpc_frame_info info; 842 843 info.buffer = sampleBuffer; 844 mpc_demux_decode(&demux, &info); 845 copyBuffer(sampleBuffer, xmmsBuffer, info.samples); 853 846 854 847 if (pluginConfig.dynamicBitrate) … … 859 852 if (pluginConfig.isEq) 860 853 { 861 iir(xmmsBuffer, 4 * status);862 } 863 864 MpcPlugin.add_vis_pcm(MpcPlugin.output->written_time(), FMT_S16_LE, track.channels, status * 4, xmmsBuffer);865 MpcPlugin.output->write_audio(xmmsBuffer, status * 4);866 return status;854 iir(xmmsBuffer, 4 * info.samples); 855 } 856 857 MpcPlugin.add_vis_pcm(MpcPlugin.output->written_time(), FMT_S16_LE, track.channels, info.samples * 4, xmmsBuffer); 858 MpcPlugin.output->write_audio(xmmsBuffer, info.samples * 4); 859 return info.samples; 867 860 } 868 861 -
xmms-musepack/branches/r2d/src/libmpc.h
r79 r103 2 2 * Copyright (c) 2005, The Musepack Development Team 3 3 * All rights reserved. 4 * 4 * 5 5 * Redistribution and use in source and binary forms, with or without 6 6 * modification, are permitted provided that the following conditions are 7 7 * met: 8 * 8 * 9 9 * * Redistributions of source code must retain the above copyright 10 10 * notice, this list of conditions and the following disclaimer. 11 * 11 * 12 12 * * Redistributions in binary form must reproduce the above 13 13 * copyright notice, this list of conditions and the following 14 14 * disclaimer in the documentation and/or other materials provided 15 15 * with the distribution. 16 * 16 * 17 17 * * Neither the name of the The Musepack Development Team nor the 18 18 * names of its contributors may be used to endorse or promote 19 19 * products derived from this software without specific prior 20 20 * written permission. 21 * 21 * 22 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT … … 170 170 static void lockRelease(); 171 171 static void* decodeStream(void*); 172 static int processBuffer(MPC_SAMPLE_FORMAT*, char*, mpc_de coder&);172 static int processBuffer(MPC_SAMPLE_FORMAT*, char*, mpc_demux&); 173 173 static void* endThread(FILE*, bool); 174 174 static bool isAlive();
Note: See TracChangeset
for help on using the changeset viewer.