Closed asumagic closed 4 years ago
It turns out the crash was due to a call to engine.setInaudibleBehavior(sound, true, false);
. This was called just after the sound was created. If I have some time I'll try to make a reliable repro.
I think this may have something to do with the mutex mess that got fixed a while ago, as that was related to having enough sounds and setInaudibleBehavior.
Hi there,
I have just run into the same crash using the latest release (20200207). I also tested against the latest code pulled from master a few days ago, and it also crashes. I'm running on macOS using the CoreAudio backend.
Here's a super simple repro:
#include "soloud.h"
#include "soloud_thread.h"
#include "soloud_wav.h"
int main(int argc, const char * argv[])
{
const char* wav_filename = "/path/to/file.wav";
SoLoud::Soloud soloud;
soloud.init();
SoLoud::Wav sample;
sample.load(wav_filename);
for (int t=0; t<16+1; t++)
{
SoundID handle = soloud.play(sample, 1.0f, 0.0f, true);
soloud.setInaudibleBehavior(handle, true, false);
soloud.setPause(handle, false);
}
while (soloud.getActiveVoiceCount() > 0)
{
SoLoud::Thread::sleep(100);
}
soloud.deinit();
return 0;
}
Some notes:
The crash occurs on the same line with the same callstack as the original poster.
The crash seems to occur when setInaudibleBehavior is set to (true, false) and the number of simultaneously playing sounds is greater than the value set in setMaxActiveVoiceCount
.
Any idea what the issue might be?
Also, I just want to confirm that I understand this function correctly. The behaviour I want is when there are too many sounds playing at once, the quietest sounds should not be mixed, however they should still be ticked. Is setting (true, false) the correct approach?
Cheers!
I did a bit of investigation. I don't understand the code well enough to really know what's going on, but here are some notes:
The crash occurs because voice->mResampleData[0]
is NULL (worth noting: voice->mResampleData[1]
is also NULL).
As I understand it, voice->mResampleData is populated from a pool of buffers in the Soloud core object (Soloud::mResampleData
). The size is allocated as mMaxActiveVoices * 2
which makes sense since each active voice needs two buffers to ping-pong between.
It seems like voice->mResampleData
is NULL because it can't find a free buffer in the pool. But I'm not sure why it can't find it or where the buffers in the core object are mapped to the voices. If we just want to tick (but not mix) the voice, then we probably don't need a buffer for the voice at all...
SoLoud 2018119 on Arch Linux, 64-bit build, static library using static SDL2.
I tried to port a game's audio to SoLoud due to several issues with the current library we are using. I got most of it working surprisingly easily (nice API!), however I am facing a weird crash issue in the callback thread:
As per LLDB the crash is caused by the access to
mData
.The main thread is not currently executing audio related code, and no other user code is interacting with SoLoud outside of the main thread.
When this happens, the (ogg) file is loaded using
SoLoud::Wav
(on a fresh new object) and then directly played several times at once (because the crash happens just while getting in-game).Any clue what might be happening?