[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libtunepimp] Помощ при мигр ация libmpcdec3 -> libmpcdec6
From: |
Yavor Doganov |
Subject: |
Re: [libtunepimp] Помощ при мигр ация libmpcdec3 -> libmpcdec6 |
Date: |
Thu, 16 Jul 2009 14:40:41 +0300 |
В 14:44 +0000 на 22.05.2009 (пт), Yavor Doganov написа:
> BTW, кръпката не е наред, но все още не знам къде е проблема.
Вече трябва да работи. Не ми е ясно точно защо така се получава, но
след като замених mpc_streaminfo_get_length в mpcDecodeInfo с директно
изчисление, всичко се оправи...
Трябваше да се включи и config.h в mpcdecode.cpp за дефиницията на
символа MPC_OLD_API.
--- libtunepimp-0.5.3.orig/configure.in
+++ libtunepimp-0.5.3/configure.in
@@ -39,6 +39,9 @@ AC_SUBST(LIBLTDL)
AC_LIBTOOL_DLOPEN
AC_PROG_LIBTOOL
AC_SUBST(LIBTOOL_DEPS)
+# Check if the package was bootsrapped with Libtool 1.5.x.
+AC_EGREP_CPP([lt_dlhandle_struct \*lt_dlhandle], [#include "libltdl/ltdl.h"],
+ [AC_DEFINE([OLD_LIBTOOL], [1], [Define to 1 if libtool 1.5 is used.])])
PREFIX="${prefix}"
AC_SUBST(PREFIX)
AC_PROG_CXX
@@ -201,7 +204,11 @@ dnl Check for TagLib 1.4
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
@@ -33,12 +33,19 @@
#include <dirent.h>
#include "../libltdl/ltdl.h"
#include "plugins.h"
+#include "config.h"
#include <map>
using namespace std;
/*------------------------------------------------------------------------- */
+#ifndef OLD_LIBTOOL
+#define LTDLHANDLE lt_dlhandle
+#else
+#define LTDLHANDLE lt_dlhandle_struct *
+#endif
+
#define DB printf("%s:%d\n", __FILE__, __LINE__);
/*------------------------------------------------------------------------- */
@@ -103,12 +110,12 @@ int Plugins::load(const char *path, bool
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((LTDLHANDLE)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((LTDLHANDLE)info.handle);
continue;
}
@@ -116,7 +123,7 @@ int Plugins::load(const char *path, bool
info.methods = (*init_function)();
if (info.methods == NULL)
{
- lt_dlclose((lt_dlhandle_struct *)info.handle);
+ lt_dlclose((LTDLHANDLE)info.handle);
if (printDebugInfo)
fprintf(stderr, "Cannot retrieve supported methods from %s.\n",
file);
continue;
@@ -150,7 +157,7 @@ int Plugins::load(const char *path, bool
fprintf(stderr, " [Plugin %s has already been loaded. "
"Skipping.]\n", info.file);
info.methods->shutdown();
- lt_dlclose((lt_dlhandle_struct *)info.handle);
+ lt_dlclose((LTDLHANDLE)info.handle);
break;
}
}
@@ -173,7 +180,7 @@ void Plugins::unload(void)
if ((*i).handle)
{
(*i).methods->shutdown();
- lt_dlclose((lt_dlhandle_struct *)(*i).handle);
+ lt_dlclose((LTDLHANDLE)(*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 @@ typedef struct reader_data_t {
} 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 @@ canseek_impl(void *data)
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 @@ mpcDecodeStart(const char *fileName, int
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 @@ mpcDecodeStart(const char *fileName, int
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 @@ mpcDecodeInfo(mpc_decode_struct_t *ds, u
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 @@ mpcDecodeRead(mpc_decode_struct_t *ds, m
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 @@ mpcDecodeRead(mpc_decode_struct_t *ds, m
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 @@ mpcDecodeRead(mpc_decode_struct_t *ds, m
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 @@ convert:
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;
+ }
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [libtunepimp] Помощ при мигр ация libmpcdec3 -> libmpcdec6,
Yavor Doganov <=