$OpenBSD: patch-mixer_c,v 1.1 2002/01/14 13:47:22 naddy Exp $
--- mixer.c.orig	Thu Nov  7 11:00:26 1996
+++ mixer.c	Sun Jan 13 20:18:56 2002
@@ -104,6 +104,14 @@ STATIC ctlinfo_t	ctlsav;		/* Saved state
  ***********************/
 
 
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+void
+mxchg(int sig)
+{
+	deliverSIGIO();
+}
+#endif
+
 /*
  * do_ioctl
  *	Perform ioctl command.  If file is not yet open or if we
@@ -681,11 +689,13 @@ mx_init_drv(void)
 	/* Query sound driver version */
 	if ((fp = fopen("/dev/sndstat", "r")) == NULL) {
 		if (!app_data.demo) {
+#if !defined(__NetBSD__) && !defined(__OpenBSD__)
 			fprintf(errfp, "%s: %s: %s\n",
 				PROGNAME,
 				"Cannot open /dev/sndstat",
 				"assuming pre-3.0 sound driver.");
 			maxdevs = MAXDEVS_V2;
+#endif
 		}
 		return;
 	}
@@ -800,7 +810,7 @@ mx_init_hw(widgets_t *m)
 	/* Open device */
 	sprintf(errmsg, "%s: Cannot open device %s",
 		PROGNAME, app_data.device);
-	if ((dev_fd = open(app_data.device, O_RDONLY)) < 0) {
+	if ((dev_fd = open(app_data.device, O_RDWR)) < 0) {
 		perror(errmsg);
 		exit_flag = TRUE;
 	}
@@ -915,6 +925,7 @@ void
 mx_start(widgets_t *m)
 {
 	char	msg[256];
+	int one = 1;
 
 	if (app_data.autoload != NULL && app_data.autoload[0] != '\0' &&
 	    strcmp(app_data.autoload, "/dev/null") != 0) {
@@ -930,6 +941,14 @@ mx_start(widgets_t *m)
 		}
 	}
 
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+	signal(SIGIO, mxchg);
+	ioctl(dev_fd, FIOASYNC, &one);
+#endif
+
+	/* Query hardware mixer settings */
+	mx_queryhw(&widgets);
+
 	/* Update screen controls to match current status */
 	mx_updctl(m);
 }
@@ -1531,6 +1550,22 @@ mx_focuschg(Widget w, XtPointer client_d
 	if (p->reason != XmCR_FOCUS || form == (Widget) NULL)
 		return;
 
+	/* Query hardware mixer settings */
+	mx_queryhw(&widgets);
+
+	/* Update screen controls */
+	mx_updctl(&widgets);
+}
+
+
+/*
+ * mx_change
+ *	Mixer device has changed
+ */
+/*ARGSUSED*/
+void
+mx_change(XtPointer client_data)
+{
 	/* Query hardware mixer settings */
 	mx_queryhw(&widgets);
 
