From 68cff160cbf2fb0b4865f2b74bb49b8fa1a2a657 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Wed, 1 Oct 2014 10:43:06 -0500 Subject: [PATCH] Properly register aRts plugin with Xine >= 1.2.x This resolves Bug 1905 --- xine_artsplugin/Makefile.am | 2 +- xine_artsplugin/audio_fifo_out.c | 155 +++++++++++++++++++++++++++---- xine_artsplugin/configure.in.in | 6 +- 3 files changed, 139 insertions(+), 24 deletions(-) diff --git a/xine_artsplugin/Makefile.am b/xine_artsplugin/Makefile.am index 39bb6a96..395873b5 100644 --- a/xine_artsplugin/Makefile.am +++ b/xine_artsplugin/Makefile.am @@ -8,7 +8,7 @@ libarts_xine_la_SOURCES = xinePlayObject.cc \ xinePlayObject_impl.cpp \ audio_fifo_out.c libarts_xine_la_LDFLAGS = $(all_libraries) -module -no-undefined -pthread -libarts_xine_la_LIBADD = $(XINE_LIBS) $(LIBPTHREAD) $(LIB_X11) $(LIB_XEXT) \ +libarts_xine_la_LIBADD = $(XINE_LIBS) $(LIBPTHREAD) $(LIB_X11) $(LIB_XEXT) $(LIB_QT) \ -lkmedia2_idl -lsoundserver_idl -lartsflow libarts_xine_la_METASOURCES = AUTO diff --git a/xine_artsplugin/audio_fifo_out.c b/xine_artsplugin/audio_fifo_out.c index f5256e1b..9255ba2c 100644 --- a/xine_artsplugin/audio_fifo_out.c +++ b/xine_artsplugin/audio_fifo_out.c @@ -1,6 +1,7 @@ /* This file is part of KDE/aRts (Noatun) - xine integration Copyright (C) 2002-2003 Ewald Snel + Copyright (C) 2014 Timothy Pearson This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -21,29 +22,40 @@ #include #include +#if (XINE_MAJOR_VERSION >= 1) && (XINE_MINOR_VERSION >= 2) +#include +#include +#endif + #include "audio_fifo_out.h" #define GAP_TOLERANCE 5000 -typedef struct fifo_driver_s -{ - ao_driver_t ao_driver; - - xine_arts_audio *audio; - - int capabilities; - int mode; - pthread_mutex_t read_mutex; - pthread_mutex_t write_mutex; - pthread_cond_t cond; - - uint32_t bytes_per_frame; - uint8_t *fifo; - int fifo_size; - int fifo_read_ptr; - int fifo_write_ptr; - int fifo_flush; - int fifo_delay; +// #define XINE_DEBUG 1 + +typedef struct fifo_driver_s { + ao_driver_t ao_driver; + + xine_arts_audio *audio; + + int capabilities; + int mode; + pthread_mutex_t read_mutex; + pthread_mutex_t write_mutex; + pthread_cond_t cond; + + uint32_t bytes_per_frame; + uint8_t *fifo; + int fifo_size; + int fifo_read_ptr; + int fifo_write_ptr; + int fifo_flush; + int fifo_delay; + +#if (XINE_MAJOR_VERSION >= 1) && (XINE_MINOR_VERSION >= 2) + config_values_t *config; + xine_t *xine; +#endif } fifo_driver_t; /* @@ -280,9 +292,111 @@ static int ao_fifo_control( ao_driver_t *this_gen, int cmd, ... ) return 0; } +#if (XINE_MAJOR_VERSION >= 1) && (XINE_MINOR_VERSION >= 2) +static fifo_driver_t * _ao_driver = NULL; + +typedef struct fifo_class_s { + audio_driver_class_t driver_class; + config_values_t *config; + xine_t *xine; +} fifo_class_t; + +static void _arts_class_dispose(audio_driver_class_t *driver_class) { + fifo_class_t *cl; + + cl = (fifo_class_t *)driver_class; + free(cl); +} + +static char *_arts_class_identifier_get(video_driver_class_t *driver_class) { + return "arts"; +} + +static char *_arts_class_description_get(video_driver_class_t *driver_class) { + return "aRts xine video output plugin"; +} + +static ao_driver_t * _arts_open(audio_driver_class_t *driver_class, const void *data) { + fifo_class_t *cl; + + cl = (fifo_class_t *)driver_class; + + _ao_driver = (fifo_driver_t *)malloc(sizeof(fifo_driver_t)); + if (!_ao_driver) return NULL; + + _ao_driver->config = cl->config; + _ao_driver->xine = cl->xine; + _ao_driver->audio = data; + _ao_driver->fifo = NULL; + _ao_driver->fifo_read_ptr = 0; + _ao_driver->fifo_write_ptr = 0; + _ao_driver->fifo_flush = 2; + _ao_driver->fifo_delay = 0; + _ao_driver->capabilities = (AO_CAP_MODE_MONO | AO_CAP_MODE_STEREO); + + _ao_driver->ao_driver.get_capabilities = ao_fifo_get_capabilities; + _ao_driver->ao_driver.get_property = ao_fifo_get_property; + _ao_driver->ao_driver.set_property = ao_fifo_set_property; + _ao_driver->ao_driver.open = ao_fifo_open; + _ao_driver->ao_driver.num_channels = ao_fifo_num_channels; + _ao_driver->ao_driver.bytes_per_frame = ao_fifo_bytes_per_frame; + _ao_driver->ao_driver.delay = ao_fifo_delay; + _ao_driver->ao_driver.write = ao_fifo_write; + _ao_driver->ao_driver.close = ao_fifo_close; + _ao_driver->ao_driver.exit = ao_fifo_exit; + _ao_driver->ao_driver.get_gap_tolerance = ao_fifo_get_gap_tolerance; + _ao_driver->ao_driver.control = ao_fifo_control; + + pthread_cond_init( &_ao_driver->cond, NULL ); + pthread_mutex_init( &_ao_driver->read_mutex, NULL ); + pthread_mutex_init( &_ao_driver->write_mutex, NULL ); + + return &_ao_driver->ao_driver; +} + +static void *_arts_plugin_class_init(xine_t *xine, void *data) { + fifo_class_t *cl; + + cl = (fifo_class_t *) malloc(sizeof(fifo_class_t)); + if (!cl) return NULL; + cl->driver_class.open_plugin = _arts_open; + cl->driver_class.identifier = _arts_class_identifier_get(NULL); + cl->driver_class.description = _arts_class_description_get(NULL); + cl->driver_class.dispose = _arts_class_dispose; + cl->config = xine->config; + cl->xine = xine; + + return cl; +} + +static ao_info_t _arts_info = +{ + 1 /* priority */ +}; + +plugin_info_t arts_xine_plugin_info[] = +{ + { PLUGIN_AUDIO_OUT, AUDIO_OUT_IFACE_VERSION, "arts", XINE_VERSION_CODE, &_arts_info, _arts_plugin_class_init }, + { PLUGIN_NONE, 0, "", 0, NULL, NULL } +}; +#endif + xine_audio_port_t *init_audio_out_plugin( xine_t *xine, xine_arts_audio *audio, void **ao_driver ) { +#ifdef XINE_DEBUG + xine->verbosity = 1; +#endif + +#if (XINE_MAJOR_VERSION >= 1) && (XINE_MINOR_VERSION >= 2) + xine_audio_port_t *ret; + xine_register_plugins(xine, arts_xine_plugin_info); + ret = xine_open_audio_driver( xine, "arts", audio ); + if (ret) { + *ao_driver = (void *)_ao_driver; + } + return ret; +#else fifo_driver_t *ao = (fifo_driver_t *)malloc( sizeof(fifo_driver_t) ); ao->audio = audio; @@ -312,7 +426,8 @@ xine_audio_port_t *init_audio_out_plugin( xine_t *xine, xine_arts_audio *audio, *ao_driver = (void *)ao; - return _x_ao_new_port( xine, (ao_driver_t *)ao, 0 ); + return ao_new_port( xine, (ao_driver_t *)ao, 0 ); +#endif } unsigned long ao_fifo_read( void *ao_driver, unsigned char **buffer, diff --git a/xine_artsplugin/configure.in.in b/xine_artsplugin/configure.in.in index 61168fb8..7797d223 100644 --- a/xine_artsplugin/configure.in.in +++ b/xine_artsplugin/configure.in.in @@ -232,11 +232,11 @@ int shmCompletionType = XShmGetEventBase( display ); AC_LANG_RESTORE() dnl Check for new internal xine symbol names -KDE_CHECK_LIB(xine, _x_ao_new_port, :, +KDE_CHECK_LIB(xine, ao_new_port, :, [ - AC_DEFINE(_x_ao_new_port, ao_new_port, [Compatibility with older version of xine]) + AC_DEFINE(ao_new_port, _x_ao_new_port, [Compatibility with newer versions of xine]) ]) -AC_CHECK_FUNC([ao_new_port]) +AC_CHECK_FUNC([_x_ao_new_port]) AC_ARG_WITH([xine], [AC_HELP_STRING([--with-xine],