Subject: re: bin/30612: audiorecord(1) does not copy correctly the existing audio settings
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: matthew green <mrg@eterna.com.au>
List: netbsd-bugs
Date: 06/28/2005 22:39:02
The following reply was made to PR bin/30612; it has been noted by GNATS.

From: matthew green <mrg@eterna.com.au>
To: gnats-bugs@netbsd.org, netbsd@xstnz.tk
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: re: bin/30612: audiorecord(1) does not copy correctly the existing audio settings 
Date: Wed, 29 Jun 2005 08:38:19 +1000

    >Description:
    If one or more record format parameters are not defined on the command
    line, the existing audio settings are not used instead as the code
    intends to do. Since the new settings are initialized with AUDIO_INITINFO
    before the ioctl call the AUDIO_SETINFO ioctl call will fail with EINVAL.
    >How-To-Repeat:
    audiorecord foo.wav
    >Fix:
    --- record_org.c	2005-06-27 18:53:55.000000000 +0200
    +++ record.c	2005-06-27 18:54:27.000000000 +0200
    @@ -261,7 +261,7 @@
     	/*
     	 * for these, get the current values for stuffing into the header
     	 */
    -#define SETINFO(x)	if (x) info.record.x = x; else x = oinfo.record.x
    +#define SETINFO(x)	if (x) info.record.x = x; else info.record.x = oinfo.record.x
     	SETINFO (sample_rate);
     	SETINFO (channels);
     	SETINFO (precision);
    
 
 this loses the setting of options from the existing settings.  would
 you please try this patch instead?
 
 
 .mrg.
 
 Index: record/record.c
 ===================================================================
 RCS file: /cvsroot/src/usr.bin/audio/record/record.c,v
 retrieving revision 1.38
 diff -p -r1.38 record.c
 *** record/record.c	19 Jul 2004 19:27:59 -0000	1.38
 --- record/record.c	28 Jun 2005 22:37:47 -0000
 *************** main(argc, argv)
 *** 261,274 ****
   	/*
   	 * for these, get the current values for stuffing into the header
   	 */
 ! #define SETINFO(x)	if (x) info.record.x = x; else x = oinfo.record.x
 ! 	SETINFO (sample_rate);
 ! 	SETINFO (channels);
 ! 	SETINFO (precision);
 ! 	SETINFO (encoding);
 ! 	SETINFO (gain);
 ! 	SETINFO (port);
 ! 	SETINFO (balance);
   #undef SETINFO
   
   	if (monitor_gain)
 --- 261,277 ----
   	/*
   	 * for these, get the current values for stuffing into the header
   	 */
 ! #define SETINFO(x)	if (x) \
 ! 				info.record.x = x; \
 ! 			else \
 ! 				info.record.x = x = oinfo.record.x;
 ! 	SETINFO (sample_rate)
 ! 	SETINFO (channels)
 ! 	SETINFO (precision)
 ! 	SETINFO (encoding)
 ! 	SETINFO (gain)
 ! 	SETINFO (port)
 ! 	SETINFO (balance)
   #undef SETINFO
   
   	if (monitor_gain)