On Fri, Jun 26, 2015 at 10:55:49AM +0200, Alexandre Ratchov wrote:
> the kernel API change borke brltty. Programs are supposed to use
> libsndio, but obviously we missed this one.
> 
> Here's the sndio code for brltty (tested by copy-pasting the code
> in a standalone program). Now I just figured out audio is not used
> on openbsd :(
> 
> So what do we do? commit this? disable audio?


sorry, I sent the wrong diff, here's the right diff:

Index: Makefile
===================================================================
RCS file: /cvs/ports/misc/brltty/Makefile,v
retrieving revision 1.12
diff -u -p -u -p -r1.12 Makefile
--- Makefile    11 Mar 2013 11:23:56 -0000      1.12
+++ Makefile    26 Jun 2015 09:02:27 -0000
@@ -4,6 +4,7 @@ COMMENT=        access software for a blind per
 
 SHARED_ONLY=   Yes
 DISTNAME=      brltty-3.6
+REVISION=      0
 CATEGORIES=    misc
 HOMEPAGE=      http://mielke.cc/brltty
 MASTER_SITES=  ${HOMEPAGE}/releases/
@@ -25,6 +26,9 @@ MODGNU_CONFIG_GUESS_DIRS=${WRKSRC}/aux
 USE_GROFF =    Yes
 NO_TEST=       Yes
 SEPARATE_BUILD=        Yes
+
+post-extract:
+       @cp ${FILESDIR}/sys_pcm_sndio.h  ${WRKSRC}/Programs
 
 post-install:
        rm -f ${PREFIX}/bin/brltty-install
Index: files/sys_pcm_sndio.h
===================================================================
RCS file: files/sys_pcm_sndio.h
diff -N files/sys_pcm_sndio.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ files/sys_pcm_sndio.h       26 Jun 2015 09:02:27 -0000
@@ -0,0 +1,136 @@
+/*
+ * BRLTTY - A background process providing access to the Linux console (when in
+ *          text mode) for a blind person using a refreshable braille display.
+ *
+ * Copyright (C) 1995-2004 by The BRLTTY Team. All rights reserved.
+ *
+ * BRLTTY comes with ABSOLUTELY NO WARRANTY.
+ *
+ * This is free software, placed under the terms of the
+ * GNU General Public License, as published by the Free Software
+ * Foundation.  Please see the file COPYING for details.
+ *
+ * Web Page: http://mielke.cc/brltty/
+ *
+ * This software is maintained by Dave Mielke <[email protected]>.
+ */
+
+#include "iomisc.h"
+#include <sndio.h>
+
+struct PcmDeviceStruct {
+  struct sio_hdl *hdl;
+  struct sio_par par;
+};
+
+PcmDevice *
+openPcmDevice (int errorLevel, const char *device) {
+  PcmDevice *pcm;
+
+  if (!device)
+    device = SIO_DEVANY;
+  pcm = malloc(sizeof(*pcm));
+  if (pcm == NULL) {
+    LogError("PCM device allocation");
+    return NULL;
+  }
+  pcm->hdl = sio_open(device, SIO_PLAY, 0);
+  if (pcm->hdl == NULL) {
+      LogPrint(errorLevel, "Cannot open PCM device: %s", device);
+      goto bad_free;
+  }
+  sio_initpar(&pcm->par);
+  pcm->par.bits = 16;
+  pcm->par.le = SIO_LE_NATIVE;
+  pcm->par.pchan = 1;
+  pcm->par.rate = 16000;
+  pcm->par.sig = 1;
+  if (!sio_setpar(pcm->hdl, &pcm->par) || !sio_getpar(pcm->hdl, &pcm->par)) {
+    LogPrint(errorLevel, "Cannot set PCM device parameters");
+    goto bad_free;
+  }
+  if (pcm->par.bits != 16 || pcm->par.le != SIO_LE_NATIVE ||
+      pcm->par.pchan != 1 || pcm->par.rate != 16000) {
+    LogPrint(errorLevel, "Unsupported PCM device parameters");
+    goto bad_free;
+  }
+  if (!sio_start(pcm->hdl)) {
+    LogPrint(errorLevel, "Cannot start PCM device");
+    goto bad_free;
+  }
+  return pcm;
+bad_free:
+  free(pcm);
+  return NULL;
+}
+
+void
+closePcmDevice (PcmDevice *pcm) {
+  sio_close(pcm->hdl);
+  free(pcm);
+}
+
+int
+writePcmData (PcmDevice *pcm, const unsigned char *buffer, int count) {
+  return sio_write(pcm->hdl, buffer, count);
+}
+
+int
+getPcmBlockSize (PcmDevice *pcm) {
+  return pcm->par.appbufsz;
+}
+
+int
+getPcmSampleRate (PcmDevice *pcm) {
+  return pcm->par.rate;
+}
+
+int
+setPcmSampleRate (PcmDevice *pcm, int rate) {
+  return getPcmSampleRate(pcm);
+}
+
+int
+getPcmChannelCount (PcmDevice *pcm) {
+  return pcm->par.pchan;
+}
+
+int
+setPcmChannelCount (PcmDevice *pcm, int channels) {
+  return getPcmChannelCount(pcm);
+}
+
+PcmAmplitudeFormat
+getPcmAmplitudeFormat (PcmDevice *pcm) {
+  switch (pcm->par.bits) {
+  case 8:
+    return (pcm->par.sig) ? PCM_FMT_S8 : PCM_FMT_U8;
+    break;
+  case 16:
+    if (pcm->par.le) {
+      return (pcm->par.sig) ? PCM_FMT_S16L : PCM_FMT_U16L;
+    } else {
+      return (pcm->par.sig) ? PCM_FMT_S16B : PCM_FMT_U16B;
+    }
+    break;
+  default:
+    return PCM_FMT_UNKNOWN;
+  }
+}
+
+PcmAmplitudeFormat
+setPcmAmplitudeFormat (PcmDevice *pcm, PcmAmplitudeFormat format) {
+  return getPcmAmplitudeFormat(pcm);
+}
+
+void
+forcePcmOutput (PcmDevice *pcm) {
+}
+
+void
+awaitPcmOutput (PcmDevice *pcm) {
+}
+
+void
+cancelPcmOutput (PcmDevice *pcm) {
+}
Index: patches/patch-Programs_sys_openbsd_c
===================================================================
RCS file: patches/patch-Programs_sys_openbsd_c
diff -N patches/patch-Programs_sys_openbsd_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-Programs_sys_openbsd_c        26 Jun 2015 09:02:27 -0000
@@ -0,0 +1,12 @@
+$OpenBSD$
+--- Programs/sys_openbsd.c.orig        Fri Jun 26 09:29:06 2015
++++ Programs/sys_openbsd.c     Fri Jun 26 09:29:40 2015
+@@ -40,7 +40,7 @@
+ 
+ #ifdef ENABLE_PCM_SUPPORT
+ #define PCM_AUDIO_DEVICE_PATH "/dev/audio"
+-#include "sys_pcm_audio.h"
++#include "sys_pcm_sndio.h"
+ #endif /* ENABLE_PCM_SUPPORT */
+ 
+ #ifdef ENABLE_MIDI_SUPPORT
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 09:02:27 -0000
@@ -0,0 +1,11 @@
+$OpenBSD$
+--- configure.orig     Fri Jun 26 09:59:26 2015
++++ configure  Fri Jun 26 09:59:40 2015
+@@ -7790,6 +7790,7 @@ _ACEOF
+       ;;
+    openbsd*)
+       system_object="openbsd"
++      LIBS="-lsndio ${LIBS}"
+       ;;
+    freebsd*)
+       system_object="freebsd"

Reply via email to