Subject: bin/9133: Bug in audioplay
To: None <gnats-bugs@gnats.netbsd.org>
From: Ben <hackerb9@u.washington.edu>
List: netbsd-bugs
Date: 01/08/2000 04:58:22
>Number:         9133
>Category:       bin
>Synopsis:       audioplay cannot play some .au sound files even with -f
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan  6 08:30:00 2000
>Last-Modified:
>Originator:     Ben Wong
>Organization:
	
>Release:        NetBSD-1.4.1
>Environment:
	
System: NetBSD ursula.wongs.net 1.4.1 NetBSD 1.4.1 (AMNESIAC) #7: Thu Oct 14 22:00:19 EDT 1999 hackerb9@ursula.wongs.net:/usr/src/sys/arch/i386/compile/AMNESIAC i386


>Description:

audioplay cannot play sound files that have been created with
audiorecord because it exits with an error. It complains that the
files are of an "unknown supported format" (this may also be a bug in
how audiorecord creates files).

The bug in audioplay is that it does not try to play the file even
when given the -f option to force playing. It currently does not check
for the -f option if a Sun audio header is detected.


>How-To-Repeat:

The following assumes you have an audio signal coming in to your
soundcard and have set up mixerctl to select the appropriate source.

	# Create a new .au sound file. Count to ten to allow some data
	# to be flushed to the file before hitting ^C.
	> audiorecord foo.au
	^C

	# The following probably ought to work but doesn't.
	> audioplay foo.au
	audioplay: unknown supported Sun audio encoding format 0
	audioplay: unknown audio file: foo.au

	# The following definitely should work but doesn't.
	> audioplay -f foo.au
	audioplay: unknown supported Sun audio encoding format 0
	audioplay: unknown audio file: foo.au

	# Dumping the raw file to /dev/audio works.
	> cat foo.au >/dev/audio



>Fix:

Here is a patch to src/usr.bin/audio/play.c so that if the user
specifies -f the file is forced to play even if it is in an "unknown
supported format".

> diff -u play.c.orig play.c
--- play.c.orig Tue Apr 13 03:13:41 1999
+++ play.c      Thu Jan  6 11:00:06 2000
@@ -285,7 +285,7 @@
 
        AUDIO_INITINFO(&info);
        sunhdr = hdr;
-       if (ntohl(sunhdr->magic) == AUDIO_FILE_MAGIC) {
+       if (ntohl(sunhdr->magic) == AUDIO_FILE_MAGIC && !fflag) {
                if (audio_get_sun_encoding(ntohl(sunhdr->encoding), 
                    &info.play.encoding, &info.play.precision)) {
                        warnx("unknown supported Sun audio encoding format %d",
@@ -344,7 +344,9 @@
        if (ioctl(fd, AUDIO_SETINFO, &info) < 0)
                err(1, "failed to set audio info");
        
-       return (hdr_len);
+       /* If they're forcing play with -f, always return successfully. */
+       if (fflag)
+         return (0);
+       else
+         return (hdr_len);
 }
 
 void

>Audit-Trail:
>Unformatted: