On Sun, Mar 21, 2010 at 01:27:14PM +0000, Stuart Henderson wrote: > On 2010/03/21 10:03, Jacob Meuser wrote: > > On Sat, Dec 26, 2009 at 09:54:07AM +0000, Jacob Meuser wrote: > > > I have no way to test this, so testing would be much appreciated. > > > > does anyone use gmfsk? > > > > there may very well be change the audio(4) API/ABI this release cycle, > > so it'd be nice to convert the last few ports still using audio(4) > > to sndio(7) sooner than later. > > this breaks it. after the sndio conversion nothing works; no input > detected, and output also fails. > > to test: go through the basic setup - you need to choose your > audio device,
and the only choices it gives you do not even exist on OpenBSD. yes, you can type a usable name in, but this port never worked "out of the box". this version seems to work. basically, forgot sio_start(). figured I might as well cleared up the device choice issue too. now it does work "out of the box", at least for me it does. -- jake...@sdf.lonestar.org SDF Public Access UNIX System - http://sdf.lonestar.org Index: Makefile =================================================================== RCS file: /cvs/ports/comms/gmfsk/Makefile,v retrieving revision 1.18 diff -N -u -p Makefile --- Makefile 23 Jan 2010 10:29:45 -0000 1.18 +++ Makefile 18 Apr 2010 23:53:54 -0000 @@ -4,7 +4,7 @@ COMMENT= GNOME multimode HF terminal GNOME_PROJECT= gmfsk GNOME_VERSION= 0.6 -PKGNAME= ${DISTNAME}p14 +PKGNAME= ${DISTNAME}p15 CATEGORIES= comms hamradio HOMEPAGE= http://gmfsk.connect.fi/ @@ -24,8 +24,8 @@ WANTLIB += bonobo-2 bonobo-activation bonoboui-2 c cai WANTLIB += expat fontconfig freetype gio-2.0 glib-2.0 WANTLIB += glitz gmodule-2.0 gnome-2 gnome-keyring gnomecanvas-2 WANTLIB += gnomevfs-2 gobject-2.0 gthread-2.0 m pango-1.0 pangocairo-1.0 -WANTLIB += pangoft2-1.0 pixman-1 png popt pthread pthread-stubs stdc++ xcb -WANTLIB += xml2 z +WANTLIB += pangoft2-1.0 pixman-1 png popt pthread pthread-stubs sndio +WANTLIB += stdc++ xcb xcb-render xcb-render-util xml2 z MODULES= devel/gettext \ x11/gnome \ @@ -44,7 +44,8 @@ LIB_DEPENDS= fftw.>=2::math/fftw \ CONFIGURE_STYLE= gnu CONFIGURE_ARGS= --enable-hamlib CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include" \ - LDFLAGS="-L${LOCALBASE}/lib" + LDFLAGS="-L${LOCALBASE}/lib" \ + LIBS="-lsndio" USE_X11= Yes Index: patches/patch-gmfsk_glade =================================================================== RCS file: patches/patch-gmfsk_glade diff -N -u -p patches/patch-gmfsk_glade --- /dev/null 18 Apr 2010 17:53:54 -0000 +++ patches/patch-gmfsk_glade 18 Apr 2010 23:53:54 -0000 @@ -0,0 +1,71 @@ +$OpenBSD$ +--- gmfsk.glade.orig Sun Apr 18 16:35:25 2010 ++++ gmfsk.glade Sun Apr 18 16:37:56 2010 +@@ -5970,33 +5970,10 @@ New parametes take effect after restarting the modem.< + <widget class="GtkListItem" id="listitem42"> + <property name="visible">True</property> + <property name="can_focus">True</property> +- <property name="label" translatable="yes">/dev/dsp</property> ++ <property name="label" translatable="no">default</property> + </widget> + </child> + +- <child> +- <widget class="GtkListItem" id="listitem43"> +- <property name="visible">True</property> +- <property name="can_focus">True</property> +- <property name="label" translatable="yes">/dev/dsp0</property> +- </widget> +- </child> +- +- <child> +- <widget class="GtkListItem" id="listitem44"> +- <property name="visible">True</property> +- <property name="can_focus">True</property> +- <property name="label" translatable="yes">/dev/dsp1</property> +- </widget> +- </child> +- +- <child> +- <widget class="GtkListItem" id="listitem45"> +- <property name="visible">True</property> +- <property name="can_focus">True</property> +- <property name="label" translatable="yes">/dev/dsp2</property> +- </widget> +- </child> + </widget> + </child> + </widget> +@@ -8136,31 +8113,7 @@ This druid can be run again by starting gMFSK with the + <widget class="GtkListItem" id="listitem369"> + <property name="visible">True</property> + <property name="can_focus">True</property> +- <property name="label" translatable="yes">/dev/dsp</property> +- </widget> +- </child> +- +- <child> +- <widget class="GtkListItem" id="listitem370"> +- <property name="visible">True</property> +- <property name="can_focus">True</property> +- <property name="label" translatable="yes">/dev/dsp0</property> +- </widget> +- </child> +- +- <child> +- <widget class="GtkListItem" id="listitem371"> +- <property name="visible">True</property> +- <property name="can_focus">True</property> +- <property name="label" translatable="yes">/dev/dsp1</property> +- </widget> +- </child> +- +- <child> +- <widget class="GtkListItem" id="listitem372"> +- <property name="visible">True</property> +- <property name="can_focus">True</property> +- <property name="label" translatable="yes">/dev/dsp2</property> ++ <property name="label" translatable="no">default</property> + </widget> + </child> + </widget> Index: patches/patch-gmfsk_schemas =================================================================== RCS file: patches/patch-gmfsk_schemas diff -N -u -p patches/patch-gmfsk_schemas --- /dev/null 18 Apr 2010 17:53:54 -0000 +++ patches/patch-gmfsk_schemas 18 Apr 2010 23:53:54 -0000 @@ -0,0 +1,12 @@ +$OpenBSD$ +--- gmfsk.schemas.orig Sun Apr 18 16:38:33 2010 ++++ gmfsk.schemas Sun Apr 18 16:38:54 2010 +@@ -151,7 +151,7 @@ + <applyto>/apps/gmfsk/sound/dev</applyto> + <owner>gmfsk</owner> + <type>string</type> +- <default>/dev/dsp</default> ++ <default>default</default> + <locale name="C"> + <short>Sound device</short> + <long>Device used for sound input/output.</long> Index: patches/patch-src_conf_c =================================================================== RCS file: patches/patch-src_conf_c diff -N -u -p patches/patch-src_conf_c --- /dev/null 18 Apr 2010 17:53:54 -0000 +++ patches/patch-src_conf_c 18 Apr 2010 23:53:54 -0000 @@ -0,0 +1,12 @@ +$OpenBSD$ +--- src/conf.c.orig Sun Apr 18 16:43:00 2010 ++++ src/conf.c Sun Apr 18 16:43:16 2010 +@@ -127,7 +127,7 @@ static struct conf_default conf_defs[] = { + { "colors/rxwin", D_STRING, { .s = "white" } }, + { "fonts/txfont", D_STRING, { .s = "Sans 10" } }, + { "fonts/rxfont", D_STRING, { .s = "Sans 10" } }, +- { "sound/dev", D_STRING, { .s = "/dev/dsp" } }, ++ { "sound/dev", D_STRING, { .s = "default" } }, + { "ptt/dev", D_STRING, { .s = "none" } }, + { "misc/datefmt", D_STRING, { .s = "%d.%m.%Y" } }, + { "misc/timefmt", D_STRING, { .s = "%H:%M:%S %Z" } }, Index: patches/patch-src_interface_c =================================================================== RCS file: patches/patch-src_interface_c diff -N -u -p patches/patch-src_interface_c --- /dev/null 18 Apr 2010 17:53:54 -0000 +++ patches/patch-src_interface_c 18 Apr 2010 23:53:54 -0000 @@ -0,0 +1,27 @@ +$OpenBSD$ +--- src/interface.c.orig Tue Jul 6 01:35:46 2004 ++++ src/interface.c Sun Apr 18 16:42:26 2010 +@@ -3078,10 +3078,7 @@ create_confdialog (void) + (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + gtk_container_set_border_width (GTK_CONTAINER (soundcombo), 8); +- soundcombo_items = g_list_append (soundcombo_items, (gpointer) _("/dev/dsp")); +- soundcombo_items = g_list_append (soundcombo_items, (gpointer) _("/dev/dsp0")); +- soundcombo_items = g_list_append (soundcombo_items, (gpointer) _("/dev/dsp1")); +- soundcombo_items = g_list_append (soundcombo_items, (gpointer) _("/dev/dsp2")); ++ soundcombo_items = g_list_append (soundcombo_items, (gpointer) _("default")); + gtk_combo_set_popdown_strings (GTK_COMBO (soundcombo), soundcombo_items); + g_list_free (soundcombo_items); + +@@ -4236,10 +4233,7 @@ create_druidwindow (void) + gtk_widget_show (druid_soundcombo); + gtk_box_pack_start (GTK_BOX (hbox32), druid_soundcombo, TRUE, TRUE, 0); + gtk_container_set_border_width (GTK_CONTAINER (druid_soundcombo), 8); +- druid_soundcombo_items = g_list_append (druid_soundcombo_items, (gpointer) _("/dev/dsp")); +- druid_soundcombo_items = g_list_append (druid_soundcombo_items, (gpointer) _("/dev/dsp0")); +- druid_soundcombo_items = g_list_append (druid_soundcombo_items, (gpointer) _("/dev/dsp1")); +- druid_soundcombo_items = g_list_append (druid_soundcombo_items, (gpointer) _("/dev/dsp2")); ++ druid_soundcombo_items = g_list_append (druid_soundcombo_items, (gpointer) _("default")); + gtk_combo_set_popdown_strings (GTK_COMBO (druid_soundcombo), druid_soundcombo_items); + g_list_free (druid_soundcombo_items); + Index: patches/patch-src_snd_c =================================================================== RCS file: /cvs/ports/comms/gmfsk/patches/patch-src_snd_c,v retrieving revision 1.1.1.1 diff -N -u -p patches/patch-src_snd_c --- patches/patch-src_snd_c 28 May 2007 18:47:06 -0000 1.1.1.1 +++ patches/patch-src_snd_c 18 Apr 2010 23:53:54 -0000 @@ -1,41 +1,63 @@ $OpenBSD: patch-src_snd_c,v 1.1.1.1 2007/05/28 18:47:06 jason Exp $ ---- src/snd.c.orig Sat Apr 17 13:24:11 2004 -+++ src/snd.c Wed Nov 23 11:04:58 2005 -@@ -36,7 +36,12 @@ +--- src/snd.c.orig Sat Apr 17 10:24:11 2004 ++++ src/snd.c Sun Apr 18 16:52:21 2010 +@@ -36,8 +36,7 @@ #include <fcntl.h> #include <time.h> -#include <sys/soundcard.h> -+#ifdef __OpenBSD__ -+# include <sys/audioio.h> -+#else -+# include <sys/soundcard.h> -+#endif -+ - #include <sys/ioctl.h> +-#include <sys/ioctl.h> ++#include <sndio.h> #include "snd.h" -@@ -139,9 +144,11 @@ static gint opensnd(gint direction) - audio_buf_info info; + #include "misc.h" +@@ -55,6 +54,7 @@ + static snd_config_t config; + static snd_config_t newconfig; + ++static struct sio_hdl *hdl = NULL; + static gint snd_fd = -1; + static gint snd_dir = 0; + +@@ -133,18 +133,17 @@ static void dprintf(const char *fmt, ...) + + /* ---------------------------------------------------------------------- */ + +-static gint opensnd(gint direction) ++static struct sio_hdl * opensnd(gint direction) + { + #ifdef SND_DEBUG +- audio_buf_info info; gchar *str; #endif - guint sndparam, wanted; -+ audio_info_t ainfo; - gint fd; +- gint fd; ++ struct sio_hdl *h; ++ struct sio_par par, gpar; -+ AUDIO_INITINFO(&ainfo); -+ if (!config.device) { snderr("opensnd: device not set"); - return -1; -@@ -166,17 +173,11 @@ static gint opensnd(gint direction) +- return -1; ++ return NULL; + } + + #ifdef SND_DEBUG +@@ -165,18 +164,16 @@ static gint opensnd(gint direction) + dprintf("Opening %s for %s...\n", config.device, str); #endif - /* non-blocking open */ +- /* non-blocking open */ - if ((fd = open(config.device, direction | O_NONBLOCK)) < 0) { -+ if ((fd = open(config.device, direction)) < 0) { - snderr("opensnd: open: %s: %m", config.device); - return -1; +- snderr("opensnd: open: %s: %m", config.device); +- return -1; ++ if (!strncmp(config.device, "", 1) || ++ !strncmp(config.device, "default", 8)) ++ h = sio_open(NULL, direction, 0); ++ else ++ h = sio_open(config.device, direction, 0); ++ if (!h) { ++ snderr("opensnd: open: %s", config.device); ++ return NULL; } - /* make it block again - (SNDCTL_DSP_NONBLOCK ???) */ @@ -47,7 +69,7 @@ $OpenBSD: patch-src_snd_c,v 1.1.1.1 2007/05/28 18:47:0 #ifdef SND_DEBUG if (config.flags & SND_FLAG_8BIT) str = "8 bit unsigned"; -@@ -186,20 +187,15 @@ static gint opensnd(gint direction) +@@ -186,20 +183,15 @@ static gint opensnd(gint direction) dprintf("Setting sample format (%s)...\n", str); #endif @@ -55,19 +77,18 @@ $OpenBSD: patch-src_snd_c,v 1.1.1.1 2007/05/28 18:47:0 - wanted = AFMT_U8; /* 8 bit unsigned */ - else - wanted = AFMT_S16_NE; /* 16 bit signed, native byteorder */ -- ++ sio_initpar(&par); + - sndparam = wanted; - if (ioctl(fd, SNDCTL_DSP_SETFMT, &sndparam) < 0) { - snderr("opensnd: ioctl: SNDCTL_DSP_SETFMT: %m"); - goto error; + if (config.flags & SND_FLAG_8BIT) { -+ ainfo.record.encoding = ainfo.play.encoding = -+ AUDIO_ENCODING_ULINEAR; -+ ainfo.record.precision = ainfo.play.precision = 8; ++ par.bits = 8; ++ par.sig = 0; + } else { -+ ainfo.record.encoding = ainfo.play.encoding = -+ AUDIO_ENCODING_SLINEAR; -+ ainfo.record.precision = ainfo.play.precision = 16; ++ par.bits = 16; ++ par.sig = 1; } - if (sndparam != wanted) { - snderr("opensnd: Requested sample format not supported"); @@ -76,15 +97,15 @@ $OpenBSD: patch-src_snd_c,v 1.1.1.1 2007/05/28 18:47:0 #ifdef SND_DEBUG dprintf("Setting %s audio...\n", -@@ -207,61 +203,34 @@ static gint opensnd(gint direction) +@@ -207,85 +199,50 @@ static gint opensnd(gint direction) #endif if (config.flags & SND_FLAG_STEREO) - wanted = 1; /* stereo */ -+ ainfo.record.channels = ainfo.play.channels = 2; ++ par.pchan = par.rchan = 2; else - wanted = 0; /* mono */ -+ ainfo.record.channels = ainfo.play.channels = 1; ++ par.pchan = par.rchan = 1; - sndparam = wanted; - if (ioctl(fd, SNDCTL_DSP_STEREO, &sndparam) < 0) { @@ -112,77 +133,220 @@ $OpenBSD: patch-src_snd_c,v 1.1.1.1 2007/05/28 18:47:0 - config.samplerate); - } - config.samplerate = sndparam; -+ ainfo.record.sample_rate = ainfo.play.sample_rate = config.samplerate; ++ par.rate = config.samplerate; /* Request a buffer size of 512 samples */ - if (config.flags & SND_FLAG_8BIT) - sndparam = 0x00000009; - else - sndparam = 0x0000000A; -+ ainfo.blocksize = 512; -+ if ((config.flags & SND_FLAG_8BIT) == 0) -+ ainfo.blocksize *= 2; ++ par.round = 512; ++ par.appbufsz = par.round * 4; - if (config.flags & SND_FLAG_STEREO) +- if (config.flags & SND_FLAG_STEREO) - sndparam += 1; -+ ainfo.blocksize *= 2; - - /* Unlimited amount of buffers for RX, four for TX */ - if (direction == O_RDONLY) +- +- /* Unlimited amount of buffers for RX, four for TX */ +- if (direction == O_RDONLY) - sndparam |= 0x7FFF0000; -+ ainfo.hiwat = 65536; - else +- else - sndparam |= 0x00040000; -+ ainfo.hiwat = 4; - +- #ifdef SND_DEBUG - dprintf("Setting fragment size (param = 0x%08X)...\n", sndparam); +- dprintf("Setting fragment size (param = 0x%08X)...\n", sndparam); ++ dprintf("-- \n"); #endif - if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &sndparam) < 0) { - snderr("opensnd: ioctl: SNDCTL_DSP_SETFRAGMENT: %m"); -- goto error; ++ if (!sio_setpar(h, &par) || !sio_getpar(h, &gpar) || ++ gpar.bits != par.bits || gpar.sig != par.sig) { ++ snderr("sndopen: could not set parameters as desired"); + goto error; + } + + #ifdef SND_DEBUG +- if (direction == O_RDONLY) { +- if (ioctl(fd, SNDCTL_DSP_GETISPACE, &info) < 0) { +- dprintf("ioctl: SNDCTL_DSP_GETISPACE: %m"); +- } +- } else { +- if (ioctl(fd, SNDCTL_DSP_GETOSPACE, &info) < 0) { +- dprintf("ioctl: SNDCTL_DSP_GETOSPACE: %m"); +- } - } - - #ifdef SND_DEBUG - if (direction == O_RDONLY) { - if (ioctl(fd, SNDCTL_DSP_GETISPACE, &info) < 0) { -@@ -281,6 +250,27 @@ static gint opensnd(gint direction) - dprintf("-- \n"); +- dprintf("Audio buffer size: %d bytes, number of buffers: %d\n", +- info.fragsize, info.fragstotal); ++ dprintf("samplerate: %u / want %u\n", ++ gpar.rate, config.samplerate); ++ dprintf("channels: play %u / record %u / want %u\n", ++ gpar.pchan, gpar.rchan, ++ (config.flags & SND_FLAG_STEREO) ? 2 : 1); #endif -+ if (ioctl(fd, AUDIO_SETINFO, &ainfo) == -1) { -+ snderr("sndopen: setinfo failed: %m"); +-#ifdef SND_DEBUG +- dprintf("-- \n"); +-#endif ++ config.samplerate = gpar.rate; + +- return fd; ++ if (!sio_start(h)) { ++ snderr("sndopen: could not start sndio"); + goto error; + } -+ -+ if (ioctl(fd, AUDIO_GETINFO, &ainfo) == -1) { -+ snderr("sndopen: getinfo failed: %m"); -+ goto error; -+ } -+ -+#ifdef SND_DEBUG -+ printf("samplerate: play %u / record %u / want %u\n", -+ ainfo.play.sample_rate, ainfo.record.sample_rate, -+ config.samplerate); -+ printf("channels: play %u / record %u / want %u\n", -+ ainfo.play.channels, ainfo.record.channels, -+ (config.flags & SND_FLAG_STEREO) ? 2 : 1); -+#endif -+ -+ config.samplerate = ainfo.play.sample_rate; -+ - return fd; ++ return h; ++ error: -@@ -453,8 +443,8 @@ void sound_close(void) +- close(fd); +- return -1; ++ sio_close(h); ++ return NULL; + } - /* never close stdin/out/err */ - if (snd_fd > 2) { + /* ---------------------------------------------------------------------- */ +@@ -307,11 +264,9 @@ gint sound_open_for_write(gint rate) + if (config.flags & SND_FLAG_TESTMODE_MASK) + snd_fd = 1; + else if (!(config.flags & SND_FLAG_FULLDUP)) +- snd_fd = opensnd(O_WRONLY); +- else if (snd_fd < 0) +- snd_fd = opensnd(O_RDWR); ++ hdl = opensnd(SIO_PLAY); + +- if (snd_fd < 0) ++ if (hdl == NULL && snd_fd != 1) + return -1; + + snd_dir = O_WRONLY; +@@ -323,14 +278,14 @@ gint sound_open_for_write(gint rate) + src_delete(tx_src_state); + tx_src_state = NULL; + } +- return snd_fd; ++ return 0; + } + + ratio = real_rate / rate; + + if (tx_src_state && tx_src_data && tx_src_data->src_ratio == ratio) { + src_reset(tx_src_state); +- return snd_fd; ++ return 0; + } + + #if SND_DEBUG +@@ -354,7 +309,7 @@ gint sound_open_for_write(gint rate) + + tx_src_data->src_ratio = ratio; + +- return snd_fd; ++ return 0; + } + + gint sound_open_for_read(gint rate) +@@ -374,11 +329,9 @@ gint sound_open_for_read(gint rate) + if (config.flags & SND_FLAG_TESTMODE_MASK) + snd_fd = 0; + else if (!(config.flags & SND_FLAG_FULLDUP)) +- snd_fd = opensnd(O_RDONLY); +- else if (snd_fd < 0) +- snd_fd = opensnd(O_RDWR); ++ hdl = opensnd(SIO_REC); + +- if (snd_fd < 0) ++ if (hdl == NULL && snd_fd != 0) + return -1; + + snd_dir = O_RDONLY; +@@ -390,14 +343,14 @@ gint sound_open_for_read(gint rate) + src_delete(rx_src_state); + rx_src_state = NULL; + } +- return snd_fd; ++ return 0; + } + + ratio = rate / real_rate; + + if (rx_src_state && rx_src_data && rx_src_data->src_ratio == ratio) { + src_reset(rx_src_state); +- return snd_fd; ++ return 0; + } + + #if SND_DEBUG +@@ -421,7 +374,7 @@ gint sound_open_for_read(gint rate) + + rx_src_data->src_ratio = ratio; + +- return snd_fd; ++ return 0; + } + + void sound_close(void) +@@ -451,13 +404,7 @@ void sound_close(void) + } + #endif + +- /* never close stdin/out/err */ +- if (snd_fd > 2) { - if (ioctl(snd_fd, SNDCTL_DSP_SYNC, 0) < 0) - snderr("sound_close: ioctl: SNDCTL_DSP_SYNC: %m"); -+ if (ioctl(snd_fd, AUDIO_FLUSH, 0) < 0) -+ snderr("sound_close: ioctl: AUDIO_FLUSH: %m"); - close(snd_fd); - snd_fd = -1; +- close(snd_fd); +- snd_fd = -1; +- } ++ sio_close(hdl); + } + + char *sound_error(void) +@@ -477,8 +424,8 @@ gint sound_write(gfloat *buf, gint cnt) + if ((config.flags & SND_FLAG_TESTMODE_MASK) == SND_FLAG_TESTMODE_RX) + return cnt; + +- if (snd_fd < 0) { +- snderr("sound_write: fd < 0"); ++ if (hdl == NULL) { ++ snderr("sound_write: hdl == NULL"); + return -1; } + +@@ -539,7 +486,7 @@ static gint write_samples(gfloat *buf, gint count) + if (config.flags & SND_FLAG_STEREO) + count *= 2; + +- if ((i = write(snd_fd, p, count)) < 0) ++ if ((i = sio_write(hdl, p, count)) < 0) + snderr("write_samples: write: %m"); + + return i; +@@ -573,8 +520,8 @@ gint sound_read(gfloat **buffer, gint *count) + return 0; + } + +- if (snd_fd < 0) { +- snderr("sound_read: fd < 0"); ++ if (hdl == NULL) { ++ snderr("sound_read: hdl == NULL"); + return -1; + } + +@@ -625,7 +572,7 @@ static gint read_samples(gfloat *buf, gint count) + if (config.flags & SND_FLAG_8BIT) { + count *= sizeof(guint8); + +- if ((len = read(snd_fd, snd_b_buffer, count)) < 0) ++ if ((len = sio_read(hdl, snd_b_buffer, count)) < 0) + goto error; + + len /= sizeof(guint8); +@@ -641,7 +588,7 @@ static gint read_samples(gfloat *buf, gint count) + } else { + count *= sizeof(gint16); + +- if ((len = read(snd_fd, snd_w_buffer, count)) < 0) ++ if ((len = sio_read(hdl, snd_w_buffer, count)) < 0) + goto error; + + len /= sizeof(gint16);