Yet another forgotten audio program. The below is a diff adds the sndio bits, for xcdroast to build and to play tracks from the GUI.
OK? Index: Makefile =================================================================== RCS file: /cvs/ports/misc/xcdroast/Makefile,v retrieving revision 1.35 diff -u -p -u -p -r1.35 Makefile --- Makefile 11 Oct 2013 23:50:14 -0000 1.35 +++ Makefile 26 Jun 2015 17:57:08 -0000 @@ -3,7 +3,7 @@ COMMENT= gtk-based frontend to cdrtools DISTNAME= xcdroast-0.98alpha16 PKGNAME= ${DISTNAME:L:S/alpha/a/} -REVISION= 4 +REVISION= 5 CATEGORIES= misc x11 MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=xcdroast/} Index: patches/patch-configure =================================================================== RCS file: patches/patch-configure diff -N patches/patch-configure --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-configure 26 Jun 2015 17:57:08 -0000 @@ -0,0 +1,13 @@ +$OpenBSD$ +--- configure.orig Fri Jun 26 19:08:19 2015 ++++ configure Fri Jun 26 19:08:49 2015 +@@ -2833,6 +2833,9 @@ case "$host" in + *-*-irix*) + AUDIO_LIBS="-laudio" + ;; ++*-*-openbsd*) ++ AUDIO_LIBS="-lsndio" ++ ;; + esac + + Index: patches/patch-src_io_c =================================================================== RCS file: patches/patch-src_io_c diff -N patches/patch-src_io_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_io_c 26 Jun 2015 17:57:08 -0000 @@ -0,0 +1,81 @@ +$OpenBSD$ +--- src/io.c.orig Thu Aug 21 15:11:40 2008 ++++ src/io.c Fri Jun 26 19:48:45 2015 +@@ -28,7 +28,10 @@ + # include <sys/soundcard.h> + # include <sys/ioctl.h> + #endif +-#if defined(sun) || defined(__OpenBSD__) ++#if defined(__OpenBSD__) ++# include <sndio.h> ++#endif ++#if defined(sun) + # include <sys/ioctl.h> + # include <sys/audioio.h> + #endif +@@ -1708,7 +1711,7 @@ GList *loop; + struct stat buf; + #endif + +-#if defined(sun) || defined(aix) || defined(__OpenBSD__) ++#if defined(sun) || defined(aix) + gchar *audiodev; + #endif + dsp = NULL; +@@ -1723,7 +1726,10 @@ gchar *audiodev; + dsp = g_list_append(dsp,"/dev/dsp1"); + } + #endif +-#if defined(sun) || defined(__OpenBSD__) ++#if defined(__OpenBSD__) ++ dsp = g_list_append(dsp, SIO_DEVANY); ++#endif ++#if defined(sun) + /* check if the user has any special audio-hardware running, + which set the AUDIODEV-environment-variable */ + audiodev = getenv("AUDIODEV"); +@@ -1850,7 +1856,7 @@ gchar tmp2[MAXLINE]; + } + } + #endif +-#if defined(sun) || defined(__OpenBSD__) ++#if defined(sun) + + g_snprintf(tmp,MAXLINE,"%s%s",dsp,"ctl"); + +@@ -3601,7 +3607,7 @@ gint mix; + #if defined(linux) || defined(__FreeBSD__) + gint val; + #endif +-#if defined(sun) || defined(__OpenBSD__) ++#if defined(sun) + audio_info_t ainfo; + #endif + #ifdef hpux +@@ -3636,7 +3642,7 @@ struct audio_gain again; + return ((val & 0x7f) + ((val >> 8) & 0x7f))/2; + + #endif +-#if defined(sun) || defined(__OpenBSD__) ++#if defined(sun) + + dodebug(10,"quering mixer %s\n", setupdata.mix_device); + mix = open(setupdata.mix_device, O_RDONLY); +@@ -3724,7 +3730,7 @@ gint set_mixer(gint val) { + #if !(defined(__MACH__) && defined(__APPLE__)) + gint mix; + #endif +-#if defined(sun) || defined(__OpenBSD__) ++#if defined(sun) + audio_info_t ainfo; + #endif + #ifdef aix +@@ -3760,7 +3766,7 @@ struct audio_gain again; + close(mix); + + #endif +-#if defined(sun) || defined(__OpenBSD__) ++#if defined(sun) + + dodebug(10,"setting mixer %s to %d\n", setupdata.mix_device, val); + mix = open(setupdata.mix_device, O_WRONLY); Index: patches/patch-src_wavplay_c =================================================================== RCS file: patches/patch-src_wavplay_c diff -N patches/patch-src_wavplay_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_wavplay_c 26 Jun 2015 17:57:08 -0000 @@ -0,0 +1,128 @@ +$OpenBSD$ +--- src/wavplay.c.orig Wed Aug 20 17:34:02 2008 ++++ src/wavplay.c Fri Jun 26 19:47:07 2015 +@@ -31,7 +31,10 @@ + # include <sys/soundcard.h> + # include <sys/ioctl.h> + #endif +-#if defined(sun) || defined(__OpenBSD__) ++#if defined(__OpenBSD__) ++# include <sndio.h> ++#endif ++#if defined(sun) + # include <sys/ioctl.h> + # include <sys/audioio.h> + #endif +@@ -74,6 +77,8 @@ off_t is_std_wav_file(int f, off_t *offset); + + #if defined(linux) || defined(__FreeBSD__) + #define DEFAULT_AUDIO_DEVICE "/dev/dsp" ++#elif defined(__OpenBSD__) ++#define DEFAULT_AUDIO_DEVICE SIO_DEVANY + #elif defined (aix) + #define DEFAULT_AUDIO_DEVICE "" + #elif defined(__sgi) +@@ -360,8 +365,50 @@ gint flags; + + #endif + +-#if defined(sun) || defined(__OpenBSD__) ++#if defined(__OpenBSD__) + ++static struct sio_hdl *audio_hdl = NULL; ++ ++/* open the sound-device of sndio and set cd-quality */ ++gint open_sndio_audio(gchar *dev) { ++ struct sio_par par; ++ ++ /* First try open with O_NONBLOCK so it doesn't hang */ ++ if ((audio_hdl = sio_open(dev, SIO_PLAY, 0)) == NULL) { ++ g_warning("Unable to open audio device\n"); ++ return -1; ++ } ++ sio_initpar(&par); ++ par.rate = 44100; ++ par.pchan = 2; ++ par.bits = 16; ++ par.le = SIO_LE_NATIVE; ++ par.appbufsz = DEFAULT_BUFFER_SIZE; ++ ++ if (!sio_setpar(audio_hdl, &par) || !sio_getpar(audio_hdl, &par)) { ++ g_warning("Unable to set audio parameters\n"); ++ goto bad; ++ } ++ if (par.rate != 44100 || par.pchan != 2 || par.bits != 16 || ++ par.le != SIO_LE_NATIVE) { ++ g_warning("Unsupported audio parameters\n"); ++ goto bad; ++ } ++ if (!sio_start(audio_hdl)) { ++ g_warning("Couldn't start audio\n"); ++ goto bad; ++ } ++ abuf_size = par.appbufsz; ++ return 0; ++bad: ++ sio_close(audio_hdl); ++ audio_hdl = NULL; ++ return -1; ++} ++#endif ++ ++#if defined(sun) ++ + /* open the sound-device of solaris and set cd-quality */ + + gint open_solaris_audio(gchar *dev) { +@@ -387,9 +434,7 @@ gint flags; + info.play.precision = 16; + info.play.encoding = AUDIO_ENCODING_LINEAR; + info.play.buffer_size = abuf_size; +-#ifndef __OpenBSD__ + info.output_muted = 0; +-#endif + + if (ioctl(audio, AUDIO_SETINFO, &info) == -1) { + g_warning("Unable to set audio parameters\n"); +@@ -790,7 +835,10 @@ gchar keybuffer[MAXLINE]; + #if defined(linux) || defined(__FreeBSD__) + audio = open_linux_audio(audio_dev); + #endif +-#if defined(sun) || defined(__OpenBSD__) ++#if defined(__OpenBSD__) ++ audio = open_sndio_audio(audio_dev); ++#endif ++#if defined(sun) + audio = open_solaris_audio(audio_dev); + #endif + #ifdef aix +@@ -820,7 +868,7 @@ gchar keybuffer[MAXLINE]; + fd = open (wavname, O_RDONLY, 0); + + if (fd == -1) { +-#if !(defined(__MACH__) && defined(__APPLE__)) ++#if !(defined(__MACH__) && defined(__APPLE__)) && !defined(__OpenBSD__) + close(audio); + #endif + g_warning("Can't open wav-file\n"); +@@ -934,6 +982,11 @@ gchar keybuffer[MAXLINE]; + + #if (defined(__MACH__) && defined(__APPLE__)) + audio_write(audiobuf,l); ++#elif defined(__OpenBSD__) ++ if (sio_write(audio_hdl, audiobuf, l) != l) { ++ g_print("write error to audio-device\n"); ++ exit(-1); ++ } + #elif defined(__sgi) + write_irix_audio(audiobuf, l); + #else +@@ -975,6 +1028,8 @@ gchar keybuffer[MAXLINE]; + + #if (defined(__MACH__) && defined(__APPLE__)) + audio_close(); ++#elif defined(__OpenBSD__) ++ sio_close(audio_hdl); + #elif defined(__sgi) + close_irix_audio(); + #else