openbsd-ports/audio/xmp/patches/patch-src_drivers_solaris_c
espie 49bc284aaa Finally repair xmp. temp race is so obvious to fix, and nobody will move.
Also, make driver more robust, by separating gain control (which often
does not work) from main setup.
2001-04-05 19:31:41 +00:00

81 lines
1.9 KiB
Plaintext

$OpenBSD: patch-src_drivers_solaris_c,v 1.1 2001/04/05 19:31:42 espie Exp $
--- src/drivers/solaris.c.orig Mon May 18 06:21:17 1998
+++ src/drivers/solaris.c Thu Apr 5 21:23:52 2001
@@ -55,7 +55,9 @@ static void dummy () { }
static char *help[] = {
"gain=val", "Audio output gain (0 to 255)",
+#if !defined(__OpenBSD__)
"port={s|h|l}", "Audio port (s[peaker], h[eadphones], l[ineout])",
+#endif
"buffer=val", "Audio buffer size (default is 32768)",
NULL
};
@@ -86,6 +88,50 @@ struct xmp_drv_info drv_solaris = {
NULL
};
+#if defined(__OpenBSD__)
+static int setaudio (struct drv_config *cfg)
+{
+ audio_info_t ainfo;
+ int gain = 128;
+ int bsize = 32 * 1024;
+ char *token;
+ char **parm = cfg->parm;
+
+ parm_init ();
+ chkparm1 ("gain", gain = atoi (token));
+ chkparm1 ("buffer", bsize = atoi (token));
+ parm_end ();
+
+ if (gain < AUDIO_MIN_GAIN)
+ gain = AUDIO_MIN_GAIN;
+ if (gain > AUDIO_MAX_GAIN)
+ gain = AUDIO_MAX_GAIN;
+
+ AUDIO_INITINFO (&ainfo);
+
+ ainfo.play.sample_rate = cfg->rate;
+ ainfo.play.channels = cfg->mode + 1;
+ ainfo.play.precision = cfg->fmt & MIX_16BIT ? 16 : 8;
+ ainfo.play.encoding = cfg->fmt & MIX_16BIT ? AUDIO_ENCODING_SLINEAR : AUDIO_ENCODING_ULINEAR;
+ ainfo.play.buffer_size = bsize;
+
+ if (ioctl (audio_fd, AUDIO_SETINFO, &ainfo) == -1) {
+ close (audio_fd);
+ return 0;
+ }
+
+ AUDIO_INITINFO (&ainfo);
+ ainfo.play.gain = gain;
+ ioctl(audio_fd, AUDIO_SETINFO, &ainfo);
+
+ drv_solaris.description = "OpenBSD Generic Audio";
+
+ cfg->mode++;
+
+ return 1;
+}
+
+#else
static int setaudio (struct drv_config *cfg)
{
@@ -150,10 +196,15 @@ static int setaudio (struct drv_config *
return 1;
}
+#endif
static int init (struct drv_config *cfg)
{
+#if defined(__OpenBSD__)
+ audio_fd = open ("/dev/sound", O_WRONLY);
+#else
audio_fd = open ("/dev/audio", O_WRONLY);
+#endif
if (audio_fd == -1)
return 0;