0
0

Would it be possible to modify fmod so that we can call api functions such as:

FMOD_Sound_SetDefaults(..)
FMOD_Sound_SetUserData(..)
FMOD_System_PlaySound(..)

while the sound is still loading? Right now, I get the error "Operation could not be performed because specified sound is not ready." This happens in the case where we pass FMOD_NONBLOCKING into the API when we create the sound.

It would be really great if I could create a stream and/or sampled sound asynchronously, set a bunch of properties on the sound (loop count, user data, defaults), and then also play it before it was finished loading, knowing that it would play on the given channel as soon as it was finished loading.

The reason this would be so nice is because I don’t want my app blocking waiting for sounds to load or stream buffers to fill up.

I know I could emulate this in my application (by polling the openstate of a sound), but I imagine this is a feature that lots of people would be interested in having, and I also suspect that fmod could do it much more efficiently (quicker response time) than my application.

Alternatively, is it be possible to get a callback in my application when a sound has finished loading? that way I can immediately set properties on it and play it.

-sam

  • You must to post comments
0
0

You can fill in an FMOD_CREATESOUNDEXINFO structure and set the nonblock load callback to get a callback when the sound has finished loading. You can also set the User Data there if you need to.

  • Guy
  • You must to post comments
0
0

[quote="Adiss":1ya4978q]You can fill in an FMOD_CREATESOUNDEXINFO structure and set the nonblock load callback to get a callback when the sound has finished loading. You can also set the User Data there if you need to.
[/quote:1ya4978q]

Excellent, thanks. Do you know what thread context the callback will occurr in? Is that my main app thread or is it a thread created by FMOD? Just wondering if I’m going to need to introduce some synchronization variables for this…

-sam

  • You must to post comments
0
0

[quote="samc":37apvzme][quote="Adiss":37apvzme]You can fill in an FMOD_CREATESOUNDEXINFO structure and set the nonblock load callback to get a callback when the sound has finished loading. You can also set the User Data there if you need to.
[/quote:37apvzme]

Excellent, thanks. Do you know what thread context the callback will occurr in? Is that my main app thread or is it a thread created by FMOD? Just wondering if I’m going to need to introduce some synchronization variables for this…[/quote:37apvzme]

For those who are interested, the callback appears to occur in the context of a thread created by FMOD, so you might need synchronization variables.

-sam

  • You must to post comments
0
0

Yeah I am fairly sure that is called from the FMOD_NONBLOCKING thread (described in tutorial in docs about threads/threadsafety).

  • You must to post comments
0
0

Hmm.. and according to the tutorial:

"Do not call FMOD commands from different threads! This will lead to instability, corruption and possible crashes."

So I can’t play the sound in the callback after all unless I wrap all calls to fmod in my app with a critical section.

-sam

  • You must to post comments
0
0

you would be better off just setting a flag and executing -complex- logic in the main thread. Threaded callbacks are like interrupts on consoles, you shouldnt really be doing anything complex in them.

  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.