gug-bg-herd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libtunepimp] Помощ при миграц ия libmpcdec3 -> libmpcdec6


From: Yavor Doganov
Subject: [libtunepimp] Помощ при миграц ия libmpcdec3 -> libmpcdec6
Date: Fri, 22 May 2009 14:04:40 +0300

Подхванах #476378, прилагам кръпката за преглед и тестване.

Проблеми:

      * Понеже така или иначе трябва да тествам и под Дебиан, оказа се,
        че се налага и приспособяване към Libtool 2.2.x.  С малка
        шмекерийка поддържам и овехтелия 1.5.x (gNewSense, Debian Etch).
      * Не ми е съвсем ясно какво прави delete в mpcDecodeStart/
        mpcDecodeEnd и дали mpc_demux_exit е необходимо.
      * Тествах с kid3.  Изглежда работи при файлов формат SV7, но не и
        при SV8 -- не показва времетраене или каквато и да е информация.
        В сесиите ми с gdb всичко изглежда нормално -- декодера се
        инициализира, и например `p *duration' в mpcDecodeInfo връща
        верния резултат.  Теоретично ако има някакъв проблем с кръпката,
        не би трябвало изобщо да показва информация и за SV7...

Ще съм благодарен за насоки/идеи.
--- libtunepimp-0.5.3.orig/configure.in
+++ libtunepimp-0.5.3/configure.in
@@ -39,6 +39,9 @@
 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 +203,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
@@ -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 @@
        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 @@
        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 @@
                   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 @@
        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
@@ -30,7 +30,11 @@
 #include <time.h>
 #include "fileio.h"
 
-#include <mpcdec/mpcdec.h> 
+#ifdef MPC_OLD_API
+#include <mpcdec/mpcdec.h>
+#else
+#include <mpc/mpcdec.h>
+#endif
 
 extern char *mpcErrorString;
 
@@ -40,35 +44,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 +108,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 +150,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 +164,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 +192,11 @@
         return 0;
         
     if (duration)
+#ifdef MPC_OLD_API
         *duration = (ds->info.pcm_samples * 1000) / ds->info.sample_freq;
+#else
+        *duration = (unsigned long)mpc_streaminfo_get_length(&ds->info);
+#endif
     if (samplesPerSecond)
         *samplesPerSecond = ds->info.sample_freq;
     if (bitsPerSample)
@@ -173,6 +225,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 +238,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 +248,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 +301,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;
+  }
 }
 
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]