When I play stream samples (WAV) from two different threads I get a crash during a playSound API call in one of the threads. It doesn’t happen on every call, but it does always happen within 5 or 10 calls. My platform in Mac OSX 10.4.6 Intel Duo and I’m using FmodEx 4.04.06 (latest as of today). It seems to mostly crash at the same spot. Here is a crash output and GDB stack trace example:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
[Switching to process 4204 thread 0x6003]
0x003c4929 in FMOD::ChannelStream::setPosition ()
(gdb) bt

0 0x003c4929 in FMOD::ChannelStream::setPosition ()

1 0x003cb6dc in FMOD::ChannelI::setPosition ()

2 0x003ccf47 in FMOD::ChannelI::play ()

3 0x0045a711 in FMOD::SystemI::playSound ()

4 0x00450ce6 in FMOD::System::playSound ()

5 0x00009492 in Program::Cmd_FMOD_PlaySound (cx=0x67b4f0, obj=0x181f7f8, argc=2, argv=0x183ef80, rval=0xb04079b0) at Program.cc:488#6 0x0034194f in js_Invoke ()#7 0x00335e54 in js_Interpret ()#8 0x0034108b in js_Execute ()#9 0x0030a49e in JS_ExecuteScript ()#10 0x0000873c in Program::run (this=0x67b3b0) at Program.cc:216#11 0x00153a69 in Thread::startRoutine (param=0x67b3b0) at Thread.cc:65#12 0x90024a27 in _pthread_body ()

One interesting point to note is that when I perform the same operation in only one thread instead of two there is no problem whatsoever.

I have run the program using a debugging malloc library with no other issues found.

Thanks in advance for any advice,

  • Jason
  • You must to post comments

hi, you’re not supposed to call fmod from different threads, call all fmod commands from the same thread. If we made it thread safe the calls would be full of criticalsections which means huge stalls in performance as you are effectively synchronizing one thread with another, which makes each thread wait for no reason.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.