Subject: soundblaster AWE64 misbehaving with 1.3.2?
To: None <port-i386@netbsd.org>
From: Tom Spindler <dogcow@isi.net>
List: port-i386
Date: 12/17/1998 13:53:55
--YZ5djTAD1cGYuMQK
Content-Type: text/plain; charset=us-ascii

I've found that that my AWE64 misbehaves in rather strange ways under
netbsd 1.3.2 - it only accepts the first write to /dev/audio and subsequent
writes get queued but never played. A further interesting wrinkle is that
when the program doing the writing is ^C'ed, the program continues to block
for about 10-30 seconds, plays one final blip of sound, and then exits.

Has anybody else encountered this problem?

I've attached a lttle program that sends some output to the speaker, as
well as the results on my machine.

(It's a ASUS P5A, K6-2 @350mhz machine, if that helps.)

--YZ5djTAD1cGYuMQK
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="bogo.c"

/* This is mostly stolen from the xmame source */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <math.h>
#include <sys/types.h>
#include <sys/audioio.h>

static int audio_fd;
static int audioctl_fd;
volatile audio_info_t a_info, zort;
audio_device_t a_dev;

#define AUDIO_SAMPLE_FREQ 22050
#define AUDIO_SAMPLE_BITS 8

void init() {
    fprintf(stderr, "NetBSD/i386 sound device initialization...\n");
    /* try to open audio device */
    if ((audio_fd = open("/dev/audio", O_WRONLY /* | O_NDELAY*/)) < 0) {
      perror("Cannot open audio device");
    } else {
	audioctl_fd = open("/dev/audioctl", O_RDWR);
      /* empty buffers before change config */
      ioctl(audioctl_fd, AUDIO_FLUSH, 0);        /* flush everything */
      
      /* identify audio device. */
      if(ioctl(audioctl_fd, AUDIO_GETDEV, &a_dev) < 0) {
	perror("Cannot get sound device type");
	close(audio_fd);
	close(audioctl_fd);
      } else {
	fprintf(stderr, "Sound device is a %s %s version %s fds %d/%d\n",
	       a_dev.config, a_dev.name, a_dev.version, audio_fd, audioctl_fd);
	    
	/* initialize audio parameters. */ 
	AUDIO_INITINFO(&a_info);
	    
	a_info.play.sample_rate = AUDIO_SAMPLE_FREQ;
	a_info.play.encoding = (uint) AUDIO_ENCODING_ULINEAR;
	a_info.play.precision = (uint) AUDIO_SAMPLE_BITS;
	a_info.play.channels = (uint) 1;
	a_info.blocksize = 0;
	a_info.mode = AUMODE_PLAY | AUMODE_PLAY_ALL;
	printf("sr %d pre %d blsz %d bfsz %d\n", a_info.play.sample_rate,
	    a_info.play.precision, a_info.blocksize, a_info.play.buffer_size);
	if (ioctl(audioctl_fd, AUDIO_SETINFO, &a_info) < 0) {
	  perror("cannot set audio device parameters");
	  close(audio_fd);
	  close(audioctl_fd);
	}
	ioctl(audioctl_fd, AUDIO_GETINFO, &zort);
      }
    }
}

int main() {
char buff[1024];
int j;
int i;
	init();
	j = 440;
	while(1) {

		for (i = 0; i < 1024; i++) 
		buff[i] = (char)(256 * sin(3.14159 * 2 * i * j/ AUDIO_SAMPLE_FREQ));
		write(audio_fd, buff, 1024);
		printf("foop (%d) rem:%ld.\n", j, a_info.play.seek);
		j *= 1.1;
		ioctl(audioctl_fd, AUDIO_GETINFO, &a_info);
	sleep(1);
	}
}

--YZ5djTAD1cGYuMQK
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="bogo.out"

p0 dogcow@baloney: ~ 34 % ./bogo
NetBSD/i386 sound device initialization...
Sound device is a SB_16 SoundBlaster version 4.16 fds 5/6
sr 22050 pre 8 blsz 0 bfsz -1
foop (440) rem:-1.
foop (484) rem:1024.
foop (532) rem:2048.
foop (585) rem:3072.
^C


--YZ5djTAD1cGYuMQK--