summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac6
-rw-r--r--src/libmusepack/xine_musepack_decoder.c74
2 files changed, 78 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 8ca6df8d0..5e87d63e0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1352,8 +1352,10 @@ AC_ARG_WITH([external-libmpcdec], AS_HELP_STRING([--with-external-libmpcdec], [U
if test "x$enable_musepack" = "xno"; then
AC_MSG_RESULT([musepack support disabled])
elif test "x$with_external_libmpcdec" = "xyes"; then
- AC_CHECK_LIB([mpcdec], [mpc_decoder_decode], [have_mpcdec=yes])
- AC_CHECK_HEADERS([mpcdec/mpcdec.h], , [have_mpcdec=no])
+ AC_CHECK_LIB([mpcdec], [mpc_demux_decode], [have_mpcdec=yes],
+ [AC_CHECK_LIB([mpcdec], [mpc_decoder_decode], [have_mpcdec=yes])])
+ AC_CHECK_HEADERS([mpc/mpcdec.h], [],
+ [AC_CHECK_HEADERS([mpcdec/mpcdec.h], [], [have_mpcdec=no])])
if test "x$have_mpcdec" != "xyes"; then
AC_MSG_ERROR([Unable to find mpcdec])
fi
diff --git a/src/libmusepack/xine_musepack_decoder.c b/src/libmusepack/xine_musepack_decoder.c
index 1454b32f9..5977abd63 100644
--- a/src/libmusepack/xine_musepack_decoder.c
+++ b/src/libmusepack/xine_musepack_decoder.c
@@ -47,6 +47,8 @@
#ifdef HAVE_MPCDEC_MPCDEC_H
# include <mpcdec/mpcdec.h>
+#elif defined(HAVE_MPC_MPCDEC_H)
+# include <mpc/mpcdec.h>
#else
# include "musepack/musepack.h"
#endif
@@ -78,7 +80,11 @@ typedef struct mpc_decoder_s {
mpc_reader reader;
mpc_streaminfo streaminfo;
+#ifndef HAVE_MPC_MPCDEC_H
mpc_decoder decoder;
+#else
+ mpc_demux *decoder;
+#endif
int decoder_ok;
unsigned int current_frame;
@@ -93,8 +99,13 @@ typedef struct mpc_decoder_s {
*************************************************************************/
/* Reads size bytes of data into buffer at ptr. */
+#ifndef HAVE_MPC_MPCDEC_H
static int32_t mpc_reader_read(void *data, void *ptr, int size) {
mpc_decoder_t *this = (mpc_decoder_t *) data;
+#else
+static int32_t mpc_reader_read(mpc_reader *data, void *ptr, int size) {
+ mpc_decoder_t *this = (mpc_decoder_t *) data->data;
+#endif
lprintf("mpc_reader_read: size=%d\n", size);
@@ -112,8 +123,13 @@ static int32_t mpc_reader_read(void *data, void *ptr, int size) {
}
/* Seeks to byte position offset. */
+#ifndef HAVE_MPC_MPCDEC_H
static mpc_bool_t mpc_reader_seek(void *data, int32_t offset) {
mpc_decoder_t *this = (mpc_decoder_t *) data;
+#else
+static mpc_bool_t mpc_reader_seek(mpc_reader *data, int32_t offset) {
+ mpc_decoder_t *this = (mpc_decoder_t *) data->data;
+#endif
lprintf("mpc_reader_seek: offset=%d\n", offset);
@@ -121,11 +137,19 @@ static mpc_bool_t mpc_reader_seek(void *data, int32_t offset) {
* that the buffer starts at the start of the file */
this->read = offset;
+#ifndef HAVE_MPC_MPCDEC_H
return TRUE;
+#else
+ return MPC_TRUE;
+#endif
}
/* Returns the current byte offset in the stream. */
+#ifndef HAVE_MPC_MPCDEC_H
static int32_t mpc_reader_tell(void *data) {
+#else
+static int32_t mpc_reader_tell(mpc_reader *data) {
+#endif
lprintf("mpc_reader_tell\n");
/* Tell isn't used so just return 0 */
@@ -133,8 +157,13 @@ static int32_t mpc_reader_tell(void *data) {
}
/* Returns the total length of the source stream, in bytes. */
+#ifndef HAVE_MPC_MPCDEC_H
static int32_t mpc_reader_get_size(void *data) {
mpc_decoder_t *this = (mpc_decoder_t *) data;
+#else
+static int32_t mpc_reader_get_size(mpc_reader *data) {
+ mpc_decoder_t *this = (mpc_decoder_t *) data->data;
+#endif
lprintf("mpc_reader_get_size\n");
@@ -142,10 +171,17 @@ static int32_t mpc_reader_get_size(void *data) {
}
/* True if the stream is a seekable stream. */
+#ifndef HAVE_MPC_MPCDEC_H
static mpc_bool_t mpc_reader_canseek(void *data) {
lprintf("mpc_reader_canseek\n");
return TRUE;
+#else
+static mpc_bool_t mpc_reader_canseek(mpc_reader *data) {
+
+ lprintf("mpc_reader_canseek\n");
+ return MPC_TRUE;
+#endif
}
/* Convert 32bit float samples into 16bit int samples */
@@ -165,10 +201,19 @@ static inline void float_to_int(float *_f, int16_t *s16, int samples) {
static int mpc_decode_frame (mpc_decoder_t *this) {
float buffer[MPC_DECODER_BUFFER_LENGTH];
uint32_t frames;
+#ifdef HAVE_MPC_MPCDEC_H
+ mpc_frame_info frame;
+#endif
lprintf("mpd_decode_frame\n");
+#ifndef HAVE_MPC_MPCDEC_H
frames = mpc_decoder_decode(&this->decoder, buffer, 0, 0);
+#else
+ frame.buffer = buffer;
+ mpc_demux_decode(this->decoder, &frame);
+ frames = frame.samples;
+#endif
if (frames > 0) {
audio_buffer_t *audio_buffer;
@@ -235,6 +280,16 @@ static void mpc_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
xine_fast_memcpy(this->buf, buf->content, buf->size);
this->size = buf->size;
+#ifdef HAVE_MPC_MPCDEC_H
+ this->decoder = mpc_demux_init(&this->reader);
+ if (!this->decoder) {
+ xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
+ _("libmusepack: mpc_demux_init failed.\n"));
+ _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_HANDLED, 0);
+ return;
+ }
+ mpc_demux_get_info(this->decoder, &this->streaminfo);
+#else
/* Initialise and read stream info */
mpc_streaminfo_init(&this->streaminfo);
@@ -245,6 +300,7 @@ static void mpc_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
_x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_HANDLED, 0);
return;
}
+#endif
this->sample_rate = this->streaminfo.sample_freq;
this->channels = this->streaminfo.channels;
@@ -259,7 +315,9 @@ static void mpc_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
this->current_frame = 0;
/* Setup the decoder */
+#ifndef HAVE_MPC_MPCDEC_H
mpc_decoder_setup(&this->decoder, &this->reader);
+#endif
this->decoder_ok = 0;
/* Take this opportunity to initialize stream/meta information */
@@ -312,7 +370,11 @@ static void mpc_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
/* Time to decode */
if (buf->decoder_flags & BUF_FLAG_FRAME_END) {
/* Increment frame count */
+#ifndef HAVE_MPC_MPCDEC_H
if (this->current_frame++ == this->streaminfo.frames) {
+#else
+ if (this->current_frame++ == this->streaminfo.samples) {
+#endif
xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
_("libmusepack: data after last frame ignored\n"));
return;
@@ -323,7 +385,11 @@ static void mpc_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
if ((this->size - this->read) >= MPC_DECODER_MEMSIZE) {
lprintf("initialise");
+#ifndef HAVE_MPC_MPCDEC_H
if (!mpc_decoder_initialize(&this->decoder, &this->streaminfo)) {
+#else
+ if (!this->decoder) {
+#endif
xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
_("libmusepack: mpc_decoder_initialise failed\n"));
@@ -354,7 +420,11 @@ static void mpc_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
/* If we are at the end of the stream we decode the remaining frames as we
* know we'll have enough data */
+#ifndef HAVE_MPC_MPCDEC_H
if (this->current_frame == this->streaminfo.frames) {
+#else
+ if (this->current_frame == this->streaminfo.samples) {
+#endif
lprintf("flushing buffers\n");
do {
@@ -392,6 +462,10 @@ static void mpc_dispose (audio_decoder_t *this_gen) {
/* free anything that was allocated during operation */
if (this->buf)
free(this->buf);
+#ifdef HAVE_MPC_MPCDEC_H
+ if (this->decoder)
+ mpc_demux_exit(this->decoder);
+#endif
free(this);
}