this was sent to MAINTAINER > 6 months ago.  no response other than
to say he was busy and was hoped to get to it eventually.  iirc it's
been tested by canacar@ (tho maybe that was 1.7, which is now building
on my machine), who had requested it.

-- 
[email protected]
SDF Public Access UNIX System - http://sdf.lonestar.org

Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/jdk/1.6/Makefile,v
retrieving revision 1.15
diff -u -p -r1.15 Makefile
--- Makefile    5 Feb 2010 13:10:31 -0000       1.15
+++ Makefile    1 Jul 2010 09:41:37 -0000
@@ -7,8 +7,8 @@ COMMENT-main=           Java2(TM) Standard Editio
 COMMENT-jre=           Java2(TM) Standard Edition Runtime Environment v${V}
 V=                     1.6.0.03
 PKGNAME=               jdk-${V}
-PKGNAME-main=          jdk-${V}p9
-PKGNAME-jre=           jre-${V}p9
+PKGNAME-main=          jdk-${V}p10
+PKGNAME-jre=           jre-${V}p10
 
 CATEGORIES=            devel/jdk java
 
@@ -48,7 +48,7 @@ BUILD_DEPENDS=                ::archivers/gtar \
                        ::x11/openmotif
 MODULES=               converters/libiconv
 WANTLIB=               X11 Xext Xi Xtst c m ossaudio pthread pthread-stubs \
-                       stdc++ xcb z
+                       sndio stdc++ xcb z
 
 USE_X11=               Yes
 USE_GMAKE=             Yes
@@ -156,6 +156,7 @@ post-extract:
                mkdir deploy/src/plugin/share/plugin && \
                mv share/plugin/mozilla_headers_18 
deploy/src/plugin/share/plugin
        @cp -f ${FILESDIR}/cacerts ${WRKDIR}/j2se/src/share/lib/security
+       @cp ${FILESDIR}/PLATFORM_API_BSDOS_PCM.c 
${WRKDIR}/j2se/src/solaris/native/com/sun/media/sound/engine
        @rm -rf ${WRKDIR}/tmp ${WRKDIR}/share
 
 pre-patch:
Index: files/PLATFORM_API_BSDOS_PCM.c
===================================================================
RCS file: files/PLATFORM_API_BSDOS_PCM.c
diff -N files/PLATFORM_API_BSDOS_PCM.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ files/PLATFORM_API_BSDOS_PCM.c      1 Jul 2010 09:41:37 -0000
@@ -0,0 +1,482 @@
+/*
+ * Copyright (c) 2009 Jacob Meuser <[email protected]>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+
+/* sndio backend for DirectAudio */
+
+#include <stdlib.h>
+#include <poll.h>
+#include <sndio.h>
+
+#include "DirectAudio.h"
+
+#if USE_DAUDIO == TRUE
+
+struct sndio_data {
+       struct sio_hdl *hdl;
+       struct sio_par par;
+       int mode;
+       long long realpos;
+       long long softpos;
+};
+
+static void
+sndio_movecb(void *arg, int delta)
+{
+       struct sndio_data *d = arg;
+       d->realpos += delta;
+}
+
+static int
+sndio_check_handle(struct sndio_data *d, int isSource)
+{
+       if (!d || !d->hdl ||
+           (isSource ? d->mode != SIO_PLAY : d->mode != SIO_REC))
+               return 0;
+
+       return 1;
+}
+
+INT32
+DAUDIO_GetDirectAudioDeviceCount()
+{
+       /* keep it simple for now */
+       return 1;
+}
+
+INT32
+DAUDIO_GetDirectAudioDeviceDescription(INT32 mixerIndex,
+    DirectAudioDeviceDescription* description)
+{
+       if (mixerIndex != 0) {
+               printf("invalid sndio mixerIndex\n");
+               return FALSE;
+       }
+
+       /* one device for now */
+       description->deviceID = 0;
+
+       /* number of simultaneous connections: 1 for hardware, -1 (inf)
+        * for aucat.  no way to know the difference.
+        */
+       description->maxSimulLines = -1;
+
+       strlcpy(description->name, "sndio device", DAUDIO_STRING_LENGTH);
+       strlcpy(description->vendor, "OpenBSD", DAUDIO_STRING_LENGTH);
+       strlcpy(description->version, "1", DAUDIO_STRING_LENGTH);
+       strlcpy(description->description, "OpenBSD Audio", 
DAUDIO_STRING_LENGTH);
+
+       return TRUE;
+}
+
+void
+DAUDIO_GetFormats(INT32 mixerIndex, INT32 deviceID, int isSource,
+    void* creator)
+{
+       struct sio_hdl *hdl;
+       struct sio_cap cap;
+       int i, j, k;
+       unsigned int n;
+
+       hdl = sio_open(NULL, isSource ? SIO_PLAY : SIO_REC, 0);
+       if (hdl == NULL) {
+               printf("could not get sndio handle to probe formats");
+               return;
+       }
+
+       if (!sio_getcap(hdl, &cap)) {
+               printf("sio_getcap failed\n");
+               return;
+       }
+
+       for (n = 0; n < cap.nconf; n++) {
+           for (i = 0; i < SIO_NENC; i++) {
+               if (cap.confs[n].enc & (1 << i)) {
+                   for (j = 0; j < SIO_NCHAN; j++) {
+                       if ((isSource ?
+                         cap.confs[n].pchan : cap.confs[n].rchan) & (1 << j)) {
+                           for (k = 0; k < SIO_NRATE; k++) {
+                               if (cap.confs[n].rate & (1 << k)) {
+                                   DAUDIO_AddAudioFormat(creator,
+                                     cap.enc[i].bits,
+                                     0, /* cap.enc[i].bps * (isSource ? 
cap.pchan[j] : cap.rchan[j]) */
+                                     (isSource ? cap.pchan[j] : cap.rchan[j]),
+                                     cap.rate[k],
+                                     DAUDIO_PCM,
+                                     cap.enc[i].sig,
+                                     !cap.enc[i].le);
+                               }
+                           }
+                       }
+                   }
+               }
+           }
+       }
+
+       sio_close(hdl);
+}
+
+void*
+DAUDIO_Open(INT32 mixerIndex, INT32 deviceID, int isSource, int encoding,
+    float sampleRate, int sampleSizeInBits, int frameSize, int channels, 
+    int isSigned, int isBigEndian, int bufferSizeInBytes)
+{
+       struct sndio_data *d;
+       struct sio_par gpar;
+
+       if (encoding != DAUDIO_PCM) {
+               printf("invalid encoding for sndio\n");
+               return NULL;
+       }
+
+       if (mixerIndex != 0 || deviceID != 0) {
+               printf("invalid device for sndio\n");
+               return NULL;
+       }
+
+       d = malloc(sizeof(struct sndio_data));
+       if (d == NULL) {
+               printf("could not alloc sndio_data structure\n");
+               return NULL;
+       }
+
+       d->mode = isSource ? SIO_PLAY : SIO_REC;
+
+       d->hdl = NULL;
+       d->hdl = sio_open(NULL, d->mode, 0);
+       if (d->hdl == NULL) {
+               printf("could not open sndio device\n");
+               goto bad;
+       }
+
+       sio_initpar(&d->par);
+       if (d->mode == SIO_PLAY)
+               d->par.pchan = channels;
+       else
+               d->par.rchan = channels;
+       d->par.rate = sampleRate;
+       d->par.bits = sampleSizeInBits;
+       d->par.sig = isSigned;
+       d->par.le = !isBigEndian;
+       d->par.appbufsz = bufferSizeInBytes / SIO_BPS(d->par.bits) /
+           ((d->mode == SIO_PLAY) ? d->par.pchan : d->par.rchan);
+
+       if (!sio_setpar(d->hdl, &d->par)) {
+               printf("could not set sndio params\n");
+               goto bad;
+       }
+       if (!sio_getpar(d->hdl, &gpar)) {
+               printf("could not get sndio params\n");
+               goto bad;
+       }
+
+       if (d->par.rate != gpar.rate ||
+           d->par.bits != gpar.bits ||
+           d->par.sig != gpar.sig ||
+           d->par.le != gpar.le ||
+           ((d->mode == SIO_PLAY) ?
+             d->par.pchan != gpar.pchan : d->par.rchan != gpar.rchan)) {
+               printf("could not set sndio params as desired\n");
+               goto bad;
+       }
+       d->par.appbufsz = gpar.appbufsz;
+
+       d->realpos = d->softpos = 0;
+       sio_onmove(d->hdl, sndio_movecb, d);
+
+       return (void *)d;
+bad:
+       if (d) {
+               if (d->hdl)
+                       sio_close(d->hdl);
+               free(d);
+       }
+       return NULL;
+}
+
+int
+DAUDIO_Start(void *id, int isSource)
+{
+       struct sndio_data *d = id;
+
+       if (!sndio_check_handle(d, isSource)) {
+               printf("sndio handle error: DAUDIO_Start\n");
+               return FALSE;
+       }
+
+       if (!sio_start(d->hdl)) {
+               printf("could not start sndio\n");
+               return FALSE;
+       }
+
+       return TRUE;
+}
+
+int
+DAUDIO_Stop(void *id, int isSource)
+{
+       struct sndio_data *d = id;
+
+       if (!sndio_check_handle(d, isSource)) {
+               printf("sndio handle error: DAUDIO_Stop\n");
+               return FALSE;
+       }
+
+       if (!sio_stop(d->hdl)) {
+               printf("could not stop sndio\n");
+               return FALSE;
+       }
+
+       return TRUE;
+}
+
+void
+DAUDIO_Close(void *id, int isSource)
+{
+       struct sndio_data *d = id;
+
+       if (!sndio_check_handle(d, isSource)) {
+               printf("sndio handle error: DAUDIO_Close\n");
+               return;
+       }
+
+       sio_close(d->hdl);
+       free(d);
+       d = NULL;
+}
+
+int
+DAUDIO_Write(void *id, char* data, int byteSize)
+{
+       struct sndio_data *d = id;
+       int ret, done;
+
+       if (!sndio_check_handle(d, 1)) {
+               printf("sndio handle error: DAUDIO_Write\n");
+               return -1;
+       }
+
+       done = 0;
+       while (byteSize > 0) {
+               ret = sio_write(d->hdl, data + done, byteSize);
+               if (ret == 0) {
+                       printf("sndio write error\n");
+                       return -1;
+               }
+               done += ret;
+               byteSize -= ret;
+       }
+       d->softpos += done / (d->par.bps * d->par.pchan);
+
+       return done;
+}
+
+int
+DAUDIO_Read(void *id, char* data, int byteSize)
+{
+       struct sndio_data *d = id;
+       int ret, done;
+
+       if (!sndio_check_handle(d, 0)) {
+               printf("sndio handle error: DAUDIO_Read\n");
+               return -1;
+       }
+
+       done = 0;
+       while (byteSize > 0) {
+               ret = sio_read(d->hdl, data + done, byteSize);
+               if (ret == 0) {
+                       printf("sndio read error\n");
+                       return -1;
+               }
+               done += ret;
+               byteSize -= ret;
+       }
+       d->softpos += done / (d->par.bps * d->par.rchan);
+
+       return done;
+}
+
+int
+DAUDIO_GetBufferSize(void *id, int isSource)
+{
+       struct sndio_data *d = id;
+
+       if (!sndio_check_handle(d, isSource)) {
+               printf("sndio handle error: DAUDIO_GetBufferSize\n");
+               return 0;
+       }
+
+       return (d->par.appbufsz * d->par.bps *
+           ((d->mode == SIO_PLAY) ? d->par.pchan : d->par.rchan));
+}
+
+int
+DAUDIO_StillDraining(void *id, int isSource)
+{
+       struct sndio_data *d = id;
+       struct pollfd pfd;
+       nfds_t nfds;
+
+       if (!sndio_check_handle(d, isSource)) {
+               printf("sndio handle error: DAUDIO_StillDraining\n");
+               return FALSE;
+       }
+
+       /* make sure counters are up-to-date */
+       nfds = sio_pollfd(d->hdl, &pfd,
+           (d->mode == SIO_PLAY) ? POLLOUT : POLLIN);
+       poll(&pfd, nfds, 0);
+       sio_revents(d->hdl, &pfd);
+
+       if (d->mode == SIO_PLAY) {
+               if (d->softpos - d->realpos > 0)
+                       return TRUE;
+               else
+                       return FALSE;
+       } else {
+               /* what does it mean to drain recording? */
+#if 0
+               if (d->realpos - d->softpos > 0)
+                       return TRUE;
+               else
+                       return FALSE;
+#else
+               return FALSE;
+#endif
+       }
+}
+
+int
+DAUDIO_Flush(void *id, int isSource)
+{
+       struct sndio_data *d = id;
+       struct pollfd pfd;
+       nfds_t nfds;
+
+       if (!sndio_check_handle(d, isSource)) {
+               printf("sndio handle error: DAUDIO_StillDraining\n");
+               return FALSE;
+       }
+
+       /* how do you flush recording? */
+       if (d->mode == SIO_REC)
+               return TRUE;
+
+#if 0
+       /* probably unnecessary busy work */
+       while (d->softpos > d->realpos) {
+               nfds = sio_pollfd(d->hdl, &pfd, POLLOUT);
+               /* wait a little bit */
+               poll(&pfd, nfds, 10);
+               sio_revents(d->hdl, &pfd);
+       }
+#endif
+
+       return TRUE;
+}
+
+int
+DAUDIO_GetAvailable(void *id, int isSource)
+{
+       struct sndio_data *d = id;
+       struct pollfd pfd;
+       nfds_t nfds;
+       int avail;
+
+       if (!sndio_check_handle(d, isSource)) {
+               printf("sndio handle error: DAUDIO_GetAvailable\n");
+               return 0;
+       }
+
+       nfds = sio_pollfd(d->hdl, &pfd,
+           (d->mode == SIO_PLAY) ? POLLOUT : POLLIN);
+       poll(&pfd, nfds, 0);
+       sio_revents(d->hdl, &pfd);
+
+       avail = 0;
+       if (d->mode == SIO_PLAY)
+               avail = d->par.appbufsz - (d->softpos - d->realpos);
+       else
+               avail = d->realpos - d->softpos;
+       if (avail < 0)
+               avail = 0;
+       else if (avail > d->par.appbufsz)
+               avail = d->par.appbufsz;
+
+       return (avail * d->par.bps *
+           (d->mode == SIO_PLAY ? d->par.pchan : d->par.rchan));
+}
+
+INT64
+DAUDIO_GetBytePosition(void *id, int isSource, INT64 javaBytePos)
+{
+       struct sndio_data *d = id;
+       struct pollfd pfd;
+       nfds_t nfds;
+       long long pos;
+
+       if (!sndio_check_handle(d, isSource)) {
+               printf("sndio handle error: DAUDIO_GetBytePosition\n");
+               return 0;
+       }
+
+       nfds = sio_pollfd(d->hdl, &pfd,
+           (d->mode == SIO_PLAY) ? POLLOUT : POLLIN);
+       poll(&pfd, nfds, 0);
+       sio_revents(d->hdl, &pfd);
+
+       pos = d->realpos;
+       if (pos > d->par.appbufsz)
+               pos = d->par.appbufsz;
+       else if (pos < 0)
+               pos = 0;
+
+       return (pos * d->par.bps *
+           ((d->mode == SIO_PLAY) ? d->par.pchan : d->par.rchan));
+}
+
+void
+DAUDIO_SetBytePosition(void *id, int isSource, INT64 javaBytePos)
+{
+       struct sndio_data *d = id;
+       INT64 pos;
+       int diff;
+
+       if (!sndio_check_handle(d, isSource)) {
+               printf("sndio handle error: DAUDIO_SetBytePosition\n");
+               return;
+       }
+
+       pos = DAUDIO_GetBytePosition(id, isSource, 0);
+       diff = (javaBytePos - pos) / d->par.bps /
+           ((d->mode == SIO_PLAY) ? d->par.pchan : d->par.rchan);
+       d->realpos += diff;
+       d->softpos += diff;
+}
+
+int
+DAUDIO_RequiresServicing(void *id, int isSource)
+{
+       return FALSE;
+}
+
+void
+DAUDIO_Service(void *id, int isSource)
+{
+}
+
+#endif /* USE_DAUDIO */
Index: patches/patch-j2se_make_javax_sound_FILES_c_gmk
===================================================================
RCS file: patches/patch-j2se_make_javax_sound_FILES_c_gmk
diff -N patches/patch-j2se_make_javax_sound_FILES_c_gmk
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-j2se_make_javax_sound_FILES_c_gmk     1 Jul 2010 09:41:37 
-0000
@@ -0,0 +1,13 @@
+$OpenBSD$
+--- j2se/make/javax/sound/FILES_c.gmk.orig     Sun Dec 13 22:08:54 2009
++++ j2se/make/javax/sound/FILES_c.gmk  Sun Dec 13 22:10:14 2009
+@@ -58,7 +58,8 @@ FILES_bsd = \
+       $(CTARGDIR)HAE_API_BSDOS.c \
+       $(CTARGDIR)HAE_API_BSDOS_Capture.c \
+       $(CTARGDIR)HAE_API_MacOS.c \
+-      $(CTARGDIR)HAE_API_MacOS_Capture.c
++      $(CTARGDIR)HAE_API_MacOS_Capture.c \
++      $(CTARGDIR)PLATFORM_API_BSDOS_PCM.c
+ 
+ FILES_windows = \
+       $(CTARGDIR)HAE_API_WinOS.c \
Index: patches/patch-j2se_make_javax_sound_Makefile
===================================================================
RCS file: patches/patch-j2se_make_javax_sound_Makefile
diff -N patches/patch-j2se_make_javax_sound_Makefile
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-j2se_make_javax_sound_Makefile        1 Jul 2010 09:41:37 
-0000
@@ -0,0 +1,18 @@
+$OpenBSD$
+--- j2se/make/javax/sound/Makefile.orig        Mon Dec 14 03:10:20 2009
++++ j2se/make/javax/sound/Makefile     Mon Dec 14 03:22:20 2009
+@@ -105,9 +105,12 @@ ifeq ($(PLATFORM), bsd)
+     INCLUDE_MIDI = TRUE
+     # build with empty ports
+     INCLUDE_PORTS = TRUE
+-    # build with empty direct audio
++    # build with direct audio
+     INCLUDE_DAUDIO = TRUE
+-    ifeq ($(OS_VENDOR), OpenBSD) 
++    CPPFLAGS += -DUSE_DAUDIO=TRUE
++    # sndio for DirectAudio, ossaudio for HAE
++    LDFLAGS += -lsndio
++    ifeq ($(OS_VENDOR), OpenBSD)
+       LDFLAGS += -lossaudio
+     endif
+ endif # PLATFORM bsd
Index: patches/patch-j2se_src_share_native_com_sun_media_sound_Platform_c
===================================================================
RCS file: patches/patch-j2se_src_share_native_com_sun_media_sound_Platform_c
diff -N patches/patch-j2se_src_share_native_com_sun_media_sound_Platform_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-j2se_src_share_native_com_sun_media_sound_Platform_c  1 Jul 
2010 09:41:37 -0000
@@ -0,0 +1,13 @@
+$OpenBSD$
+--- j2se/src/share/native/com/sun/media/sound/Platform.c.orig  Mon Dec 14 
03:26:44 2009
++++ j2se/src/share/native/com/sun/media/sound/Platform.c       Mon Dec 14 
12:04:38 2009
+@@ -88,8 +88,7 @@ JNIEXPORT jint JNICALL Java_com_sun_media_sound_Platfo
+     case com_sun_media_sound_Platform_FEATURE_PORTS:
+       return com_sun_media_sound_Platform_LIB_MAIN;
+     case com_sun_media_sound_Platform_FEATURE_DIRECT_AUDIO:
+-      // XXXBSD: When native Direct Audio support is ported change
+-      // this back to returning com_sun_media_sound_Platform_LIB_MAIN
++      return com_sun_media_sound_Platform_LIB_MAIN;
+       return 0;
+     }
+ #endif

Reply via email to