From alsa-devel-owner@alsa.jcu.cz  Thu Mar 19 22:31:29 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 WAA17127;
	Thu, 19 Mar 1998 22:31:17 +0100
Date: Thu, 19 Mar 1998 22:31:17 +0100 (MET)
From: Jaroslav Kysela <perex@jcu.cz>
To: Thomas Sailer <sailer@ife.ee.ethz.ch>
cc: Scott Lampert <fortunato@heavymetal.org>, alsa-devel@alsa.jcu.cz
Subject: SB 16 & MMAP & quake2
In-Reply-To: <3511549E.64F7@ife.ee.ethz.ch>
Message-ID: <Pine.LNX.3.96.980319221200.2030C-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 we have first big problem with SoundBlaster 16
soundcards and mmaped access. I don't know how we can best solve this
problem, but someone can have idea:


cutted strace of quake:

open("/dev/dsp", O_RDWR)                = 7
ioctl(7, SNDCTL_DSP_RESET, 0)           = 0
ioctl(7, SNDCTL_DSP_GETCAPS, 0xbffff920) = 0
ioctl(7, SNDCTL_DSP_GETOSPACE, 0xbffff924) = 0
ioctl(7, SNDCTL_DSP_GETFMTS, 0xbffff91c) = 0
ioctl(7, SNDCTL_DSP_SPEED, 0x80ab00c)   = 0
mmap(0, 65536, PROT_WRITE, MAP_SHARED, 7, 0) = -1 ENXIO (Device not configured)
ioctl(7, SNDCTL_DSP_STEREO, 0xbffff918) = 0
ioctl(7, SNDCTL_DSP_SPEED, 0x8999138)   = 0
ioctl(7, SNDCTL_DSP_SETFMT, 0xbffff914) = 0
ioctl(7, SNDCTL_DSP_SETTRIGGER, 0xbffff918) = 0
ioctl(7, SNDCTL_DSP_SETTRIGGER, 0xbffff918) = 0
lseek(3, 473982, SEEK_SET)              = 473982
read(3, "RIFF\340\331\0\0WAVEfmt \22\0\0\0"..., 55784) = 55784
lseek(3, 529766, SEEK_SET)              = 529766
read(3, "RIFF\272o\0\0WAVEfmt \22\0\0\0\1"..., 28610) = 28610
--- SIGSEGV (Segmentation fault) ---

Source in ALSA driver:

  if ( pchn -> hw.flags & SND_PCM_HW_8BITONLY ) {
    if ( pchn -> mode & SND_PCM_MODE_16 ) return -ENXIO;
  }
  if ( pchn -> hw.flags & SND_PCM_HW_16BITONLY ) {
    if ( !(pchn -> mode & SND_PCM_MODE_16) ) return -ENXIO;
  }

Explain:

  Driver allocates for SB16 PCM when is first direction open (by
duplex is first direction playback) 16-bit DMA (if is enabled). In this
case driver does for normal access (not mmaped access) conversion from
8-bit samples to 16-bit samples. This conversion is unpossible with
mmaped access, so driver checks sample with and returns error to
application which called mmap() functions if conversion is needed and
can't be done. Looks like that quake doesn't reflect to this error code
and tries write to non-existent piece of memory (-> SIGSEGV).

Problem solving:

  Try change sample width for quake (quake -sndbits 16 or quake -sndbits
8).

Any ideas?

					Jaroslav Kysela

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




