I have a 80 MB PCM-file. I want to read it into a buffer and process it:
FMOD_System_CreateStream(fmod_system, s, FMOD_OPENONLY, NULL, &fmod_sound);
while (buf_length == act_length)
FMOD_Sound_ReadData(fmod_sound, (char *)data, buf_length, &act_length);
When I open it using CreateStream, it takes 10 sec. just to read it completely (without further processing)!!!
For comparison: Same work takes less than a second with CreateSound.
Why is the Streaming so slow???
Later I’ll have PCM > 1 GB, that’s why I can’t use CreateSound (which would load it into memory completely)
- thespiders asked 10 years ago
I did some profiles on OPEN_ONLY flag and found that it was practically negligible with and without it, and what’s more interesting was that closing a sound handle was almost equally time consuming. This is of course using my own memory callbacks, but that’s not the issue, I hope.
- mac_bug answered 10 years ago
Its not the createStream that is slow right?
As for readdata, all it is doing is calling fread for you. If that is what you are asking about how long do you expect 80mb to take when reading? It would probably take nearly 10 seconds to just copy that file in explorer on some machines.
We also have a case where CreateStream() (for loading music tracks of about 800kb) is quite slow and takes 0.5 seconds, which is unacceptable in the main thread. What could take it so long? Does it copy memory – like CreateSound() – under certain circumstances?
I’ll call it with FMOD_NONBLOCKING and play it later if you don’t have any better solution.
- brunntho answered 6 years ago
Please login first to submit.