From nobody@FreeBSD.org  Sat Nov 30 01:14:05 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTPS id 9CD021C2
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 30 Nov 2013 01:14:05 +0000 (UTC)
Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 89C4B1B2C
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 30 Nov 2013 01:14:05 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id rAU1E4XV053429
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 30 Nov 2013 01:14:04 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id rAU1E4mf053426;
	Sat, 30 Nov 2013 01:14:04 GMT
	(envelope-from nobody)
Message-Id: <201311300114.rAU1E4mf053426@oldred.freebsd.org>
Date: Sat, 30 Nov 2013 01:14:04 GMT
From: Jan Beich <jbeich@tormail.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [pcm] SNDCTL_DSP_SETFMT accepts unsupported values
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         184380
>Category:       kern
>Synopsis:       [pcm] SNDCTL_DSP_SETFMT accepts unsupported values
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Nov 30 01:20:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Jan Beich
>Release:        FreeBSD 11.0-CURRENT amd64
>Organization:
>Environment:
>Description:
According to SNDCTL_DSP_SETFMT documentation if the ioctl() succeeds
the application must check if value was accepted. Unfortunately, our
OSS implementation may return value that's not actually supported.

http://manuals.opensound.com/developer/SNDCTL_DSP_SETFMT.html

At least the following ports check requested format and would assume
AFMT_FLOAT is accepted if built with sys/soundcard.h from opensound.com.

  devel/allegro-devel
  emulators/wine
  multimedia/audacious-plugins
  multimedia/mplayer
  multimedia/vlc

Probably, only Linux accepts AFMT_FLOAT which means apps built with
OSSv4 wouldn't work under linuxulator either.

>How-To-Repeat:
# kern/21073, audio/oss
$ ./dsp-record -b float
Trying    8012 Hz 1 Channel float Format
ioctl(SNDCTL_DSP_SETFMT) failed: Tried 16384, Got 16

# kern/21073, native
$ ./dsp-record -b float | head -1 | vis -m
Trying    8012 Hz 1 Channel float Format
Recording 8012 Hz 1 Channel float Format
=00=00=00=80=FF=FF=FF=7F=FA=FF=FF=7Fx=FF=FF=7F=E4=00=00=80=9B=FE=FF=7F

# audio/oss
$ ./test
0x00000010

# native
$ ./test
0x00004000

$ cat test.c
#include <sys/soundcard.h>

#include <fcntl.h>
#include <stdio.h>

#ifndef AFMT_FLOAT
#define AFMT_FLOAT 0x00004000
#endif

int main()
{
  int fd = open("/dev/dsp", O_RDWR, 0);

  int format = AFMT_FLOAT;
  if (ioctl(fd, SNDCTL_DSP_SETFMT, &format) < 0)
    return 1;

  printf("%0#10x\n", format);

  return 0;
}

>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:
