Sunday, June 11, 2023

Re: UPDATE: xmms

On Fri, May 19, 2023 at 01:32:55PM -0400, Brad Smith wrote:
> Disable the JACK backend. The are two backends enabled and the ao backend works fine.

An updated diff that also includes dealing with newer FFmpeg releases.


Index: Makefile
===================================================================
RCS file: /home/cvs/ports/audio/xmms2/Makefile,v
retrieving revision 1.61
diff -u -p -u -p -r1.61 Makefile
--- Makefile 5 Nov 2022 17:06:23 -0000 1.61
+++ Makefile 19 May 2023 07:27:18 -0000
@@ -3,7 +3,7 @@ COMMENT = audio player daemon with libr
V = 0.8
DISTNAME = xmms2-${V}DrO_o
PKGNAME = xmms2-${V}
-REVISION = 17
+REVISION = 18

SHARED_LIBS += xmmsclient++ 2.0 # 4.0.0
SHARED_LIBS += xmmsclient++-glib 1.0 # 1.0.0
@@ -19,7 +19,7 @@ PERMIT_PACKAGE = Yes

WANTLIB += ${COMPILER_LIBCXX} FLAC ao avahi-client avahi-common
WANTLIB += avahi-glib avcodec avutil c curl ffi gio-2.0 glib-2.0
-WANTLIB += gmodule-2.0 gobject-2.0 gthread-2.0 intl jack m mpg123
+WANTLIB += gmodule-2.0 gobject-2.0 gthread-2.0 intl m mpg123
WANTLIB += ogg opus pcre2-8 perl python2.7 readline sndfile sqlite3
WANTLIB += swresample vorbis vorbisenc vorbisfile xml2 z

@@ -33,7 +33,7 @@ COMPILER = base-clang ports-gcc base-gc

MODULES = lang/python \
perl
-MODPY_VERSION = ${MODPY_DEFAULT_VERSION_2}
+MODPY_VERSION = ${MODPY_DEFAULT_VERSION_2}

NO_TEST = Yes

@@ -44,7 +44,6 @@ LIB_DEPENDS = devel/glib2 \
databases/sqlite3 \
graphics/ffmpeg \
audio/libao \
- audio/jack \
textproc/libxml \
net/curl \
audio/mpg123 \
@@ -71,7 +70,7 @@ do-configure:
--no-cython \
--disable-shmvis-server \
--without-optionals=medialib-updater,tests,xmmsclient-cf,xmmsclient-ecore,ruby \
- --without-plugins=airplay,alsa,cdda,coreaudio,faad,gme,ices,mac,mad,mms,modplug,musepack,nms,ofa,oss,pulse,samba,sid,speex,sun,tremor,vocoder,waveout,wavpack
+ --without-plugins=airplay,alsa,cdda,coreaudio,faad,gme,ices,jack,mac,mad,mms,modplug,musepack,nms,ofa,oss,pulse,samba,sid,speex,sun,tremor,vocoder,waveout,wavpack

post-configure:
# avoid linking to bogus libraries
Index: patches/patch-src_plugins_avcodec_avcodec_c
===================================================================
RCS file: /home/cvs/ports/audio/xmms2/patches/patch-src_plugins_avcodec_avcodec_c,v
retrieving revision 1.5
diff -u -p -u -p -r1.5 patch-src_plugins_avcodec_avcodec_c
--- patches/patch-src_plugins_avcodec_avcodec_c 11 Mar 2022 18:20:36 -0000 1.5
+++ patches/patch-src_plugins_avcodec_avcodec_c 19 May 2023 02:06:20 -0000
@@ -1,7 +1,8 @@
Deal with newer FFmpeg API.

---- src/plugins/avcodec/avcodec.c.orig Thu Mar 27 01:42:57 2014
-+++ src/plugins/avcodec/avcodec.c Thu Mar 27 01:52:27 2014
+Index: src/plugins/avcodec/avcodec.c
+--- src/plugins/avcodec/avcodec.c.orig
++++ src/plugins/avcodec/avcodec.c
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <string.h>
@@ -10,7 +11,14 @@ Deal with newer FFmpeg API.

#include "avcodec_compat.h"

-@@ -36,6 +37,8 @@ typedef struct {
+@@ -30,12 +31,15 @@
+
+ typedef struct {
+ AVCodecContext *codecctx;
++ AVPacket packet;
+
+ guchar *buffer;
+ guint buffer_length;
guint buffer_size;
gboolean no_demuxer;

@@ -19,7 +27,7 @@ Deal with newer FFmpeg API.
guint channels;
guint samplerate;
xmms_sample_format_t sampleformat;
-@@ -53,10 +56,14 @@ typedef struct {
+@@ -53,10 +57,14 @@ typedef struct {
static gboolean xmms_avcodec_plugin_setup (xmms_xform_plugin_t *xform_plugin);
static gboolean xmms_avcodec_init (xmms_xform_t *xform);
static void xmms_avcodec_destroy (xmms_xform_t *xform);
@@ -34,7 +42,7 @@ Deal with newer FFmpeg API.

/*
* Plugin header
-@@ -85,13 +92,23 @@ xmms_avcodec_plugin_setup (xmms_xform_plugin_t *xform_
+@@ -85,13 +93,23 @@ xmms_avcodec_plugin_setup (xmms_xform_plugin_t *xform_
xmms_magic_add ("A/52 (AC-3) header", "audio/x-ffmpeg-ac3",
"0 beshort 0x0b77", NULL);
xmms_magic_add ("DTS header", "audio/x-ffmpeg-dca",
@@ -59,7 +67,7 @@ Deal with newer FFmpeg API.
return TRUE;
}

-@@ -107,6 +124,7 @@ xmms_avcodec_destroy (xmms_xform_t *xform)
+@@ -107,6 +125,7 @@ xmms_avcodec_destroy (xmms_xform_t *xform)

avcodec_close (data->codecctx);
av_free (data->codecctx);
@@ -67,18 +75,31 @@ Deal with newer FFmpeg API.

g_string_free (data->outbuf, TRUE);
g_free (data->buffer);
-@@ -132,9 +150,10 @@ xmms_avcodec_init (xmms_xform_t *xform)
+@@ -118,7 +137,7 @@ static gboolean
+ xmms_avcodec_init (xmms_xform_t *xform)
+ {
+ xmms_avcodec_data_t *data;
+- AVCodec *codec;
++ const AVCodec *codec;
+ const gchar *mimetype;
+ const guchar *tmpbuf;
+ gsize tmpbuflen;
+@@ -131,12 +150,12 @@ xmms_avcodec_init (xmms_xform_t *xform)
+ data->buffer = g_malloc (AVCODEC_BUFFER_SIZE);
data->buffer_size = AVCODEC_BUFFER_SIZE;
data->codecctx = NULL;
++ data->packet.size = 0;

+ data->read_out_frame = av_frame_alloc ();
+
xmms_xform_private_data_set (xform, data);

- avcodec_init ();
- avcodec_register_all ();
-
+- avcodec_register_all ();
+-
mimetype = xmms_xform_indata_get_str (xform,
+ XMMS_STREAM_TYPE_MIMETYPE);
+ data->codec_id = mimetype + strlen ("audio/x-ffmpeg-");
@@ -161,12 +180,12 @@ xmms_avcodec_init (xmms_xform_t *xform)
data->channels = ret;
}
@@ -326,7 +347,7 @@ Deal with newer FFmpeg API.
}

ret = xmms_xform_seek (xform, samples, whence, err);
-@@ -419,4 +358,179 @@ xmms_avcodec_seek (xmms_xform_t *xform, gint64 samples
+@@ -419,4 +358,171 @@ xmms_avcodec_seek (xmms_xform_t *xform, gint64 samples
}

return ret;
@@ -438,45 +459,37 @@ Deal with newer FFmpeg API.
+static gint
+xmms_avcodec_internal_decode_some (xmms_avcodec_data_t *data)
+{
-+ int got_frame = 0;
-+ gint bytes_read = 0;
-+ AVPacket packet;
++ int rc = 0;
+
-+ av_init_packet (&packet);
-+ packet.data = data->buffer;
-+ packet.size = data->buffer_length;
-+
-+ /* clear buffers and reset fields to defaults */
-+ av_frame_unref (data->read_out_frame);
-+
-+ bytes_read = avcodec_decode_audio4 (
-+ data->codecctx, data->read_out_frame, &got_frame, &packet);
-+
-+ /* The DTS decoder of ffmpeg is buggy and always returns
-+ * the input buffer length, get frame length from header */
-+ /* FIXME: Is ^^^^ still true? */
-+ if (!strcmp (data->codec_id, "dca") && bytes_read > 0) {
-+ bytes_read = ((int)data->buffer[5] << 12) |
-+ ((int)data->buffer[6] << 4) |
-+ ((int)data->buffer[7] >> 4);
-+ bytes_read = (bytes_read & 0x3fff) + 1;
++ if (data->packet.size == 0) {
++ av_init_packet (&data->packet);
++ data->packet.data = data->buffer;
++ data->packet.size = data->buffer_length;
++
++ rc = avcodec_send_packet(data->codecctx, &data->packet);
++ if (rc == AVERROR_EOF)
++ rc = 0;
+ }
+
-+ if (bytes_read < 0 || bytes_read > data->buffer_length) {
-+ XMMS_DBG ("Error decoding data!");
-+ return -1;
++ if (rc == 0) {
++ rc = avcodec_receive_frame(data->codecctx, data->read_out_frame);
++ if (rc < 0) {
++ data->packet.size = 0;
++ data->buffer_length = 0;
++ if (rc == AVERROR(EAGAIN)) rc = 0;
++ else if (rc == AVERROR_EOF) rc = 1;
++ }
++ else
++ rc = 1;
+ }
+
-+ if (bytes_read < data->buffer_length) {
-+ data->buffer_length -= bytes_read;
-+ g_memmove (data->buffer,
-+ data->buffer + bytes_read,
-+ data->buffer_length);
-+ } else {
-+ data->buffer_length = 0;
++ if (rc < 0) {
++ data->packet.size = 0;
++ XMMS_DBG ("Error decoding data!");
++ return -1;
+ }
+
-+ return got_frame ? 1 : 0;
++ return rc;
+}
+
+static void
Index: patches/patch-src_plugins_avcodec_wscript
===================================================================
RCS file: patches/patch-src_plugins_avcodec_wscript
diff -N patches/patch-src_plugins_avcodec_wscript
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_plugins_avcodec_wscript 19 May 2023 02:12:13 -0000
@@ -0,0 +1,62 @@
+Deal with newer FFmpeg API.
+
+Index: src/plugins/avcodec/wscript
+--- src/plugins/avcodec/wscript.orig
++++ src/plugins/avcodec/wscript
+@@ -1,10 +1,56 @@
+ from waftools.plugin import plugin
+
++## Code fragments for configuration
++avcodec_send_packet_fragment = """
++#ifdef HAVE_LIBAVCODEC_AVCODEC_H
++# include "libavcodec/avcodec.h"
++#else
++# include "avcodec.h"
++

No comments:

Post a Comment