Subject: kern/17159: Incompatible change to audio(4) between NetBSD 1.5 and 1.6
To: None <gnats-bugs@gnats.netbsd.org>
From: Gregory McGarry <g.mcgarry@ieee.org>
List: netbsd-bugs
Date: 06/04/2002 12:58:13
>Number:         17159
>Category:       kern
>Synopsis:       audio(4) interface change
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 03 17:59:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Gregory McGarry
>Release:        NetBSD 1.6_BETA1
>Organization:
	
>Environment:

System: NetBSD 1.6_BETA1
Architecture: i686

eap0 at pci0 dev 10 function 0: vendor 0x1274 product 0x5880 CT5880C (rev. 0x02)
eap0: interrupting at irq 5
eap0: SigmaTel STAC9721/23 codec; 18 bit DAC, 18 bit ADC, SigmaTel 3D
audio0 at eap0: full duplex, mmap, independent
midi0 at eap0: AudioPCI MIDI UART

>Description:

This code fragment works on NetBSD 1.5:

	AUDIO_INITINFO(&info);
	if (ioctl(fd, AUDIO_GETINFO, &info) == -1)
		err(EXIT_FAILURE, "AUDIO_GETINFO");
	if (ioctl(fd, AUDIO_SETINFO, &info) == -1)
		err(EXIT_FAILURE, "AUDIO_SETINFO");

On NetBSD 1.6, the AUDIO_SETINFO ioctl fails, returning EINVAL.

audio(4) provides the following documentation:

   When setting the current state with AUDIO_SETINFO, the audio_info
   structure should first be initialized with AUDIO_INITINFO (&info)
   and then the particular values to be changed should be set.  This
   allows the audio driver to only set those things that you wish to
   change and eliminates the need to query the device with
   AUDIO_GETINFO first.

With the current state, it is not sufficient to say "eliminates the
need to query the device with AUDIO_GETINFO first".  In fact, it
is mandatory to do it this way.

The original 1.5 behaviour such that the AUDIO_GETINFO ioctl can be
called to initialise struct audio_info should be preserved.  Certainly,
it's less likely to break existing code which worked before the
auconv changes.

>How-To-Repeat:

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <err.h>
#include <sys/ioctl.h>
#include <sys/audioio.h>

int main (int argc, char *argv[])
{
	struct audio_info info;
	int fd;
  
	if ((fd = open("/dev/audio", O_RDWR, 0666)) == -1)
		err(EXIT_FAILURE, "/dev/audio");
  
	AUDIO_INITINFO(&info);
	if (ioctl(fd, AUDIO_GETINFO, &info) == -1)
		err(EXIT_FAILURE, "AUDIO_GETINFO");
	if (ioctl(fd, AUDIO_SETINFO, &info) == -1)
		err(EXIT_FAILURE, "AUDIO_SETINFO");

	close(fd);
}

>Fix:

N/A
>Release-Note:
>Audit-Trail:
>Unformatted: