# HG changeset patch # User William Pitcock # Date 1241561244 18000 # Node ID 7cb2239f78ea4da6affb34a3aaca9c764aefc319 # Parent b3402e6f9aaa726fa1aeb965ad9d697a06e52c43 arts: removed diff -r b3402e6f9aaa -r 7cb2239f78ea configure.ac --- a/configure.ac Tue May 05 10:00:57 2009 -0400 +++ b/configure.ac Tue May 05 17:07:24 2009 -0500 @@ -849,22 +849,6 @@ OUTPUT_PLUGINS="$OUTPUT_PLUGINS jack" fi -dnl *** arts output plugin -AC_ARG_ENABLE( arts, -[ --disable-arts disable arts output plugin (default=enabled)],, - enable_arts="yes") - -if test "x$enable_arts" = "xyes"; then - AM_PATH_ARTSC(0.9.5, have_arts=yes, have_arts=no) -else - AC_MSG_RESULT([*** arts plugin disabled per user request ***]) - have_arts=no -fi - -if test "x$have_arts" = "xyes"; then - OUTPUT_PLUGINS="$OUTPUT_PLUGINS arts" -fi - dnl *** sid AC_ARG_ENABLE( sid, [ --disable-sid disable SID input plugin (default=enabled)],, @@ -1691,7 +1675,6 @@ echo " Advanced Linux Sound Arch. (alsa): $have_alsa" echo " Enlightenment Sound Daemon (esd): $have_esd" echo " Jack Audio Connection Kit (jack): $have_jack" -echo " Analog Realtime Synthesizer (arts): $have_arts" echo " BSD/SUN audio output (sun): $have_sun" echo " PulseAudio sound server (pulse_audio): $have_pulse" echo " Mac OS X sound support (CoreAudio): $have_coreaudio" diff -r b3402e6f9aaa -r 7cb2239f78ea src/arts/Makefile --- a/src/arts/Makefile Tue May 05 10:00:57 2009 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -PLUGIN = arts${PLUGIN_SUFFIX} - -SRCS = arts.c \ - configure.c \ - audio.c \ - convert.c - -SUBDIRS = arts_helper - -include ../../buildsys.mk -include ../../extra.mk - -plugindir := ${plugindir}/${OUTPUT_PLUGIN_DIR} - -CFLAGS += ${PLUGIN_CFLAGS} -CPPFLAGS += ${PLUGIN_CPPFLAGS} ${MOWGLI_CFLAGS} ${GTK_CFLAGS} ${GLIB_CFLAGS} ${ARTSC_CFLAGS} -I../.. -LIBS += ${GTK_LIBS} ${GLIB_LIBS} ${ARTSC_LIBS} -lpthread diff -r b3402e6f9aaa -r 7cb2239f78ea src/arts/arts.c --- a/src/arts/arts.c Tue May 05 10:00:57 2009 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* - * aRts ouput plugin for xmms - * - * Copyright (C) 2000,2003 Haavard Kvaalen - * - * Licenced under GNU GPL version 2. - * - * Audacious port by Giacomo Lozito from develia.org - * - */ - -#include "arts.h" - -static void about(void) -{ - static GtkWidget *dialog; - - if (dialog) - return; - - dialog = audacious_info_dialog(_("About aRts Output"), - _("aRts output plugin by " - "H\303\245vard Kv\303\245len \n" - "Audacious port by Giacomo Lozito from develia.org"), - _("Ok"), FALSE, NULL, NULL); - gtk_signal_connect(GTK_OBJECT(dialog), "destroy", - GTK_SIGNAL_FUNC(gtk_widget_destroyed), - &dialog); -} - - -OutputPlugin arts_op = -{ - .description = "aRts Output Plugin", - .init = artsxmms_init, - .cleanup = NULL, - .about = about, - .configure = artsxmms_configure, - .get_volume = artsxmms_get_volume, - .set_volume = artsxmms_set_volume, - .open_audio = artsxmms_open, - .write_audio = artsxmms_write, - .close_audio = artsxmms_close, - .flush = artsxmms_flush, - .pause = artsxmms_pause, - .buffer_free = artsxmms_free, - .buffer_playing = artsxmms_playing, - .output_time = artsxmms_get_output_time, - .written_time = artsxmms_get_written_time, - .tell_audio = artsxmms_tell_audio -}; - -OutputPlugin *arts_oplist[] = { &arts_op, NULL }; - -DECLARE_PLUGIN(arts, NULL, NULL, NULL, arts_oplist, NULL, NULL, NULL, NULL); diff -r b3402e6f9aaa -r 7cb2239f78ea src/arts/arts.h --- a/src/arts/arts.h Tue May 05 10:00:57 2009 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -/* - * aRts ouput plugin for xmms - * - * Copyright (C) 2000,2003 Haavard Kvaalen - * - * Licenced under GNU GPL version 2. - * - * Audacious port by Giacomo Lozito from develia.org - * - */ - -#ifndef XMMS_ARTS_H -#define XMMS_ARTS_H - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include -# include "config.h" - -struct arts_config -{ - int buffer_size; -}; - -struct params_info -{ - AFormat format; - int frequency; - int channels; - - /* Cache these */ - int bps; - int resolution; -}; - -extern struct arts_config artsxmms_cfg; - -void artsxmms_init(void); -void artsxmms_about(void); -void artsxmms_configure(void); - -void artsxmms_tell_audio( AFormat * , gint * , gint * ); - -void artsxmms_get_volume(int *l, int *r); -void artsxmms_set_volume(int l, int r); - -int artsxmms_playing(void); -int artsxmms_free(void); -void artsxmms_write(void *ptr, int length); -void artsxmms_close(void); -void artsxmms_flush(int time); -void artsxmms_pause(short p); -int artsxmms_open(AFormat fmt, int rate, int nch); -int artsxmms_get_output_time(void); -int artsxmms_get_written_time(void); - -int (*arts_get_convert_func(int input))(void **, int); - - -#endif diff -r b3402e6f9aaa -r 7cb2239f78ea src/arts/arts_helper/Makefile --- a/src/arts/arts_helper/Makefile Tue May 05 10:00:57 2009 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -PROG = audacious-arts-helper${PROG_SUFFIX} - -SRCS = arts_helper.c - -include ../../../buildsys.mk -include ../../../extra.mk - -CPPFLAGS += ${ARTSC_CFLAGS} -I../../../intl -I../../.. -LIBS += ${ARTSC_LIBS} -LDFLAGS += -Wl,-export-dynamic diff -r b3402e6f9aaa -r 7cb2239f78ea src/arts/arts_helper/arts_helper.c --- a/src/arts/arts_helper/arts_helper.c Tue May 05 10:00:57 2009 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,446 +0,0 @@ -/* - * aRts ouput plugin for xmms - * - * Copyright (C) 2000,2003 Haavard Kvaalen - * - * Licenced under GNU GPL version 2. - * - * Audacious port by Giacomo Lozito from develia.org - * - */ - -#include "arts_helper.h" - -#include -#include -#include -#include -#include -#include -#include - -#include - -#define FALSE 0 -#define TRUE (!FALSE) -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) - -#ifdef WORDS_BIGENDIAN -#define INT16_FROM_LE(val) ((val & 0xff) << 8 | (val & 0xff00) >> 8) -#define INT16_TO_LE(val) ((val & 0xff) << 8 | (val & 0xff00) >> 8) -#else -#define INT16_FROM_LE(val) (val) -#define INT16_TO_LE(val) (val) -#endif - -/* This is not quite portable, but should be ok anyway */ -typedef short int16; - -static arts_stream_t handle; - -static int going, paused, inited; -static struct params_info output_params; - -struct { - int left, right; -} volume = {100, 100}; - -struct params_info -{ - int resolution; - int frequency; - int channels; - - /* Cache */ - int bps; -}; - -static struct { - unsigned int bsize, latency, psize; -} arts_params; - -static struct { - char *ptr; - int size; - int rd, wr; -} ring_buffer; - -static void artsxmms_set_params(struct params_info *params, int resolution, int rate, int nch) -{ - params->frequency = rate; - params->channels = nch; - - params->bps = rate * nch; - params->resolution = resolution; - if (resolution == 16) - params->bps *= 2; -} - -static int artsxmms_free(void) -{ - if (ring_buffer.rd > ring_buffer.wr) - return ring_buffer.rd - ring_buffer.wr - 1; - return ring_buffer.size - (ring_buffer.wr - ring_buffer.rd); -} - -static int artsxmms_buffer_used(void) -{ - return ring_buffer.size - artsxmms_free(); -} - -static int artsxmms_get_output_latency(void) -{ - int latency; - long long w; - - if (!going) - return 0; - - w = artsxmms_buffer_used(); - w += arts_params.bsize - arts_stream_get(handle, ARTS_P_BUFFER_SPACE); - latency = (w * 1000) / output_params.bps; - - if (!paused) - latency += arts_params.latency; - - return latency; -} - -static int artsxmms_playing(void) -{ - if (!going) - return FALSE; - - if (!paused) - { - int t; - t = arts_stream_get(handle, ARTS_P_BUFFER_SPACE); - return t < arts_params.bsize - arts_params.psize; - } - - return TRUE; -} - -static void artsxmms_open_stream(struct params_info *params, int buffer_time) -{ - int buffersize = buffer_time * params->bps / 1000; - handle = arts_play_stream(params->frequency, params->resolution, - params->channels, "XMMS"); - arts_params.bsize = arts_stream_set(handle, ARTS_P_BUFFER_SIZE, - buffersize); - arts_params.latency = arts_stream_get(handle, ARTS_P_SERVER_LATENCY); - arts_params.psize = arts_stream_get(handle, ARTS_P_PACKET_SIZE); -} - -static void artsxmms_set_volume(int l, int r) -{ - volume.left = l; - volume.right = r; -} - -static void volume_adjust(void* data, int length) -{ - int i; - - if ((volume.left == 100 && volume.right == 100) || - (output_params.channels == 1 && - (volume.left == 100 || volume.right == 100))) - return; - - if (output_params.resolution == 16) - { - int16 *ptr = data; - if (output_params.channels == 2) - for (i = 0; i < length; i += 4) - { - *ptr = INT16_TO_LE(INT16_FROM_LE(*ptr) * - volume.left / 100); - ptr++; - *ptr = INT16_TO_LE(INT16_FROM_LE(*ptr) * - volume.right / 100); - ptr++; - } - else - { - int vol = MAX(volume.left, volume.right); - for (i = 0; i < length; i += 2, ptr++) - { - *ptr = INT16_TO_LE(INT16_FROM_LE(*ptr) * - vol / 100); - } - } - } - else - { - unsigned char *ptr = data; - if (output_params.channels == 2) - for (i = 0; i < length; i += 2) - { - *ptr = *ptr * volume.left / 100; - ptr++; - *ptr = *ptr * volume.right / 100; - ptr++; - } - else - { - int vol = MAX(volume.left, volume.right); - for (i = 0; i < length; i++, ptr++) - { - *ptr = *ptr * vol / 100; - } - } - } -} - -static void artsxmms_write(char *ptr, int length) -{ - int cnt; - - /* FIXME: Check that length is not too large? */ - while (length > 0) - { - cnt = MIN(length, ring_buffer.size - ring_buffer.wr); - memcpy(ring_buffer.ptr + ring_buffer.wr, ptr, cnt); - ring_buffer.wr = (ring_buffer.wr + cnt) % ring_buffer.size; - length -= cnt; - ptr += cnt; - } -} - -static void artsxmms_write_arts(void) -{ - int ret, cnt, space; - char *ptr; - - if (ring_buffer.wr == ring_buffer.rd || paused) - return; - - space = arts_stream_get(handle, ARTS_P_BUFFER_SPACE); - - while (space > 0 && ring_buffer.wr != ring_buffer.rd) - { - if (ring_buffer.wr > ring_buffer.rd) - cnt = MIN(space, ring_buffer.wr - ring_buffer.rd); - else - cnt = MIN(space, ring_buffer.size - ring_buffer.rd); - - ptr = ring_buffer.ptr + ring_buffer.rd; - - volume_adjust(ptr, cnt); - ret = arts_write(handle, ptr, cnt); - if (ret < 0) - { - /* FIXME: handle this better? */ - fprintf(stderr, "artsxmms_write(): write error: %s\n", - arts_error_text(ret)); - return; - } - - ring_buffer.rd = (ring_buffer.rd + cnt) % ring_buffer.size; - space -= cnt; - } -} - -static void artsxmms_close(void) -{ - going = 0; - arts_close_stream(handle); - arts_free(); -} - -static int read_all(int fd, void *buf, size_t count) -{ - size_t left = count; - int r; - do { - r = read(fd, buf, left); - if (r < 0) - return -1; - left -= r; - buf = (char *)buf + r; - } while (left > 0 && r > 0); - return count - left; -} - -static int write_all(int fd, const void *buf, size_t count) -{ - size_t left = count; - int w; - do { - w = write(fd, buf, left); - - if (w < 0) - return -1; - left -= w; - buf = (char *)buf + w; - } while (left > 0 && w > 0); - return count - left; -} - - -static int init_ring_buffer(int size) -{ - free(ring_buffer.ptr); - /* Make the ring buffer always end on a sample boundary */ - size -= size % 4; - ring_buffer.size = size; - ring_buffer.ptr = malloc(size); - ring_buffer.rd = 0; - ring_buffer.wr = 0; - if (ring_buffer.ptr == NULL) - return -1; - return 0; -} - -static int helper_init(struct init_data *init) -{ - int buffer_time = MAX(init->buffer_time, 50); - if (init->version != HELPER_VERSION) { - fprintf(stderr, - "Fatal: Version mismatch between arts output plugin and\n" - " audacious-arts-helper program.\n"); - return -1; - } - if (!inited) - return -1; - artsxmms_set_params(&output_params, init->resolution, init->rate, - init->nchannels); - - if (init_ring_buffer((buffer_time * 2 * output_params.bps) / 1000)) - return -1; - - if (handle) - arts_close_stream(handle); - artsxmms_open_stream(&output_params, buffer_time); - - going = 1; - return 0; -} - -static int process_cmd(int fd) -{ - struct command inp; - struct response outp; - void *data = NULL; - int retval = 0; - - if (read_all(fd, &inp, sizeof(inp)) != sizeof(inp)) { - fprintf(stderr, "read short, giving up\n"); - return -1; - } - if (inp.data_length > 0) { - data = malloc(inp.data_length); - if (data == NULL) - return -1; - if (read_all(fd, data, inp.data_length) != inp.data_length) { - fprintf(stderr, "data read short, giving up\n"); - return -1; - } - } - outp.cmd = inp.cmd; - outp.status = STATUS_OK; - outp.data = 0; -/* fprintf(stderr, "Recieved %d; ", inp.cmd); */ - switch (inp.cmd) { - case CMD_QUIT: - artsxmms_close(); - retval = 1; - break; - case CMD_INIT: - if (inp.data_length != sizeof (struct init_data)) - outp.status = STATUS_FAILED; - else if (helper_init(data)) - outp.status = STATUS_FAILED; - break; - case CMD_PAUSE: - paused = inp.data; - break; - case CMD_SET_VOLUME: { - int *vol = data; - if (inp.data_length < 2 * sizeof(int)) { - outp.status = STATUS_FAILED; - break; - } - artsxmms_set_volume(vol[0], vol[1]); - break; - } - case CMD_WRITE: - artsxmms_write(data, inp.data_length); - break; - case CMD_FREE: - outp.data = artsxmms_free(); - break; - case CMD_GET_OUTPUT_LATENCY: - outp.data = artsxmms_get_output_latency(); - break; - case CMD_QUERY_PLAYING: - outp.data = artsxmms_playing(); - break; - default: - outp.status = STATUS_UNKNOWN; - fprintf(stderr, "Unknown command %d\n", inp.cmd); - } - free(data); - if (write_all(fd, &outp, sizeof (outp)) != sizeof (outp)) - return -1; - return retval; -} - - -static int main_loop(int fd) -{ - int retval = 0, sr; - struct timeval timeout; - fd_set rdfs; - - for (;;) { - FD_ZERO(&rdfs); - FD_SET(fd, &rdfs); - timeout.tv_sec = 0; - timeout.tv_usec = 20000; - sr = select(fd + 1, &rdfs, NULL, NULL, &timeout); - if (sr < 0) { - fprintf(stderr, "audacious-arts-helper select failed: %s\n", - strerror(errno)); - retval = -1; - break; - } else if (sr) { - int p = process_cmd(fd); - if (p < 0) { - fprintf(stderr, "cmd failed\n"); - retval = 1; - break; - } else if (p) - break; - } - - artsxmms_write_arts(); - } - return retval; -} - -int main(int argc, char **argv) -{ - int fd, err, ret; - - if (argc != 2 || (fd = atoi(argv[1])) < 1) - { - fprintf(stderr, "Usage: audacious-arts-helper fd\n"); - return 1; - } - - inited = 1; - - if ((err = arts_init()) != 0) - { - fprintf(stderr, "artsxmms_open(): Unable to initialize aRts: %s\n", - arts_error_text(err)); - inited = 0; - } - - ret = main_loop(fd); - close(fd); -/* fprintf(stderr, "helper exits\n"); */ - return ret < 0; -} diff -r b3402e6f9aaa -r 7cb2239f78ea src/arts/arts_helper/arts_helper.h --- a/src/arts/arts_helper/arts_helper.h Tue May 05 10:00:57 2009 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* - * aRts ouput plugin for xmms - * - * Copyright (C) 2000,2003,2004 Haavard Kvaalen - * - * Licenced under GNU GPL version 2. - * - * Audacious port by Giacomo Lozito from develia.org - * - */ - -struct command -{ - int cmd; - int data; - int data_length; -}; - -struct response -{ - int cmd; - int status; - int data; -}; - -#define HELPER_VERSION 0x000700 - -struct init_data -{ - int version; - int resolution, rate, nchannels; - int buffer_time; -}; - -enum { - CMD_INIT = 1, - CMD_QUIT, - CMD_PAUSE, - CMD_FLUSH, - CMD_SET_VOLUME, - CMD_WRITE, - CMD_FREE, - CMD_GET_OUTPUT_LATENCY, - CMD_QUERY_PLAYING, -}; - -enum { - STATUS_OK = 0, - STATUS_FAILED, - STATUS_UNKNOWN, -}; - diff -r b3402e6f9aaa -r 7cb2239f78ea src/arts/audio.c --- a/src/arts/audio.c Tue May 05 10:00:57 2009 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,390 +0,0 @@ -/* - * aRts ouput plugin for xmms - * - * Copyright (C) 2000,2003 Haavard Kvaalen - * - * Licenced under GNU GPL version 2. - * - * Audacious port by Giacomo Lozito from develia.org - * - */ - -#include "arts.h" -#include "arts_helper/arts_helper.h" -#include -#include -#include - -#include -#include -#include -#include - -static gboolean going, paused, helper_failed; -static guint64 written; -static struct params_info input_params, output_params; -static int helperfd; -static pid_t helper_pid; - -static int (*arts_convert_func)(void **data, int length); -struct arts_config artsxmms_cfg; - -struct { - int left, right; -} volume = {100, 100}; - - -typedef struct format_info { - AFormat format; - long frequency; - int channels; - long bps; -} format_info_t; - -static format_info_t input; -/* static format_info_t effect; */ -/* static format_info_t output; */ - - -void artsxmms_tell_audio(AFormat * fmt, gint * srate, gint * nch) -{ - (*fmt) = input.format; - (*srate) = input.frequency; - (*nch) = input.channels; -} - - -void artsxmms_init(void) -{ - mcs_handle_t *db; - - memset(&artsxmms_cfg, 0, sizeof (artsxmms_cfg)); - - artsxmms_cfg.buffer_size = 400; - - db = aud_cfg_db_open(); - aud_cfg_db_get_int(db, "arts", "buffer_size", - &artsxmms_cfg.buffer_size); - aud_cfg_db_close(db); -} - - -static int read_all(int fd, void *buf, size_t count) -{ - size_t left = count; - int r; - do { - r = read(fd, buf, left); - if (r < 0) - return -1; - left -= r; - buf = (char *)buf + r; - } while (left > 0 && r > 0); - return count - left; -} - -static int write_all(int fd, const void *buf, size_t count) -{ - size_t left = count; - int w; - do { - w = write(fd, buf, left); - if (w < 0) - return -1; - left -= w; - buf = (char *)buf + w; - } while (left > 0 && w > 0); -/* g_message("wrote: %d", count - left); */ - return count - left; -} - -static int wait_for_helper(int fd) -{ - struct timeval timeout; - fd_set rdfs; - int sr; - - FD_ZERO(&rdfs); - FD_SET(fd, &rdfs); - - timeout.tv_sec = 10; - timeout.tv_usec = 0; - - sr = select(fd + 1, &rdfs, NULL, NULL, &timeout); - if (sr < 0) { - g_message("wait_for_helper(): select failed: %s", - strerror(errno)); - return -1; - } else if (!sr) { - g_message("wait_for_helper(): Timed out waiting for helper"); - return -1; - } - return 0; -} - -static int xx; - -static int helper_cmd_data(int cmd, int idata, void* ptr, int data_length) -{ - static pthread_mutex_t artsm = PTHREAD_MUTEX_INITIALIZER; - struct command out; - struct response in; - int status; - - out.cmd = cmd; - out.data = idata; - out.data_length = data_length; - xx++; - - if (helper_failed) - goto failed; - - pthread_mutex_lock(&artsm); -/* fprintf(stderr, "Sending %d; ", out.cmd); */ - if (write_all(helperfd, &out, sizeof (out)) != sizeof (out)) - goto failed; - if (data_length > 0) - if (write_all(helperfd, ptr, data_length) != data_length) - goto failed; - - if (wait_for_helper(helperfd)) { - g_message("waiting failed: %d", cmd); - goto failed; - } - - if (read_all(helperfd, &in, sizeof (in)) != sizeof (in)) - { - g_message("read failed: %d", cmd); - goto failed; - } - -/* fprintf(stderr, "%d complete\n", out.cmd); */ - pthread_mutex_unlock(&artsm); - - if (in.status) - return -in.status; - return in.data; - - failed: - g_message("helper_cmd_data(): failed"); - helper_failed = TRUE; - if (helper_pid && waitpid(helper_pid, &status, WNOHANG)) { - if (status) - g_message("helper terminated abnormally: %d", status); - else - g_message("helper terminated normally"); - helper_pid = 0; - } else if (helper_pid) - g_message("helper has not terminated"); - pthread_mutex_unlock(&artsm); - return -STATUS_FAILED; -} - -static int helper_cmd(int cmd, int idata) -{ - return helper_cmd_data(cmd, idata, NULL, 0); -} - -static int artsxmms_helper_init(struct params_info *params) -{ - int ret; - struct init_data id; - - id.version = HELPER_VERSION; - id.resolution = params->resolution; - id.rate= params->frequency; - id.nchannels = params->channels; - id.buffer_time = artsxmms_cfg.buffer_size; - - ret = helper_cmd_data(CMD_INIT, 0, &id, sizeof (id)); - if (ret) { - g_message("Init failed: %d", -ret); - return -1; - } - - return 0; -} - -static void artsxmms_set_params(struct params_info *params, AFormat fmt, int rate, int nch) -{ - params->format = fmt; - params->frequency = rate; - params->channels = nch; - - params->bps = rate * nch; - params->resolution = 8; - if (!(fmt == FMT_U8 || fmt == FMT_S8)) - { - params->bps *= 2; - params->resolution = 16; - } -} - -int artsxmms_get_written_time(void) -{ - if (!going) - return 0; - - return (written * 1000) / output_params.bps; -} - -int artsxmms_get_output_time(void) -{ - int time; - - if (!going) - return 0; - if (helper_failed) - return -2; - - time = artsxmms_get_written_time(); - time -= helper_cmd(CMD_GET_OUTPUT_LATENCY, 0); - - if (time < 0) - return 0; - return time; -} - -int artsxmms_playing(void) -{ - if (!going) - return FALSE; - - if (!paused) - { - if (helper_cmd(CMD_QUERY_PLAYING, 0) <= 0) - return FALSE; - return TRUE; - } - - return TRUE; -} - -int artsxmms_free(void) -{ - int space; - - if (!going) - return 0; - - space = helper_cmd(CMD_FREE, 0); - if (space < 0) - return 0; - - return space; -} - -void artsxmms_write(gpointer ptr, int length) -{ - if (arts_convert_func) - arts_convert_func(ptr, length); - - helper_cmd_data(CMD_WRITE, 0, ptr, length); - written += length; -} - -void artsxmms_close(void) -{ - int status; - going = 0; -/* g_message("sending quit cmd"); */ - if (!helper_cmd(CMD_QUIT, 0)) { - waitpid(helper_pid, &status, 0); - if (status) - g_message("artsxmms_close(): Child exited abnormally: %d", - status); - } -} - -void artsxmms_flush(int time) -{ - /* - * Argh, no way to flush the stream from the C api. - */ - written = (time / 10) * (output_params.bps / 100); - -} - -void artsxmms_pause(short p) -{ - paused = p; - helper_cmd(CMD_PAUSE, p); -} - -static int artsxmms_start_helper() -{ - int sockets[2]; - - if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockets) < 0) - { - g_message("artsxmms_start_helper(): " - "Failed to create socketpair: %s", strerror(errno)); - return -1; - } - - if ((helper_pid = fork()) == 0) - { - /* Child */ - char sockfdstr[10]; - close(sockets[1]); - sprintf(sockfdstr, "%d", sockets[0]); - execlp("audacious-arts-helper", "audacious-arts-helper", - sockfdstr, NULL); - g_warning("artsxmms_start_helper(): " - "Failed to start audacious-arts-helper: %s", strerror(errno)); - close(sockets[0]); - _exit(1); - } - close(sockets[0]); - helperfd = sockets[1]; - - if (helper_pid < 0) - { - g_message("artsxmms_start_helper(): " - "Failed to fork() helper process: %s", strerror(errno)); - close(sockets[1]); - return -1; - } - - return 0; -} - -int artsxmms_open(AFormat fmt, int rate, int nch) -{ - if (artsxmms_start_helper() < 0) - return 0; - - artsxmms_set_params(&input_params, fmt, rate, nch); - artsxmms_set_params(&output_params, fmt, rate, nch); - - arts_convert_func = arts_get_convert_func(output_params.format); - - written = 0; - paused = 0; - helper_failed = FALSE; - - if (artsxmms_helper_init(&output_params)) { - artsxmms_close(); - return 0; - } - artsxmms_set_volume(volume.left, volume.right); - - going = 1; - return 1; -} - -void artsxmms_get_volume(int *l, int *r) -{ - *l = volume.left; - *r = volume.right; -} - -void artsxmms_set_volume(int l, int r) -{ - int vol[2]; - volume.left = l; - volume.right = r; - vol[0] = l; - vol[1] = r; - helper_cmd_data(CMD_SET_VOLUME, 0, vol, sizeof(vol)); -} diff -r b3402e6f9aaa -r 7cb2239f78ea src/arts/configure.c --- a/src/arts/configure.c Tue May 05 10:00:57 2009 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,104 +0,0 @@ -/* - * aRts ouput plugin for xmms - * - * Copyright (C) 2000,2003 Haavard Kvaalen - * - * Licenced under GNU GPL version 2. - * - * Audacious port by Giacomo Lozito from develia.org - * - */ - -#include "arts.h" - -#include - -static GtkWidget *configure_win = NULL; -static GtkWidget *buffer_size_spin; - -static void configure_win_ok_cb(GtkWidget * w, gpointer data) -{ - mcs_handle_t *db; - - artsxmms_cfg.buffer_size = - gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(buffer_size_spin)); - - db = aud_cfg_db_open(); - aud_cfg_db_set_int(db, "arts", "buffer_size", artsxmms_cfg.buffer_size); - aud_cfg_db_close(db); - - gtk_widget_destroy(configure_win); -} - - -void artsxmms_configure(void) -{ - GtkWidget *vbox, *notebook; - GtkWidget *buffer_frame, *buffer_vbox, *buffer_table; - GtkWidget *buffer_size_box, *buffer_size_label; - GtkWidget *bbox, *ok, *cancel; - - GtkObject *buffer_size_adj; - - if (configure_win) - return; - - configure_win = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_type_hint( GTK_WINDOW(configure_win), GDK_WINDOW_TYPE_HINT_DIALOG ); - gtk_signal_connect(GTK_OBJECT(configure_win), "destroy", - GTK_SIGNAL_FUNC(gtk_widget_destroyed), &configure_win); - gtk_window_set_title(GTK_WINDOW(configure_win), _("aRts Driver configuration")); - gtk_window_set_policy(GTK_WINDOW(configure_win), FALSE, FALSE, FALSE); - gtk_window_set_position(GTK_WINDOW(configure_win), GTK_WIN_POS_MOUSE); - gtk_container_border_width(GTK_CONTAINER(configure_win), 10); - - vbox = gtk_vbox_new(FALSE, 10); - gtk_container_add(GTK_CONTAINER(configure_win), vbox); - - notebook = gtk_notebook_new(); - gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0); - - buffer_frame = gtk_frame_new(_("Buffering:")); - gtk_container_set_border_width(GTK_CONTAINER(buffer_frame), 5); - - buffer_vbox = gtk_vbox_new(FALSE, 0); - gtk_container_add(GTK_CONTAINER(buffer_frame), buffer_vbox); - - buffer_table = gtk_table_new(2, 1, TRUE); - gtk_container_set_border_width(GTK_CONTAINER(buffer_table), 5); - gtk_box_pack_start(GTK_BOX(buffer_vbox), buffer_table, FALSE, FALSE, 0); - - buffer_size_box = gtk_hbox_new(FALSE, 5); - gtk_table_attach_defaults(GTK_TABLE(buffer_table), buffer_size_box, 0, 1, 0, 1); - buffer_size_label = gtk_label_new(_("Buffer size (ms):")); - gtk_box_pack_start(GTK_BOX(buffer_size_box), buffer_size_label, FALSE, FALSE, 0); - gtk_widget_show(buffer_size_label); - buffer_size_adj = gtk_adjustment_new(artsxmms_cfg.buffer_size, - 200, 10000, 100, 100, 100); - buffer_size_spin = gtk_spin_button_new(GTK_ADJUSTMENT(buffer_size_adj), 8, 0); - gtk_widget_set_usize(buffer_size_spin, 60, -1); - gtk_box_pack_start(GTK_BOX(buffer_size_box), buffer_size_spin, FALSE, FALSE, 0); - - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), buffer_frame, - gtk_label_new(_("Buffering"))); - - bbox = gtk_hbutton_box_new(); - gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); - gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); - gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); - - ok = gtk_button_new_with_label(_("Ok")); - cancel = gtk_button_new_with_label(_("Cancel")); - GTK_WIDGET_SET_FLAGS(ok, GTK_CAN_DEFAULT); - GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); - gtk_signal_connect(GTK_OBJECT(ok), "clicked", - GTK_SIGNAL_FUNC(configure_win_ok_cb), NULL); - gtk_signal_connect_object(GTK_OBJECT(cancel), "clicked", - GTK_SIGNAL_FUNC(gtk_widget_destroy), - GTK_OBJECT(configure_win)); - gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 0); - gtk_widget_grab_default(ok); - gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0); - - gtk_widget_show_all(configure_win); -} diff -r b3402e6f9aaa -r 7cb2239f78ea src/arts/convert.c --- a/src/arts/convert.c Tue May 05 10:00:57 2009 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2001-2003 Haavard Kvaalen - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "config.h" - -#include -#include - -#ifdef WORDS_BIGENDIAN -# define IS_BIG_ENDIAN TRUE -#else -# define IS_BIG_ENDIAN FALSE -#endif - - - -static int convert_swap_endian(void **data, int length) -{ - guint16 *ptr = *data; - int i; - for (i = 0; i < length; i += 2, ptr++) - *ptr = GUINT16_SWAP_LE_BE(*ptr); - - return i; -} - -static int convert_swap_sign_and_endian_to_native(void **data, int length) -{ - guint16 *ptr = *data; - int i; - for (i = 0; i < length; i += 2, ptr++) - *ptr = GUINT16_SWAP_LE_BE(*ptr) ^ 1 << 15; - - return i; -} - -static int convert_swap_sign_and_endian_to_alien(void **data, int length) -{ - guint16 *ptr = *data; - int i; - for (i = 0; i < length; i += 2, ptr++) - *ptr = GUINT16_SWAP_LE_BE(*ptr ^ 1 << 15); - - return i; -} - -static int convert_swap_sign16(void **data, int length) -{ - gint16 *ptr = *data; - int i; - for (i = 0; i < length; i += 2, ptr++) - *ptr ^= 1 << 15; - - return i; -} - -static int convert_swap_sign8(void **data, int length) -{ - gint8 *ptr = *data; - int i; - for (i = 0; i < length; i++) - *ptr++ ^= 1 << 7; - - return i; -} - -int (*arts_get_convert_func(int input))(void **, int) -{ - if (input == FMT_S16_NE) - input = IS_BIG_ENDIAN ? FMT_S16_BE : FMT_S16_LE; - else if (input == FMT_U16_NE) - input = IS_BIG_ENDIAN ? FMT_U16_BE : FMT_U16_LE; - - if (input == FMT_S16_LE || input == FMT_U8) - return NULL; - - if (input == FMT_S16_BE) - return convert_swap_endian; - - if (input == FMT_U16_LE) - return convert_swap_sign16; - - if (!IS_BIG_ENDIAN && input == FMT_U16_BE) - return convert_swap_sign_and_endian_to_native; - - if (IS_BIG_ENDIAN && input == FMT_U16_BE) - return convert_swap_sign_and_endian_to_alien; - - if (input == FMT_S8) - return convert_swap_sign8; - - g_warning("Translation needed, but not available.\n" - "Input: %d.", input); - return NULL; -}