On Sun, Feb 03, 2008 at 12:02:02AM +0000, Jacob Meuser wrote: > hmm, yep, there are some problems with the sun output plugin. > > patch below against in-tree port fixes some of them, but there is > still a problem with format conversions. I'll have a patch for that > later.
here ya go. dunno how _useful_ all the encoding changes are. seems audacious reformats to s16 native endian for you. but I do think this is better. if the format conversions aren't necessary, I'd rather see them removed, because they could be a bad example for someone down the road. anyway, there was still a bug that showed up with playing 8-bit WAVs on devices that don't support 8-bit formats. -- [EMAIL PROTECTED] SDF Public Access UNIX System - http://sdf.lonestar.org $OpenBSD$ --- src/sun/audio.c.orig Mon Sep 18 03:14:20 2006 +++ src/sun/audio.c Sat Feb 2 23:55:26 2008 @@ -25,7 +25,7 @@ #include "resample.h" static int sun_bps(int, int, int); -static int sun_format(AFormat); +static int sun_format(AFormat, int *, int *); static void sun_setformat(AFormat, int, int); static void sun_setparams(void); @@ -66,76 +66,88 @@ struct sun_format effect; */ struct sun_format output; -static int sun_bps(int sunfmt, int rate, int nch) +static int sun_bps(int precision, int rate, int nch) { int bitrate; - bitrate = rate * nch; + bitrate = rate * nch * precision / 8; - switch (sunfmt) - { - case AUDIO_ENCODING_ULINEAR_BE: - case AUDIO_ENCODING_ULINEAR_LE: - case AUDIO_ENCODING_SLINEAR_BE: - case AUDIO_ENCODING_SLINEAR_LE: - bitrate *= 2; - break; - } - return (bitrate); } -static int sun_format(AFormat fmt) +static int sun_format(AFormat fmt, int *enc, int *precision) { switch (fmt) { case FMT_U8: - return (AUDIO_ENCODING_PCM8); + *precision = 8; + *enc = AUDIO_ENCODING_ULINEAR_LE; + break; case FMT_S8: - return (AUDIO_ENCODING_SLINEAR); + *precision = 8; + *enc = AUDIO_ENCODING_SLINEAR_LE; + break; case FMT_U16_LE: - return (AUDIO_ENCODING_ULINEAR_LE); + *precision = 16; + *enc = AUDIO_ENCODING_ULINEAR_LE; + break; case FMT_U16_BE: - return (AUDIO_ENCODING_ULINEAR_BE); + *precision = 16; + *enc = AUDIO_ENCODING_ULINEAR_BE; + break; case FMT_U16_NE: + *precision = 16; #ifdef WORDS_BIGENDIAN - return (AUDIO_ENCODING_ULINEAR_BE); + *enc = AUDIO_ENCODING_ULINEAR_BE; #else - return (AUDIO_ENCODING_ULINEAR_LE); + *enc = AUDIO_ENCODING_ULINEAR_LE; #endif + break; case FMT_S16_LE: - return (AUDIO_ENCODING_SLINEAR_LE); + *precision = 16; + *enc = AUDIO_ENCODING_SLINEAR_LE; + break; case FMT_S16_BE: - return (AUDIO_ENCODING_SLINEAR_BE); + *precision = 16; + *enc = AUDIO_ENCODING_SLINEAR_BE; + break; case FMT_S16_NE: + *precision = 16; #ifdef WORDS_BIGENDIAN - return (AUDIO_ENCODING_SLINEAR_BE); + *enc = AUDIO_ENCODING_SLINEAR_BE; #else - return (AUDIO_ENCODING_SLINEAR_LE); + *enc = AUDIO_ENCODING_SLINEAR_LE; #endif + break; + default: + return -1; } - return -1; + return 0; } static void sun_setformat(AFormat fmt, int rate, int nch) { - int sun; + int enc, precision; - sun = sun_format(fmt); + if (sun_format(fmt, &enc, &precision) < 0) { + // errx("unknown format"); + } - effect.format.sun = sun; effect.format.xmms = fmt; + effect.format.sun = enc; + effect.precision = precision; effect.frequency = rate; effect.channels = nch; - effect.bps = sun_bps(sun, rate, nch); + effect.bps = sun_bps(precision, rate, nch); - output.format.sun = sun; output.format.xmms = fmt; + output.format.sun = enc; + output.precision = precision; output.frequency = rate; output.channels = nch; sun_setparams(); - output.bps = sun_bps(output.format.sun, output.frequency, + output.bps = sun_bps(output.precision, output.frequency, output.channels); audio.input = &input; @@ -150,7 +162,7 @@ void sun_setparams(void) AUDIO_INITINFO(&info); - info.mode = AUMODE_PLAY; + info.mode = AUMODE_PLAY_ALL; if (ioctl(audio.fd, AUDIO_SETINFO, &info) != 0) { g_error("%s: cannot play (%s)", audio.devaudio, @@ -163,9 +175,16 @@ void sun_setparams(void) */ enc.index = 0; while (ioctl(audio.fd, AUDIO_GETENC, &enc) == 0 && - enc.encoding != output.format.sun) + (enc.encoding != output.format.sun || enc.precision != output.precision)) enc.index++; + if (enc.encoding != output.format.sun || enc.precision != output.precision) { + /* we didn't get the desired format, need to reformat */ + /* try something likely to work on modern hardware */ + enc.encoding = AUDIO_ENCODING_SLINEAR_LE; + enc.precision = 16; + } + info.play.encoding = enc.encoding; info.play.precision = enc.precision; strcpy(output.name, enc.name); @@ -177,7 +196,12 @@ void sun_setparams(void) } info.play.channels = output.channels; - ioctl(audio.fd, AUDIO_SETINFO, &info); + if (ioctl(audio.fd, AUDIO_SETINFO, &info) < 0) + { + g_error("%s: cannot handle %i channels (%s)", audio.devaudio, + output.channels, strerror(errno)); + return; + } info.play.sample_rate = output.frequency; if (ioctl(audio.fd, AUDIO_SETINFO, &info) < 0) @@ -188,17 +212,17 @@ void sun_setparams(void) } if (ioctl(audio.fd, AUDIO_GETINFO, &info) != 0) - { - blocksize = SUN_DEFAULT_BLOCKSIZE; - output.channels = info.play.channels; - } - else - { - blocksize = blocksize; - } + g_error("%s: AUDIO_GETINFO failed: (%s)", + audio.devaudio, strerror(errno)); - sun_convert = sun_get_convert_func(output.format.sun, - sun_format(effect.format.xmms)); + blocksize = info.blocksize; + output.channels = info.play.channels; + output.frequency = info.play.sample_rate; + output.format.sun = info.play.encoding; + output.precision = info.play.precision; + sun_convert = sun_get_convert_func(output.format.sun, output.precision, + effect.format.sun, effect.precision); + #if 0 if (sun_convert != NULL) { @@ -210,12 +234,12 @@ void sun_setparams(void) static inline void sun_bufused(void) { - audio_offset_t ooffs; + u_long ofs; if (audio.paused) device_buffer_used = 0; - else if (ioctl(audio.fd, AUDIO_GETOOFFS, &ooffs) == 0) - device_buffer_used = ooffs.offset; + else if (ioctl(audio.fd, AUDIO_WSEEK, &ofs) == 0) + device_buffer_used = ofs; } int sun_written_time(void) @@ -223,7 +247,7 @@ int sun_written_time(void) if (!audio.going) return 0; - return ((written * 1000) / effect.bps); + return ((written * 1000) / output.bps); } int sun_output_time(void) @@ -293,7 +317,7 @@ static inline ssize_t write_all(int fd, const void *bu { static ssize_t n; - n = write(fd, buf, count - done); + n = write(fd, (gchar *)buf + done, count - done); if (n == -1) { if (errno == EINTR) @@ -311,6 +335,9 @@ static inline void sun_write_audio(gpointer data, int { AFormat new_format; EffectPlugin *ep; +#ifdef AUDIO_GETPRINFO + struct audio_bufinfo buf_info; +#endif int new_frequency, new_channels; new_format = input.format.xmms; @@ -340,6 +367,16 @@ static inline void sun_write_audio(gpointer data, int if (sun_convert != NULL) length = sun_convert(&data, length); +#ifdef AUDIO_GETPRINFO + if (realtime && !ioctl(audio.fd, AUDIO_GETPRINFO, &buf_info)) { + while ((buf_info.hiwat * buf_info.blksize - buf_info.seek) < length) { + xmms_usleep(10000); + if (ioctl(audio.fd, AUDIO_GETPRINFO, &buf_info)) + break; + } + } +#endif + if (effect.frequency == output.frequency) { output_bytes += write_all(audio.fd, data, length); @@ -448,7 +485,7 @@ void sun_flush(int time) ioctl(audio.fd, AUDIO_FLUSH, NULL); output_time_offset = time; - written = (guint16)(time / 10) * (guint64)(input.bps / 100); + written = ((guint64) time * output.bps) / 1000; output_bytes = 0; } @@ -544,7 +581,8 @@ int sun_open(AFormat fmt, int rate, int nch) input.format.xmms = fmt; input.frequency = rate; input.channels = nch; - input.bps = sun_bps(sun_format(fmt), rate, nch); + sun_format(fmt, &input.format.sun, &input.precision); + input.bps = sun_bps(input.precision, rate, nch); sun_setformat(fmt, rate, nch); realtime = xmms_check_realtime_priority(); @@ -556,14 +594,14 @@ int sun_open(AFormat fmt, int rate, int nch) if (!realtime) { - buffer_size = audio.req_buffer_size; + buffer_size = (audio.req_buffer_size * input.bps) / 1000; if (buffer_size < SUN_MIN_BUFFER_SIZE) buffer_size = SUN_MIN_BUFFER_SIZE; prebuffer_size = (buffer_size * audio.req_prebuffer_size) / 100; - buffer_size += blocksize; + buffer_size += blocksize * 3; buffer = g_malloc0(buffer_size); } prebuffer = TRUE; $OpenBSD$ --- src/sun/convert.c.orig Sat Feb 2 20:46:59 2008 +++ src/sun/convert.c Sat Feb 2 21:36:23 2008 @@ -193,156 +193,167 @@ static int convert_to_16_alien_endian_swap_sign(void * return (i * 2); } -int (*sun_get_convert_func(int output, int input))(void **, int) +int (*sun_get_convert_func(int output_enc, int output_precision, int input_enc, int input_precision))(void **, int) { - if (output == input) + if (output_enc == input_enc && output_precision == input_precision) return NULL; - if ((output == AUDIO_ENCODING_ULINEAR_BE && - input == AUDIO_ENCODING_ULINEAR_LE) || - (output == AUDIO_ENCODING_ULINEAR_LE && - input == AUDIO_ENCODING_ULINEAR_BE) || - (output == AUDIO_ENCODING_SLINEAR_BE && - input == AUDIO_ENCODING_SLINEAR_LE) || - (output == AUDIO_ENCODING_SLINEAR_LE && - input == AUDIO_ENCODING_SLINEAR_BE)) - return convert_swap_endian; + if (output_precision == input_precision) { - if ((output == AUDIO_ENCODING_ULINEAR_BE && - input == AUDIO_ENCODING_SLINEAR_BE) || - (output == AUDIO_ENCODING_ULINEAR_LE && - input == AUDIO_ENCODING_SLINEAR_LE) || - (output == AUDIO_ENCODING_SLINEAR_BE && - input == AUDIO_ENCODING_ULINEAR_BE) || - (output == AUDIO_ENCODING_SLINEAR_LE && - input == AUDIO_ENCODING_ULINEAR_LE)) - return convert_swap_sign16; + if ((output_enc == AUDIO_ENCODING_ULINEAR_BE && + input_enc == AUDIO_ENCODING_ULINEAR_LE) || + (output_enc == AUDIO_ENCODING_ULINEAR_LE && + input_enc == AUDIO_ENCODING_ULINEAR_BE) || + (output_enc == AUDIO_ENCODING_SLINEAR_BE && + input_enc == AUDIO_ENCODING_SLINEAR_LE) || + (output_enc == AUDIO_ENCODING_SLINEAR_LE && + input_enc == AUDIO_ENCODING_SLINEAR_BE)) + return convert_swap_endian; - if ((IS_BIG_ENDIAN && - ((output == AUDIO_ENCODING_ULINEAR_BE && - input == AUDIO_ENCODING_SLINEAR_LE) || - (output == AUDIO_ENCODING_SLINEAR_BE && - input == AUDIO_ENCODING_ULINEAR_LE))) || - (!IS_BIG_ENDIAN && - ((output == AUDIO_ENCODING_ULINEAR_LE && - input == AUDIO_ENCODING_SLINEAR_BE) || - (output == AUDIO_ENCODING_SLINEAR_LE && - input == AUDIO_ENCODING_ULINEAR_BE)))) - return convert_swap_sign_and_endian_to_native; - - if ((!IS_BIG_ENDIAN && - ((output == AUDIO_ENCODING_ULINEAR_BE && - input == AUDIO_ENCODING_SLINEAR_LE) || - (output == AUDIO_ENCODING_SLINEAR_BE && - input == AUDIO_ENCODING_ULINEAR_LE))) || - (IS_BIG_ENDIAN && - ((output == AUDIO_ENCODING_ULINEAR_LE && - input == AUDIO_ENCODING_SLINEAR_BE) || - (output == AUDIO_ENCODING_SLINEAR_LE && - input == AUDIO_ENCODING_ULINEAR_BE)))) - return convert_swap_sign_and_endian_to_alien; + if (output_precision == 16) { + if ((output_enc == AUDIO_ENCODING_ULINEAR_BE && + input_enc == AUDIO_ENCODING_SLINEAR_BE) || + (output_enc == AUDIO_ENCODING_ULINEAR_LE && + input_enc == AUDIO_ENCODING_SLINEAR_LE) || + (output_enc == AUDIO_ENCODING_SLINEAR_BE && + input_enc == AUDIO_ENCODING_ULINEAR_BE) || + (output_enc == AUDIO_ENCODING_SLINEAR_LE && + input_enc == AUDIO_ENCODING_ULINEAR_LE)) + return convert_swap_sign16; + } else if (output_precision == 8) { + if ((output_enc == AUDIO_ENCODING_ULINEAR_LE && + input_enc == AUDIO_ENCODING_ULINEAR_BE) || + (output_enc == AUDIO_ENCODING_SLINEAR_LE && + input_enc == AUDIO_ENCODING_ULINEAR_LE)) + return convert_swap_sign8; + } - if ((IS_BIG_ENDIAN && - ((output == AUDIO_ENCODING_PCM8 && - input == AUDIO_ENCODING_ULINEAR_BE) || - (output == AUDIO_ENCODING_SLINEAR && - input == AUDIO_ENCODING_SLINEAR_BE))) || - (!IS_BIG_ENDIAN && - ((output == AUDIO_ENCODING_PCM8 && - input == AUDIO_ENCODING_ULINEAR_LE) || - (output == AUDIO_ENCODING_SLINEAR && - input == AUDIO_ENCODING_SLINEAR_LE)))) - return convert_to_8_native_endian; + if ((IS_BIG_ENDIAN && + ((output_enc == AUDIO_ENCODING_ULINEAR_BE && + input_enc == AUDIO_ENCODING_SLINEAR_LE) || + (output_enc == AUDIO_ENCODING_SLINEAR_BE && + input_enc == AUDIO_ENCODING_ULINEAR_LE))) || + (!IS_BIG_ENDIAN && + ((output_enc == AUDIO_ENCODING_ULINEAR_LE && + input_enc == AUDIO_ENCODING_SLINEAR_BE) || + (output_enc == AUDIO_ENCODING_SLINEAR_LE && + input_enc == AUDIO_ENCODING_ULINEAR_BE)))) + return convert_swap_sign_and_endian_to_native; - if ((IS_BIG_ENDIAN && - ((output == AUDIO_ENCODING_PCM8 && - input == AUDIO_ENCODING_SLINEAR_BE) || - (output == AUDIO_ENCODING_SLINEAR && - input == AUDIO_ENCODING_ULINEAR_BE))) || - (!IS_BIG_ENDIAN && - ((output == AUDIO_ENCODING_PCM8 && - input == AUDIO_ENCODING_SLINEAR_LE) || - (output == AUDIO_ENCODING_SLINEAR && - input == AUDIO_ENCODING_ULINEAR_LE)))) - return convert_to_8_native_endian_swap_sign; + if ((!IS_BIG_ENDIAN && + ((output_enc == AUDIO_ENCODING_ULINEAR_BE && + input_enc == AUDIO_ENCODING_SLINEAR_LE) || + (output_enc == AUDIO_ENCODING_SLINEAR_BE && + input_enc == AUDIO_ENCODING_ULINEAR_LE))) || + (IS_BIG_ENDIAN && + ((output_enc == AUDIO_ENCODING_ULINEAR_LE && + input_enc == AUDIO_ENCODING_SLINEAR_BE) || + (output_enc == AUDIO_ENCODING_SLINEAR_LE && + input_enc == AUDIO_ENCODING_ULINEAR_BE)))) + return convert_swap_sign_and_endian_to_alien; - if ((!IS_BIG_ENDIAN && - ((output == AUDIO_ENCODING_PCM8 && - input == AUDIO_ENCODING_ULINEAR_BE) || - (output == AUDIO_ENCODING_SLINEAR && - input == AUDIO_ENCODING_SLINEAR_BE))) || - (IS_BIG_ENDIAN && - ((output == AUDIO_ENCODING_PCM8 && - input == AUDIO_ENCODING_ULINEAR_LE) || - (output == AUDIO_ENCODING_SLINEAR && - input == AUDIO_ENCODING_SLINEAR_LE)))) - return convert_to_8_alien_endian; + } else { + if (output_precision == 8 && input_precision == 16) { - if ((!IS_BIG_ENDIAN && - ((output == AUDIO_ENCODING_PCM8 && - input == AUDIO_ENCODING_SLINEAR_BE) || - (output == AUDIO_ENCODING_SLINEAR && - input == AUDIO_ENCODING_ULINEAR_BE))) || - (IS_BIG_ENDIAN && - ((output == AUDIO_ENCODING_PCM8 && - input == AUDIO_ENCODING_SLINEAR_LE) || - (output == AUDIO_ENCODING_SLINEAR && - input == AUDIO_ENCODING_ULINEAR_LE)))) - return convert_to_8_alien_endian_swap_sign; + if ((IS_BIG_ENDIAN && + ((output_enc == AUDIO_ENCODING_ULINEAR_BE && + input_enc == AUDIO_ENCODING_ULINEAR_BE) || + (output_enc == AUDIO_ENCODING_SLINEAR_BE && + input_enc == AUDIO_ENCODING_SLINEAR_BE))) || + (!IS_BIG_ENDIAN && + ((output_enc == AUDIO_ENCODING_ULINEAR_LE && + input_enc == AUDIO_ENCODING_ULINEAR_LE) || + (output_enc == AUDIO_ENCODING_SLINEAR_LE && + input_enc == AUDIO_ENCODING_SLINEAR_LE)))) + return convert_to_8_native_endian; - if ((output == AUDIO_ENCODING_PCM8 && - input == AUDIO_ENCODING_SLINEAR) || - (output == AUDIO_ENCODING_SLINEAR && - input == AUDIO_ENCODING_PCM8)) - return convert_swap_sign8; + if ((IS_BIG_ENDIAN && + ((output_enc == AUDIO_ENCODING_ULINEAR_BE && + input_enc == AUDIO_ENCODING_SLINEAR_BE) || + (output_enc == AUDIO_ENCODING_SLINEAR_BE && + input_enc == AUDIO_ENCODING_ULINEAR_BE))) || + (!IS_BIG_ENDIAN && + ((output_enc == AUDIO_ENCODING_ULINEAR_LE && + input_enc == AUDIO_ENCODING_SLINEAR_LE) || + (output_enc == AUDIO_ENCODING_SLINEAR_LE && + input_enc == AUDIO_ENCODING_ULINEAR_LE)))) + return convert_to_8_native_endian_swap_sign; - if ((IS_BIG_ENDIAN && - ((output == AUDIO_ENCODING_ULINEAR_BE && - input == AUDIO_ENCODING_PCM8) || - (output == AUDIO_ENCODING_SLINEAR_BE && - input == AUDIO_ENCODING_SLINEAR))) || - (!IS_BIG_ENDIAN && - ((output == AUDIO_ENCODING_ULINEAR_LE && - input == AUDIO_ENCODING_PCM8) || - (output == AUDIO_ENCODING_SLINEAR_LE && - input == AUDIO_ENCODING_SLINEAR)))) - return convert_to_16_native_endian; + if ((!IS_BIG_ENDIAN && + ((output_enc == AUDIO_ENCODING_ULINEAR_BE && + input_enc == AUDIO_ENCODING_ULINEAR_BE) || + (output_enc == AUDIO_ENCODING_SLINEAR_BE && + input_enc == AUDIO_ENCODING_SLINEAR_BE))) || + (IS_BIG_ENDIAN && + ((output_enc == AUDIO_ENCODING_ULINEAR_LE && + input_enc == AUDIO_ENCODING_ULINEAR_LE) || + (output_enc == AUDIO_ENCODING_SLINEAR_LE && + input_enc == AUDIO_ENCODING_SLINEAR_LE)))) + return convert_to_8_alien_endian; - if ((IS_BIG_ENDIAN && - ((output == AUDIO_ENCODING_ULINEAR_BE && - input == AUDIO_ENCODING_SLINEAR) || - (output == AUDIO_ENCODING_SLINEAR_BE && - input == AUDIO_ENCODING_PCM8))) || - (!IS_BIG_ENDIAN && - ((output == AUDIO_ENCODING_ULINEAR_LE && - input == AUDIO_ENCODING_SLINEAR) || - (output == AUDIO_ENCODING_SLINEAR_LE && - input == AUDIO_ENCODING_PCM8)))) - return convert_to_16_native_endian_swap_sign; + if ((!IS_BIG_ENDIAN && + ((output_enc == AUDIO_ENCODING_ULINEAR_LE && + input_enc == AUDIO_ENCODING_SLINEAR_BE) || + (output_enc == AUDIO_ENCODING_SLINEAR_LE && + input_enc == AUDIO_ENCODING_ULINEAR_BE))) || + (IS_BIG_ENDIAN && + ((output_enc == AUDIO_ENCODING_ULINEAR_BE && + input_enc == AUDIO_ENCODING_SLINEAR_LE) || + (output_enc == AUDIO_ENCODING_SLINEAR_BE && + input_enc == AUDIO_ENCODING_ULINEAR_LE)))) + return convert_to_8_alien_endian_swap_sign; - if ((!IS_BIG_ENDIAN && - ((output == AUDIO_ENCODING_ULINEAR_BE && - input == AUDIO_ENCODING_PCM8) || - (output == AUDIO_ENCODING_SLINEAR_BE && - input == AUDIO_ENCODING_SLINEAR))) || - (IS_BIG_ENDIAN && - ((output == AUDIO_ENCODING_ULINEAR_LE && - input == AUDIO_ENCODING_PCM8) || - (output == AUDIO_ENCODING_SLINEAR_LE && - input == AUDIO_ENCODING_SLINEAR)))) - return convert_to_16_alien_endian; + } else if (output_precision == 16 && input_precision == 8) { - if ((!IS_BIG_ENDIAN && - ((output == AUDIO_ENCODING_ULINEAR_BE && - input == AUDIO_ENCODING_SLINEAR) || - (output == AUDIO_ENCODING_SLINEAR_BE && - input == AUDIO_ENCODING_PCM8))) || - (IS_BIG_ENDIAN && - ((output == AUDIO_ENCODING_ULINEAR_LE && - input == AUDIO_ENCODING_SLINEAR) || - (output == AUDIO_ENCODING_SLINEAR_LE && - input == AUDIO_ENCODING_PCM8)))) - return convert_to_16_alien_endian_swap_sign; + if ((IS_BIG_ENDIAN && + ((output_enc == AUDIO_ENCODING_ULINEAR_BE && + input_enc == AUDIO_ENCODING_ULINEAR_BE) || + (output_enc == AUDIO_ENCODING_SLINEAR_BE && + input_enc == AUDIO_ENCODING_SLINEAR_BE))) || + (!IS_BIG_ENDIAN && + ((output_enc == AUDIO_ENCODING_ULINEAR_LE && + input_enc == AUDIO_ENCODING_ULINEAR_LE) || + (output_enc == AUDIO_ENCODING_SLINEAR_LE && + input_enc == AUDIO_ENCODING_SLINEAR_LE)))) + return convert_to_16_native_endian; + + if ((IS_BIG_ENDIAN && + ((output_enc == AUDIO_ENCODING_ULINEAR_BE && + input_enc == AUDIO_ENCODING_SLINEAR_BE) || + (output_enc == AUDIO_ENCODING_SLINEAR_BE && + input_enc == AUDIO_ENCODING_ULINEAR_BE))) || + (!IS_BIG_ENDIAN && + ((output_enc == AUDIO_ENCODING_ULINEAR_LE && + input_enc == AUDIO_ENCODING_SLINEAR_LE) || + (output_enc == AUDIO_ENCODING_SLINEAR_LE && + input_enc == AUDIO_ENCODING_ULINEAR_LE)))) + return convert_to_16_native_endian_swap_sign; + + if ((!IS_BIG_ENDIAN && + ((output_enc == AUDIO_ENCODING_ULINEAR_BE && + input_enc == AUDIO_ENCODING_ULINEAR_LE) || + (output_enc == AUDIO_ENCODING_SLINEAR_BE && + input_enc == AUDIO_ENCODING_SLINEAR_LE))) || + (IS_BIG_ENDIAN && + ((output_enc == AUDIO_ENCODING_ULINEAR_LE && + input_enc == AUDIO_ENCODING_ULINEAR_BE) || + (output_enc == AUDIO_ENCODING_SLINEAR_LE && + input_enc == AUDIO_ENCODING_SLINEAR_BE)))) + return convert_to_16_alien_endian; + + if ((!IS_BIG_ENDIAN && + ((output_enc == AUDIO_ENCODING_ULINEAR_BE && + input_enc == AUDIO_ENCODING_SLINEAR_LE) || + (output_enc == AUDIO_ENCODING_SLINEAR_BE && + input_enc == AUDIO_ENCODING_ULINEAR_LE))) || + (IS_BIG_ENDIAN && + ((output_enc == AUDIO_ENCODING_ULINEAR_LE && + input_enc == AUDIO_ENCODING_SLINEAR_BE) || + (output_enc == AUDIO_ENCODING_SLINEAR_LE && + input_enc == AUDIO_ENCODING_ULINEAR_BE)))) + return convert_to_16_alien_endian_swap_sign; + } + } return NULL; } $OpenBSD$ --- src/sun/sun.h.orig Mon Sep 18 03:14:20 2006 +++ src/sun/sun.h Sun Feb 3 00:07:19 2008 @@ -33,7 +33,7 @@ #include <string.h> #include <pthread.h> -#include "audioio.h" +#include <sys/audioio.h> #include "audacious/plugin.h" #include "audacious/configdb.h" @@ -63,9 +63,9 @@ #define SUN_DEFAULT_BLOCKSIZE 8800 #endif -/* Default `requested' buffer size */ +/* Default `requested' buffer size in milliseconds */ #ifndef SUN_DEFAULT_BUFFER_SIZE -#define SUN_DEFAULT_BUFFER_SIZE 8800 +#define SUN_DEFAULT_BUFFER_SIZE 500 #endif /* Minimum total buffer size */ @@ -82,10 +82,11 @@ struct sun_format { char name[16]; - union { + struct { AFormat xmms; gint sun; } format; + int precision; int frequency; int channels; int bps; @@ -149,7 +150,7 @@ gint sun_written_time(void); void sun_get_volume(int *, int *); void sun_set_volume(int, int); void *sun_get_convert_buffer(size_t); -int (*sun_get_convert_func(int, int))(void **, int); +int (*sun_get_convert_func(int, int, int, int))(void **, int); #ifdef WORDS_BIGENDIAN #define IS_BIG_ENDIAN TRUE
