From alsa-devel-owner@alsa.jcu.cz  Thu Apr 30 13:55:20 1998
Received: from entry.jcu.cz (perex@entry.jcu.cz [160.217.1.111])
	by marvin.jcu.cz (8.8.8/8.8.8) with SMTP id NAA28183;
	Thu, 30 Apr 1998 13:54:32 +0200
Date: Thu, 30 Apr 1998 13:54:32 +0200 (MET DST)
From: Jaroslav Kysela <perex@jcu.cz>
To: alsa-devel@alsa.jcu.cz
cc: zoid@idsoftware.com
Subject: Open flags (O_RDWR) is broken for OSS's /dev/dsp?
Message-ID: <Pine.LNX.3.96.980430132502.8532B-100000@entry.jcu.cz>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Reply-To: alsa-devel@alsa.jcu.cz
Sender: alsa-devel-owner@alsa.jcu.cz
Precedence: list

Hi all!

	Looks like OSS have total bad interpretation of O_RDWR flag.
Quake II (and maybe Quake I, too) opens /dev/dsp with O_RDWR (why? Quake
does only playback - O_WRONLY flag will be enough) and mmaps playback
buffer to user space. After this is set format (usually 16-bit signed
little endian stereo). 

What's wrong?

ALSA driver supports full duplex and if specifies format isn't supported
it defaults to 8-bit unsigned format (as OSS does). In this is problem
when playback and record directions are different (supports different
formats). For example: GUS Classic can do only 8-bit recording. ALSA
driver doesn't find requested 16-bit format for recording so it defaults
to 8-bit (if O_RDWR flag is used). Application like Quake doesn't reflect
to return value and problem is here. OSS code for Quake is a little bit
wrong that doesn't reflect if mmap function failed, too. This should cause
segfaults with Sound Blaster 16/AWE soundcards in some cases.

Some OSS software is really ugly and most of these problems are caused
that OSS driver is able do some ugly things ;-((( This is main reason why
OSS compatibility can't be do in easy way.

OK. Driver 0.1.0pre4 will contains correction for this bug (algorithm is
now: if mmaped access is used, driver looks which directions are mmaped
and format is corrected only for these directions).

						Jaroslav

-----
Jaroslav Kysela <perex@jcu.cz>
Academic Computer Centre, University of South Bohemia
Branisovska 31, C. Budejovice, CZ-370 05 Czech Republic


