Subject: emuxki(4): audioplay(1) blocking
To: None <current-users@NetBSD.org>
From: Jukka Salmi <j+nbsd@2006.salmi.ch>
List: current-users
Date: 09/12/2006 18:42:35
Hi,

I'm having problems playing some WAVE audio files on a NetBSD/i386
system with an emuxki(4):

emuxki0 at pci0 dev 14 function 0: Creative Labs SBLive! EMU 10000 (audio multimedia, revision 0x07)
emuxki0: ac97: SigmaTel STAC9708 codec; 18 bit DAC, 18 bit ADC, SigmaTel 3D
emuxki0: ac97: ext id 80<SDAC>
audio0 at emuxki0: full duplex, mmap, independent

The problem: after having played a stereo file using audioplay(1),
playing a mono file blocks while writing to /dev/sound. And the same
is true the other way round: after having played a mono file, playing
a stereo file blocks.

To reset the system to a state where playing a WAVE file with n channels
works I play a FLAC file with n channels using pkgsrc/audio/flac123.
However, I don't know _why_ this works...

Given the following files

	http://salmi.ch/~jukka/nbsd/mono.wav
	http://salmi.ch/~jukka/nbsd/mono.flac
	http://salmi.ch/~jukka/nbsd/stereo.wav
	http://salmi.ch/~jukka/nbsd/stereo.flac

$ file mono.* stereo.*
mono.flac:   FLAC audio bitstream data, 16 bit, mono, 44.1 kHz, 34584 samples
mono.wav:    RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 44100 Hz
stereo.flac: FLAC audio bitstream data, 16 bit, stereo, 44.1 kHz, 34584 samples
stereo.wav:  RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, stereo 44100 Hz

here's a log describing the reproduction of the problem (kernel with
EMUXKI_DEBUG set):

$ flac123 stereo.flac
emuxki0: emuxki_open called
Setting play voice params : mono, 16 bits, 8000 Hz
Setting play voice params : stereo, 16 bits, 8000 Hz
Setting play voice params : stereo, 16 bits, 44100 Hz
	[plays fine]
emuxki0: emu10K1_close called

$ audioplay stereo.wav
emuxki0: emuxki_open called
	[plays fine]
emuxki0: emu10K1_close called

$ audioplay mono.wav
emuxki0: emuxki_open called
Setting play voice params : mono, 16 bits, 44100 Hz
	[blocks, see below]
	[^C]
emuxki0: emu10K1_close called

$ flac123 mono.flac
emuxki0: emuxki_open called
Setting play voice params : mono, 16 bits, 8000 Hz
Setting play voice params : mono, 16 bits, 44100 Hz
	[plays fine]
emuxki0: emu10K1_close called

$ audioplay mono.wav
emuxki0: emuxki_open called
	[plays fine]
emuxki0: emu10K1_close called


Ktracing the blocking audioplay(4) shows
  [...]
  2860      1 audioplay CALL  open(0x804a3b9,1,0x804a36f)
  2860      1 audioplay NAMI  "/dev/sound"
  2860      1 audioplay RET   open 4
  [...]
  2860      1 audioplay RET   read 3676/0xe5c
  2860      1 audioplay CALL  write(4,0x804d000,0xe5c)

and top(1) reports `STATE aud_wr'.


Any hints what could be the problem? What information should I provide?

TIA, Jukka

-- 
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~