Open tkorvola opened 6 years ago
@tkorvola: have you had a chance to debug this any further? @fundamental: do you have any ideas about what could be causing this?
I haven't looked into this but noticed that it occurs also with -q
and sometimes disturbs other sounds playing at the same time.
The immediate fault appears to be the severely botched main loop of mixer
, which most of the time (when there is no sound) just spams ao_open_live
and ao_close
as fast as it can. You can wait for a semaphore but you can't wait for two. However, ux_audio.c was quite tangled in its threads even before f27d632: access to bleep_playing and other shared variables doesn't appear to be synchronized in any way. Only the buffers seem OK, protected by semaphores.
Given @fundamental's extensive experience with audio coding, I was going to pay him for the time and effort to get this mess unraveled and fixed correctly. That was a year ago, but a bunch of family stuff preempted this and I forgot all about it. I'd like to get this going again with a kickstarter or something informal paid into someone's Paypal account. The basic problem is how to get bleeps (AIFF samples) playing at the same time music (OGG or MOD) is also playing. Who's interested?
@tkorvola your description sounds like the sound engine is writing 0 bytes of audio rather than some amount of 0 value audio samples. If the audio thread is outputting something then it shouldn't output 0 samples. It's been a while since I've looked at the code so I don't have an immediate fix. As the commit in question implies, the original audio output model was convoluted, though fixable with additional work.
Duplicate of #27
line 353 ux_audio.c try adding:
if (!bleep_playing && !music_playing) {
usleep(10);
continue;
}
Anybody got a suitably noisy game for testing the sound system? With simultaneous music and audio. There was a link in #27 but it's gone 404.
@tkorvola No idea if it's the same file or a different one, but I had http://fundamental-code.com/tmp/soundtest2.blb sitting around from when I worked on the code last.
That should work. Though the latest is at http://661.org/proj/if/soundtest.blb. That one adds volume testing and an "off" button.
Just tried this in WinFrotz: turn on 64. push blue. turn off 64.
Music keeps playing. I wonder if anyone has got sound quite right yet.
Could what I described in the previous comment be a bug in the test, not in the interpreter? I've been running SDL Frotz under a debugger and the turn off command appears to call z_sound_effect
with a wrong number (that of the effect instead of the music).
Are you referring to the "off button" or turning off the Amiga or the C64?
I am referring to the last command in the sequence above, i.e., turn off 64
.
I'm not sure what the problem is and I need to get some sleep. I've cleaned up and uploaded the source to the soundtest game to https://github.com/DavidGriffith/soundtest.
I don't really know Inform but StopSound in sound.h looks like it can only stop the last sound played.
Frotz puts a lot of load on Pulseaudio, even in games with no sound. Pulseaudio CPU usage is constantly in the 110-140% range on my machine when Frotz is running and no sound playing (by Frotz or anything else). I bisected this to f27d632 but haven't debugged further.