From owner-freebsd-multimedia Mon Nov 6 17:36:12 2000 Delivered-To: freebsd-multimedia@freebsd.org Received: from arg1.demon.co.uk (arg1.demon.co.uk [194.222.34.166]) by hub.freebsd.org (Postfix) with ESMTP id 0491637B4D7; Mon, 6 Nov 2000 17:36:07 -0800 (PST) Received: by arg1.demon.co.uk (Postfix, from userid 300) id A06CF9B0F; Tue, 7 Nov 2000 01:36:00 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by arg1.demon.co.uk (Postfix) with ESMTP id 98A665D07; Tue, 7 Nov 2000 01:36:00 +0000 (GMT) Date: Tue, 7 Nov 2000 01:36:00 +0000 (GMT) From: Andrew Gordon X-Sender: arg@server.arg.sj.co.uk To: j mckitrick Cc: stable@freebsd.org, multimedia@freebsd.org Subject: Re: continuing sound problems with 4.2-beta In-Reply-To: <20001104234358.A48459@dogma.freebsd-uk.eu.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-multimedia@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Sat, 4 Nov 2000, j mckitrick wrote: > I continue to get 'invalid argument' when using 'play' to play a .wav file. > Maybe I am doing something wrong, but I can't figure out what it is. > > open("/dev/dsp",1,027757774234) = 4 (0x4) > ioctl(4,SNDCTL_DSP_GETBLKSIZE,0xbfbff7d4) = 0 (0x0) > ioctl(4,SNDCTL_DSP_SETFMT,0x804bc80) ERR#22 'Invalid argument' I ran into this the other day; it appears that there has been a change in the sound API recently such that you need to do SNDCTL_DSP_SPEED before SNDCTL_DSP_SETFMT. I haven't had time to dig into CVS to see when this happened or why. This code used to work in 3.x and in 4.x up until a week or two ago: audio_fd = open("/dev/audio", O_RDWR); if (audio_fd < 0) { perror("/dev/audio"); exit(1); } i = AFMT_S16_LE; if (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &i) == -1) { perror("Setting audio format"); exit(1); } i = 1; if (ioctl(audio_fd, SNDCTL_DSP_STEREO, &i) == -1) { perror("Setting stereo mode"); exit(1); } i = SAMPLE_HZ; if (ioctl(audio_fd, SNDCTL_DSP_SPEED, &i) == -1) { perror("Setting audio rate"); exit(1); } if (i != SAMPLE_HZ) { fprintf(stderr, "Soundcard doesn't support %dHz (offers %d)\n", SAMPLE_HZ, i); exit(1); } Now, it fails at the SNDCTL_DSP_SETFMT call (invalid argument), but if I move the SNDCTL_DSP_SETSPEED immediately after the open, normal working is restored. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-multimedia" in the body of the message