Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:ykoba:multimedia
qmmp
qmmp-MPC_OLD_API.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File qmmp-MPC_OLD_API.patch of Package qmmp
--- ./src/plugins/Input/mpc/CMakeLists.orig.txt 2020-09-20 05:48:14.000000000 +0900 +++ ./src/plugins/Input/mpc/CMakeLists.txt 2020-09-23 05:04:15.401594973 +0900 @@ -10,12 +10,19 @@ # libmpc CHECK_INCLUDE_FILE_CXX(mpc/mpcdec.h MPC_HEADER_NEW_FOUND) +IF(NOT MPC_HEADER_NEW_FOUND) +CHECK_INCLUDE_FILE_CXX(mpcdec/mpcdec.h MPC_HEADER_OLD_FOUND) +ADD_DEFINITIONS(-DMPC_OLD_API) +ENDIF(NOT MPC_HEADER_NEW_FOUND) + FIND_LIBRARY(MPC_LIB NAME mpcdec PATHS /usr/lib /usr/lib32 /usr/local/lib /usr/local/lib32) -IF(MPC_HEADER_NEW_FOUND AND (NOT MPC_LIB MATCHES "^.*-NOTFOUND")) +IF((MPC_HEADER_NEW_FOUND OR MPC_HEADER_OLD_FOUND) AND (NOT MPC_LIB MATCHES "^.*-NOTFOUND")) SET(MPC_FOUND TRUE CACHE INTERNAL "mpc") MESSAGE(STATUS "Found MusePack: ${MPC_LIB}") -ENDIF(MPC_HEADER_NEW_FOUND AND (NOT MPC_LIB MATCHES "^.*-NOTFOUND")) +ELSE((MPC_HEADER_NEW_FOUND OR MPC_HEADER_OLD_FOUND) AND (NOT MPC_LIB MATCHES "^.*-NOTFOUND")) +MESSAGE(STATUS "Could not find MusePack library") +ENDIF((MPC_HEADER_NEW_FOUND OR MPC_HEADER_OLD_FOUND) AND (NOT MPC_LIB MATCHES "^.*-NOTFOUND")) include_directories(${TAGLIB_INCLUDE_DIRS}) link_directories(${TAGLIB_LIBRARY_DIRS}) --- ./src/plugins/Input/mpc/decoder_mpc.orig.h 2020-09-20 05:48:14.000000000 +0900 +++ ./src/plugins/Input/mpc/decoder_mpc.h 2020-09-23 05:08:44.101327516 +0900 @@ -21,12 +21,21 @@ #ifndef DECODER_MPC_H #define DECODER_MPC_H +#ifdef MPC_OLD_API +#include <mpcdec/mpcdec.h> +#else #include <mpc/mpcdec.h> +#endif + #include <qmmp/decoder.h> struct mpc_data { +#ifdef MPC_OLD_API + mpc_decoder decoder; +#else mpc_demux *demuxer; +#endif mpc_reader reader; mpc_streaminfo info; }; --- ./src/plugins/Input/mpc/decoder_mpc.orig.cpp 2020-09-20 05:48:14.000000000 +0900 +++ ./src/plugins/Input/mpc/decoder_mpc.cpp 2020-10-08 04:56:26.977629219 +0900 @@ -28,33 +28,59 @@ // mpc callbacks +#ifdef MPC_OLD_API +static mpc_int32_t mpc_callback_read (void *data, void *buffer, mpc_int32_t size) +{ + DecoderMPC *dmpc = (DecoderMPC *) data; +#else static mpc_int32_t mpc_callback_read (mpc_reader *reader, void *buffer, mpc_int32_t size) { DecoderMPC *dmpc = (DecoderMPC *) reader->data; +#endif return dmpc->input()->read((char *)buffer, size); } - +#ifdef MPC_OLD_API +static mpc_bool_t mpc_callback_seek (void *data, mpc_int32_t offset) +{ + DecoderMPC *dmpc = (DecoderMPC *) data; +#else static mpc_bool_t mpc_callback_seek (mpc_reader *reader, mpc_int32_t offset) { DecoderMPC *dmpc = (DecoderMPC *) reader->data; +#endif return dmpc->input()->seek(offset); } - +#ifdef MPC_OLD_API +static mpc_int32_t mpc_callback_tell (void *data) +{ + DecoderMPC *dmpc = (DecoderMPC *) data; +#else static mpc_int32_t mpc_callback_tell (mpc_reader *reader) { DecoderMPC *dmpc = (DecoderMPC *) reader->data; +#endif return dmpc->input()->pos (); } - +#ifdef MPC_OLD_API +static mpc_bool_t mpc_callback_canseek (void *data) +{ + DecoderMPC *dmpc = (DecoderMPC *) data; +#else static mpc_bool_t mpc_callback_canseek (mpc_reader *reader) { DecoderMPC *dmpc = (DecoderMPC *) reader->data; +#endif return !dmpc->input()->isSequential () ; } - +#ifdef MPC_OLD_API +static mpc_int32_t mpc_callback_get_size (void *data) +{ + DecoderMPC *dmpc = (DecoderMPC *) data; +#else static mpc_int32_t mpc_callback_get_size (mpc_reader *reader) { DecoderMPC *dmpc = (DecoderMPC *) reader->data; +#endif return dmpc->input()->size(); } @@ -66,12 +92,23 @@ m_len = 0; m_bitrate = 0; m_totalTime = 0.0; +#ifdef MPC_OLD_API + m_data = 0; +#else m_data = nullptr; +#endif } DecoderMPC::~DecoderMPC() { m_len = 0; +#ifdef MPC_OLD_API + if(data()) + { + delete data(); + m_data = 0; + } +#else if(m_data) { if(m_data->demuxer) @@ -79,6 +116,7 @@ delete m_data; m_data = nullptr; } +#endif } bool DecoderMPC::initialize() @@ -105,19 +143,40 @@ m_data->reader.get_size = mpc_callback_get_size; m_data->reader.data = this; +#ifdef MPC_OLD_API + mpc_streaminfo_init (&m_data->info); + if (mpc_streaminfo_read (&m_data->info, &m_data->reader) != ERROR_CODE_OK) + return false; +#else m_data->demuxer = mpc_demux_init (&m_data->reader); if (!m_data->demuxer) return false; mpc_demux_get_info (m_data->demuxer, &m_data->info); +#endif int chan = data()->info.channels; configure(data()->info.sample_freq, chan, Qmmp::PCM_FLOAT); QMap<Qmmp::ReplayGainKey, double> rg_info; //replay gain information +#ifdef MPC_OLD_API + mpc_decoder_setup (&data()->decoder, &data()->reader); + + //mpc_decoder_scale_output (&data()->decoder, 3.0); + if (!mpc_decoder_initialize (&data()->decoder, &data()->info)) + { + qWarning("DecoderMPC: cannot get info."); + return false; + } + rg_info[Qmmp::REPLAYGAIN_ALBUM_GAIN] = data()->info.gain_album/100.0; + rg_info[Qmmp::REPLAYGAIN_TRACK_GAIN] = data()->info.gain_title/100.0; + rg_info[Qmmp::REPLAYGAIN_ALBUM_PEAK] = data()->info.peak_album/32768.0; + rg_info[Qmmp::REPLAYGAIN_TRACK_PEAK] = data()->info.peak_title/32768.0; +#else rg_info[Qmmp::REPLAYGAIN_ALBUM_GAIN] = data()->info.gain_album/256.0; rg_info[Qmmp::REPLAYGAIN_TRACK_GAIN] = data()->info.gain_title/256.0; rg_info[Qmmp::REPLAYGAIN_ALBUM_PEAK] = pow(10, data()->info.peak_album/256.0/20.0); rg_info[Qmmp::REPLAYGAIN_TRACK_PEAK] = pow(10, data()->info.peak_title/256.0/20.0); +#endif setReplayGainInfo(rg_info); m_totalTime = mpc_streaminfo_get_length(&data()->info) * 1000; @@ -137,6 +196,15 @@ qint64 DecoderMPC::read(unsigned char *audio, qint64 maxSize) { +#ifdef MPC_OLD_API + mpc_uint32_t vbrAcc = 0; + mpc_uint32_t vbrUpd = 0; + MPC_SAMPLE_FORMAT buffer[MPC_DECODER_BUFFER_LENGTH]; + m_len = mpc_decoder_decode (&data()->decoder, buffer, &vbrAcc, &vbrUpd); + m_len *= data()->info.channels; + memcpy(audio, buffer, qMin(qint64(m_len * sizeof(float)), maxSize)); + m_bitrate = vbrUpd * data()->info.sample_freq / 1152000; +#else mpc_frame_info frame; mpc_status err; MPC_SAMPLE_FORMAT buffer[MPC_DECODER_BUFFER_LENGTH]; @@ -158,11 +226,15 @@ } } m_bitrate = frame.bits * data()->info.sample_freq / 1152000; +#endif return m_len * sizeof(float); } void DecoderMPC::seek(qint64 pos) { +#ifdef MPC_OLD_API + mpc_decoder_seek_seconds(&data()->decoder, pos/1000); +#else mpc_demux_seek_second(data()->demuxer, (double)pos/1000); - +#endif }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor