Hi, guys.
I've got a little issue with this Spectrum emulator and audio, and I've hit a
brick wall with what to do next.
This might be a question of "oh, just do this in audioctl" - I just don't know,
and I'm not managing to find the answer myself.
The emulator runs fine, but sound isn't quite right. This message appears in
the terminal window:
Major slip in writing sound device
(This is on a couple of i386 machines.)
spsound.c has that message, it looks like the code keeps track of the number of
sample bytes written, then asks the audio (ioctl AUDIO_GETINFO) how many bytes
it has written.
After a few iterations of this, the audio playback has fallen behind, and the
program decides to ignore its idea of where it has gotten to, and go with the
samples value from the ioctl call.
I've added some debugging, and I don't understand how this occurs:
samplenum 624 written 936 auinfo.play.samples 416 (seek is 832), diff is 520
samplenum is the number of bytes the emulator has just written to /dev/audio.
The code writes 312 bytes, then another 624 - that gives the 936.
It uses the ioctl and gets told we've played 416 samples, and that there are 832
pending. How can that be? If we've requested 936, how can audio think that
there are 416+832=1248 sample bytes?
There are audio errors happening (see audioctl output below) so I can see that
obviously things aren't generally happy, but I'd love to understand why the
ioctl says there are more bytes going through than were requested.
And anything else to try, cluesticks, etc. I guess moving the sound to SDL or
libsndio are options, but I'd like to understand what is happening here before I
move on.
Thanks.
$ audioctl
name=ICH4 AC97
version=0x01
config=auich0
encodings=ulinear:8:1:1,mulaw:8:1:1*,alaw:8:1:1*,slinear:8:1:1*,slinear_le:16:2:1,ulinear_le:16:2:1*,slinear_be:16:2:1*,ulinear_be:16:2:1*
properties=full_duplex,mmap,independent
full_duplex=0
fullduplex=0
blocksize=208
hiwat=78
lowat=1
output_muted=0
monitor_gain=0
mode=
play.rate=16000
play.sample_rate=16000
play.channels=1
play.precision=8
play.bps=1
play.msb=1
play.encoding=mulaw
play.gain=255
play.balance=32
play.port=0x0
play.avail_ports=0x0
play.seek=208
play.samples=97760
play.eof=0
play.pause=0
play.error=1
play.waiting=0
play.open=0
play.active=0
play.buffer_size=16384
play.block_size=208
play.errors=520
...
$ dmesg
OpenBSD 5.1 (GENERIC) #160: Sun Feb 12 09:46:33 MST 2012
[email protected]:/usr/src/sys/arch/i386/compile/GENERIC
cpu0: Intel(R) Pentium(R) M processor 1.70GHz ("GenuineIntel" 686-class) 1.70
GHz
cpu0:
FPU,V86,DE,PSE,TSC,MSR,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,TM,SBF,EST,TM2
real mem = 1609494528 (1534MB)
avail mem = 1573068800 (1500MB)
...