openbsd-ports/audio/xmp/patches/patch-src_drivers_openbsd_c
espie 2bae543880 re-read parameters after set.
fixes issues with soundcards that can't handle all frequencies or any
number of channels.
2005-10-04 20:16:04 +00:00

57 lines
1.6 KiB
Plaintext

$OpenBSD: patch-src_drivers_openbsd_c,v 1.2 2005/10/04 20:16:04 espie Exp $
--- src/drivers/openbsd.c.orig Fri Dec 29 19:08:08 2000
+++ src/drivers/openbsd.c Tue Oct 4 22:12:46 2005
@@ -39,7 +39,6 @@ static void shutdown (void);
static void dummy () { }
static char *help[] = {
- "gain=val", "Audio output gain (0 to 255)",
"buffer=val", "Audio buffer size (default is 32768)",
NULL
};
@@ -75,35 +74,36 @@ struct xmp_drv_info drv_openbsd = {
static int setaudio (struct xmp_control *ctl)
{
audio_info_t ainfo;
- int gain = 128;
int bsize = 32 * 1024;
char *token;
char **parm = ctl->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.mode = AUMODE_PLAY;
ainfo.play.sample_rate = ctl->freq;
ainfo.play.channels = ctl->outfmt & XMP_FMT_MONO ? 1 : 2;
ainfo.play.precision = ctl->resol;
ainfo.play.encoding = ctl->resol > 8 ?
AUDIO_ENCODING_SLINEAR : AUDIO_ENCODING_ULINEAR;
- ainfo.play.gain = gain;
ainfo.play.buffer_size = bsize;
if (ioctl (audio_fd, AUDIO_SETINFO, &ainfo) == -1) {
close (audio_fd);
return XMP_ERR_DINIT;
}
+
+ ioctl (audio_fd, AUDIO_GETINFO, &ainfo);
+ ctl->freq = ainfo.play.sample_rate;
+ if (ainfo.play.channels == 2)
+ ctl->outfmt &= ~XMP_FMT_MONO;
+ else
+ ctl->outfmt |= XMP_FMT_MONO;
+ ctl->resol = ainfo.play.precision;
drv_openbsd.description = "OpenBSD PCM audio";
return XMP_OK;