[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[aqualung] Помощ при миграци я libmpcdec3 -> libmpcdec6
From: |
Yavor Doganov |
Subject: |
[aqualung] Помощ при миграци я libmpcdec3 -> libmpcdec6 |
Date: |
Fri, 05 Jun 2009 18:49:05 +0300 |
Най-сетне GTK+ (#476370). Отговорникът в Дебиан е препратил този доклад
upstream, но очевидно няма никакво развитие.
Тук изненади нямаше, с изключение на мистериозен SIGSEGV в
src/decoder/file_decoder.c:309, който впоследствие не можах да
възпроизведа. Наложи се да преименувам функцията `mpc_decoder_init',
понеже се получава колизия с новото API. Струва ми се по-добро решение
отколкото допълнителна гора от #ifdef's.
Не съм съвсем уверен дали съм успял да избегна евентуални утечки.
Според скромните тестове всичко е наред.
--- aqualung-0.9~beta10.orig/configure.ac
+++ aqualung-0.9~beta10/configure.ac
@@ -526,12 +526,16 @@
if test "$mpc" = "no"; then
AC_MSG_RESULT(no)
else
- AC_CHECK_LIB(mpcdec, mpc_streaminfo_init, [lib=yes], [lib=no],
[-lstdc++])
+ AC_CHECK_LIB([mpcdec], [mpc_demux_init], [lib=yes],
+ [AC_CHECK_LIB([mpcdec], [mpc_streaminfo_init], [lib=yes
+ AC_DEFINE([MPC_OLD_API], [1],
+ [Defined if old Musepack API is used])], [], [-lstdc++])],
+ [-lstdc++])
if test "$lib" = "yes"; then
mpc_LIBS="-lmpcdec -lstdc++"
AC_DEFINE([HAVE_MPC], [1], [Defined if compile with Musepack
support])
fi
- if test "$lib" = "no" -a "$mpc" = "yes"; then
+ if test "$lib" != "yes" -a "$mpc" = "yes"; then
AC_MSG_ERROR(You do not appear to have the Musepack decoder
library (libmpcdec) installed. Grab it from http://www.musepack.net)
fi
if test "$mpc" = "detect"; then
--- aqualung-0.9~beta10.orig/src/decoder/dec_mpc.c
+++ aqualung-0.9~beta10/src/decoder/dec_mpc.c
@@ -47,6 +47,7 @@
MPC_SAMPLE_FORMAT buffer[MPC_DECODER_BUFFER_LENGTH];
+#ifdef MPC_OLD_API
pd->status = mpc_decoder_decode(&pd->mpc_d, buffer, NULL, NULL);
if (pd->status == (unsigned)(-1)) {
fprintf(stderr, "decode_mpc: mpc decoder reported an error\n");
@@ -54,6 +55,20 @@
} else if (pd->status == 0) {
return 1; /* end of stream */
}
+#else
+ mpc_frame_info frame;
+ mpc_status err;
+
+ frame.buffer = buffer;
+ err = mpc_demux_decode(pd->mpc_d, &frame);
+ if (err != MPC_STATUS_OK) {
+ fprintf(stderr, "decode_mpc: mpc decoder reported an error\n");
+ return 1; /* ignore the rest of the stream */
+ } else if (frame.bits == -1) {
+ return 1; /* end of stream */
+ }
+ pd->status = frame.samples;
+#endif /* MPC_OLD_API */
for (n = 0; n < pd->status * pd->mpc_i.channels; n++) {
#ifdef MPC_FIXED_POINT
@@ -75,7 +90,7 @@
decoder_t *
-mpc_decoder_init(file_decoder_t * fdec) {
+mpc_decoder_init_func(file_decoder_t * fdec) {
decoder_t * dec = NULL;
@@ -91,7 +106,7 @@
return NULL;
}
- dec->init = mpc_decoder_init;
+ dec->init = mpc_decoder_init_func;
dec->destroy = mpc_decoder_destroy;
dec->open = mpc_decoder_open;
dec->close = mpc_decoder_close;
@@ -177,6 +192,7 @@
pd->size = ftell(pd->mpc_file);
fseek(pd->mpc_file, 0, SEEK_SET);
+#ifdef MPC_OLD_API
mpc_reader_setup_file_reader(&pd->mpc_r_f, pd->mpc_file);
mpc_streaminfo_init(&pd->mpc_i);
@@ -190,6 +206,16 @@
fclose(pd->mpc_file);
return DECODER_OPEN_BADLIB;
}
+#else
+ mpc_reader_init_stdio_stream(&pd->mpc_r_f, pd->mpc_file);
+
+ pd->mpc_d = mpc_demux_init(&pd->mpc_r_f);
+ if (!pd->mpc_d) {
+ fclose(pd->mpc_file);
+ return DECODER_OPEN_BADLIB;
+ }
+ mpc_demux_get_info(pd->mpc_d, &pd->mpc_i);
+#endif /* MPC_OLD_API */
pd->is_eos = 0;
pd->rb = rb_create(pd->mpc_i.channels * sample_size * RB_MPC_SIZE);
@@ -202,7 +228,11 @@
fdec->file_lib = MPC_LIB;
strcpy(dec->format_str, "Musepack");
+#ifdef MPC_OLD_API
switch (pd->mpc_i.profile) {
+#else
+ switch ((int) pd->mpc_i.profile) {
+#endif /* MPC_OLD_API */
case 7:
sprintf(dec->format_str, "%s (%s)", dec->format_str,
_("Profile: Telephone"));
break;
@@ -279,7 +309,11 @@
char flush_dest;
+#ifdef MPC_OLD_API
if (mpc_decoder_seek_sample(&pd->mpc_d, seek_to_pos)) {
+#else
+ if (mpc_demux_seek_sample(pd->mpc_d, seek_to_pos) == MPC_STATUS_OK) {
+#endif /* MPC_OLD_API */
fdec->samples_left = fdec->fileinfo.total_samples - seek_to_pos;
/* empty musepack decoder ringbuffer */
while (rb_read_space(pd->rb))
@@ -293,7 +327,7 @@
#else
decoder_t *
-mpc_decoder_init(file_decoder_t * fdec) {
+mpc_decoder_init_func(file_decoder_t * fdec) {
return NULL;
}
--- aqualung-0.9~beta10.orig/src/decoder/dec_mpc.h
+++ aqualung-0.9~beta10/src/decoder/dec_mpc.h
@@ -23,7 +23,11 @@
#define _DEC_MPC_H
#ifdef HAVE_MPC
+#ifdef MPC_OLD_API
#include <mpcdec/mpcdec.h>
+#else
+#include <mpc/mpcdec.h>
+#endif /* MPC_OLD_API */
#endif /* HAVE_MPC */
#include "file_decoder.h"
@@ -43,14 +47,19 @@
int seekable;
int status;
int is_eos;
+#ifdef MPC_OLD_API
mpc_decoder mpc_d;
mpc_reader_file mpc_r_f;
+#else
+ mpc_demux * mpc_d;
+ mpc_reader mpc_r_f;
+#endif /* MPC_OLD_API */
mpc_streaminfo mpc_i;
} mpc_pdata_t;
#endif /* HAVE_MPC */
-decoder_t * mpc_decoder_init(file_decoder_t * fdec);
+decoder_t * mpc_decoder_init_func(file_decoder_t * fdec);
#ifdef HAVE_MPC
void mpc_decoder_destroy(decoder_t * dec);
int mpc_decoder_open(decoder_t * dec, char * filename);
--- aqualung-0.9~beta10.orig/src/decoder/file_decoder.c
+++ aqualung-0.9~beta10/src/decoder/file_decoder.c
@@ -66,7 +66,7 @@
flac_decoder_init,
vorbis_decoder_init,
speex_dec_init,
- mpc_decoder_init,
+ mpc_decoder_init_func,
mac_decoder_init,
mpeg_decoder_init,
wavpack_decoder_init,
Только в aqualung-0.9~beta10/src/decoder: file_decoder.c~
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [aqualung] Помощ при миграци я libmpcdec3 -> libmpcdec6,
Yavor Doganov <=