On Thu, Jul 16, 2009 at 02:57:53PM +0300, Yavor Doganov wrote:
> I adapted the package to libtool 2.2.x -- supporting old libtool is
> not needed for Debian
Given the recent libtool vulnerability, I no longer think that
supporting 1.5.x is worthwile even for upstream. Here is the same patch
simplified, without the compatibility hack.
--- libtunepimp-0.5.3.orig/configure.in
+++ libtunepimp-0.5.3/configure.in
@@ -201,7 +201,11 @@
AC_CHECK_TAGLIB(1.4, have_taglib=yes, have_taglib=no)
dnl Check for libmpcdec
-AC_CHECK_LIB(mpcdec, mpc_decoder_decode, have_mpcdec=yes,)
+AC_CHECK_LIB([mpcdec], [mpc_demux_decode], [have_mpcdec=yes])
+AS_IF([test -z "$have_mpcdec"],
+ [AC_CHECK_LIB([mpcdec], [mpc_decoder_decode],
+ [have_mpcdec=yes
+ AC_DEFINE([MPC_OLD_API], [1], [Define if the old MusePack API is used.])])])
dnl Check if we can build TagLib-based plugins
if test "x$have_taglib" = "xyes"; then
--- libtunepimp-0.5.3.orig/lib/plugins.cpp
+++ libtunepimp-0.5.3/lib/plugins.cpp
@@ -103,12 +103,12 @@
strcat(init_func, "InitPlugin");
/* Opened plugin ok, now locate our entry function */
- init_function = (Plugin *(*)(void))lt_dlsym((lt_dlhandle_struct *)info.handle, init_func);
+ init_function = (Plugin *(*)(void))lt_dlsym((lt_dlhandle)info.handle, init_func);
if (init_function == NULL)
{
if (printDebugInfo)
fprintf(stderr, "Cannot find entry point in %s (%s).\n", file, lt_dlerror());
- lt_dlclose((lt_dlhandle_struct *)info.handle);
+ lt_dlclose((lt_dlhandle)info.handle);
continue;
}
@@ -116,7 +116,7 @@
info.methods = (*init_function)();
if (info.methods == NULL)
{
- lt_dlclose((lt_dlhandle_struct *)info.handle);
+ lt_dlclose((lt_dlhandle)info.handle);
if (printDebugInfo)
fprintf(stderr, "Cannot retrieve supported methods from %s.\n", file);
continue;
@@ -150,7 +150,7 @@
fprintf(stderr, " [Plugin %s has already been loaded. "
"Skipping.]\n", info.file);
info.methods->shutdown();
- lt_dlclose((lt_dlhandle_struct *)info.handle);
+ lt_dlclose((lt_dlhandle)info.handle);
break;
}
}
@@ -173,7 +173,7 @@
if ((*i).handle)
{
(*i).methods->shutdown();
- lt_dlclose((lt_dlhandle_struct *)(*i).handle);
+ lt_dlclose((lt_dlhandle)(*i).handle);
(*i).handle = NULL;
}
}
--- libtunepimp-0.5.3.orig/plugins/mpc/mpcdecode.cpp
+++ libtunepimp-0.5.3/plugins/mpc/mpcdecode.cpp
@@ -29,8 +29,13 @@
#include <assert.h>
#include <time.h>
#include "fileio.h"
+#include "config.h"
-#include <mpcdec/mpcdec.h>
+#ifdef MPC_OLD_API
+#include <mpcdec/mpcdec.h>
+#else
+#include <mpc/mpcdec.h>
+#endif
extern char *mpcErrorString;
@@ -40,35 +45,63 @@
} reader_data;
static mpc_int32_t
+#ifdef MPC_OLD_API
read_impl(void *data, void *ptr, mpc_int32_t size)
{
reader_data *d = (reader_data *) data;
+#else
+read_impl(mpc_reader *data, void *ptr, mpc_int32_t size)
+{
+ reader_data *d = (reader_data *) data->data;
+#endif
return tread(ptr, 1, size, d->file);
}
static mpc_bool_t
+#ifdef MPC_OLD_API
seek_impl(void *data, mpc_int32_t offset)
{
reader_data *d = (reader_data *) data;
+#else
+seek_impl(mpc_reader *data, mpc_int32_t offset)
+{
+ reader_data *d = (reader_data *) data->data;
+#endif
return !tseek(d->file, offset, SEEK_SET);
}
static mpc_int32_t
+#ifdef MPC_OLD_API
tell_impl(void *data)
{
reader_data *d = (reader_data *) data;
+#else
+tell_impl(mpc_reader *data)
+{
+ reader_data *d = (reader_data *) data->data;
+#endif
return ttell(d->file);
}
static mpc_int32_t
+#ifdef MPC_OLD_API
get_size_impl(void *data)
{
reader_data *d = (reader_data *) data;
+#else
+get_size_impl(mpc_reader *data)
+{
+ reader_data *d = (reader_data *) data->data;
+#endif
return d->size;
}
static mpc_bool_t
+#ifdef MPC_OLD_API
canseek_impl(void *data)
+#else
+canseek_impl(mpc_reader *data)
+#endif
{
return true;
}
@@ -76,7 +109,11 @@
typedef struct mpc_decode_struct_t {
TFILE *file;
reader_data rdata;
+#ifdef MPC_OLD_API
mpc_decoder decoder;
+#else
+ mpc_demux *decoder;
+#endif
mpc_reader reader;
mpc_streaminfo info;
MPC_SAMPLE_FORMAT buffer[MPC_DECODER_BUFFER_LENGTH];
@@ -114,6 +151,7 @@
ds->reader.canseek = canseek_impl;
ds->reader.data = &ds->rdata;
+#ifdef MPC_OLD_API
/* read file's streaminfo data */
mpc_streaminfo_init(&ds->info);
if (mpc_streaminfo_read(&ds->info, &ds->reader) != ERROR_CODE_OK) {
@@ -127,14 +165,25 @@
mpcErrorString = "Error initializing decoder.";
goto error;
}
-
+#else
+ ds->decoder = mpc_demux_init(&ds->reader);
+ if (!ds->decoder) {
+ mpcErrorString = "Error initializing decoder.";
+ goto error;
+ }
+
+ mpc_demux_get_info(ds->decoder, &ds->info);
+#endif
+
return ds;
error:
- if (ds)
- delete ds;
-
- return NULL;
+ if (ds) {
+#ifndef MPC_OLD_API
+ mpc_demux_exit(ds->decoder);
+#endif
+ delete ds;
+ }
}
extern "C" int
@@ -144,7 +193,12 @@
return 0;
if (duration)
+#ifdef MPC_OLD_API
*duration = (ds->info.pcm_samples * 1000) / ds->info.sample_freq;
+#else
+ *duration = ((ds->info.samples - ds->info.beg_silence) * 1000)
+ / ds->info.sample_freq;
+#endif
if (samplesPerSecond)
*samplesPerSecond = ds->info.sample_freq;
if (bitsPerSample)
@@ -173,6 +227,10 @@
return -1;
unsigned status, maxSamples = maxBytes / 2 / ds->info.channels, samples, offset;
+#ifndef MPC_OLD_API
+ mpc_frame_info frame;
+ mpc_status err;
+#endif
if (ds->samples > 0) {
samples = ds->samples;
@@ -182,6 +240,7 @@
goto convert;
}
+#ifdef MPC_OLD_API
status = mpc_decoder_decode(&ds->decoder, ds->buffer, 0, 0);
if (status == (unsigned)(-1)) { //decode error
@@ -191,6 +250,20 @@
else if (status == 0) { //EOF
return 0;
}
+#else
+ frame.buffer = ds->buffer;
+ err = mpc_demux_decode(ds->decoder, &frame);
+
+ if (err != MPC_STATUS_OK) { //decode error
+ mpcErrorString = "Error decoding file.";
+ return -1;
+ }
+ else if (frame.bits == -1) { //EOF
+ return 0;
+ }
+
+ status = frame.samples;
+#endif
if (status > maxSamples) {
ds->samples = status - maxSamples;
@@ -230,8 +303,12 @@
extern "C" void
mpcDecodeEnd(mpc_decode_struct_t *ds)
{
- if (ds)
- delete ds;
+ if (ds) {
+#ifndef MPC_OLD_API
+ mpc_demux_exit(ds->decoder);
+#endif
+ delete ds;
+ }
}