0
0

Hi,

I’ve just downloaded FMod ex 4.03.07 and recompiled my application to use it, however I’m noticing a strange thing.

When I compiled my program with version 4.01.05 and run it I get:
[code:2admb3y7] PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ Command
3259 dsl 19 0 103m 37m 7780 S 39.5 7.9 0:32.26 homedisplay
3261 dsl 9 0 103m 37m 7780 S 0.3 7.9 0:00.09 homedisplay
3260 dsl 9 0 103m 37m 7780 S 0.0 7.9 0:00.00 homedisplay
3262 dsl 9 0 103m 37m 7780 S 0.0 7.9 0:00.00 homedisplay
3263 dsl 9 0 103m 37m 7780 S 0.0 7.9 0:00.01 homedisplay[/code:2admb3y7]
The first thread is not fmod but my own working thread. One of the other threads is fmod (probably the second thread), but as you can see they are almost using no CPU at all because FMOD is not playing any sound in this case.

Now, I recompiled my program (no code has been changed) with 4.03.07, ran it and got:
[code:2admb3y7] PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ Command
3303 dsl 18 0 104m 38m 8428 R 45.4 8.2 0:04.39 homedisplay
3305 dsl 10 0 104m 38m 8428 S 7.2 8.2 0:00.48 homedisplay
3304 dsl 9 0 104m 38m 8428 S 0.0 8.2 0:00.00 homedisplay
3306 dsl 9 0 104m 38m 8428 S 0.0 8.2 0:00.00 homedisplay
3307 dsl 9 0 104m 38m 8428 S 0.0 8.2 0:00.01 homedisplay[/code:2admb3y7]
Again, the first thread is my own working thread. The second thread is fmod and as you can see it is using 7.2% CPU even when not playing any sound as was the case.

I don’t like the fact that the new fmod ex is using 7.5 % cpu when not even playing any sound. Is this a bug or known issue? Can you shed some light on this.

Some more information:
dsl@1[libs]$ uname -a
Linux EIBDSL 2.4.26 #1 SMP Sa Apr 17 19:33:42 CEST 2004 i686 GNU/Linux

I’m using ALSA and the following code to initialize fmod:
[code:2admb3y7]FMOD_RESULT result = FMOD::System_Create(&m_pSystem);
m_pSystem->setStreamBufferSize(4*16384, FMOD_TIMEUNIT_RAWBYTES);

... // check fmodex version

result = m_pSystem->setOutput(FMOD_OUTPUTTYPE_ALSA);
result = m_pSystem->setSpeakerMode(FMOD_SPEAKERMODE_5POINT1);
// m_siMaxNumSounds = 5
result = m_pSystem->init(m_siMaxNumSounds, FMOD_INIT_NORMAL, 0);[/code:2admb3y7](error checking and version checking has been stripped).

I also tried with OSS but got the same result. I also tried to use simple stereo instead of 5.1 and CPU usage went down to 4% which is still quite high for not playing any sound.

The sound card is a Creative Sound Blaster Live.

If you need more information, please let me know.

  • You must to post comments
0
0

I think he means that the CPU usage of your own program’s thread is irrelevant. i.e. the one created by your .exe. He didn’t mean that the FMOD-created threads were irrelevant.

By the way, what are your machine’s specs? CPU usage is relative, after all, to the speed of your processor. On a slower machine, the smallest little things can cause CPU usage to jump up by a few percentage points.

  • You must to post comments
0
0

I made a simple test program (see below) which only initializes FMod but doesn’t play anything and which also uses getCPUUsage(). When I run it I get:

[code:2a6zp89l] PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ Command
3601 dsl 15 0 3056 2744 1936 R 7.6 0.6 0:01.15 soundtest[/code:2a6zp89l]

So 7.6 % CPU Usage.

The program also uses getCPUUsage and the output is:
[code:2a6zp89l]dsl@EIBDSL:~/soundtest$ ./soundtest
caps: 0
init...
FMOD init done.
FMOD Load: dsp=77.7083, stream=0.00480319, update=0, total=77.7131
FMOD Load: dsp=79.8251, stream=2.84374e-05, update=0, total=79.8251
FMOD Load: dsp=79.6511, stream=1.59946e-07, update=0, total=79.6511
FMOD Load: dsp=79.612, stream=9.46964e-10, update=0, total=79.612
FMOD Load: dsp=79.8233, stream=5.60652e-12, update=0, total=79.8233
FMOD Load: dsp=79.8386, stream=3.31935e-14, update=0, total=79.8386
FMOD Load: dsp=91.6737, stream=2.06866e-16, update=0, total=91.6737
FMOD Load: dsp=79.77, stream=1.16352e-18, update=0, total=79.77
FMOD Load: dsp=79.6389, stream=0.00384882, update=0, total=79.6428
FMOD Load: dsp=79.771, stream=0.0158744, update=0, total=79.7868
FMOD Load: dsp=79.804, stream=8.92857e-05, update=0, total=79.8041
FMOD Load: dsp=79.82, stream=5.28618e-07, update=0, total=79.82
FMOD Load: dsp=79.8421, stream=0.0086981, update=0, total=79.8508
FMOD Load: dsp=79.7932, stream=5.14973e-05, update=0, total=79.7933
FMOD Load: dsp=79.6301, stream=2.89646e-07, update=0, total=79.6301
FMOD Load: dsp=80.0333, stream=1.71486e-09, update=0, total=80.0333[/code:2a6zp89l]

The program:
[code:2a6zp89l]

include "fmod.hpp"

include "fmod_errors.h"

include <iostream>

using namespace std;

void ERRCHECK(FMOD_RESULT result, const char* pszURL = NULL)
{
if (result != FMOD_OK)
{
if (pszURL)
cout << "FMOD error " << result << ": " << FMOD_ErrorString(result) << "(" << pszURL << ")" << endl;
else
cout << "FMOD error " << result << ": " << FMOD_ErrorString(result) << endl;
}
}

int main()
{
FMOD::System* m_pSystem;

    FMOD_RESULT result = FMOD::System_Create(&amp;m_pSystem);
    ERRCHECK(result);
    m_pSystem-&gt;setStreamBufferSize(4*16384, FMOD_TIMEUNIT_RAWBYTES);

    unsigned int version;
    result = m_pSystem-&gt;getVersion(&amp;version);
    ERRCHECK(result);

    if (version &lt; FMOD_VERSION)
    {
      cout &lt;&lt; &quot;FMOD Error! You are using an old version of FMOD &quot; &lt;&lt; version &lt;&lt; &quot;. This program requires &quot; &lt;&lt; FMOD_VERSION &lt;&lt; &quot;.&quot;;
      return 1;
    }

    result = m_pSystem-&gt;setOutput(FMOD_OUTPUTTYPE_ALSA);
    ERRCHECK(result);

    result = m_pSystem-&gt;setSpeakerMode(FMOD_SPEAKERMODE_5POINT1);
    ERRCHECK(result);

    FMOD_CAPS caps = 0;
    m_pSystem-&gt;getDriverCaps(0, &amp;caps, 0, 0, 0);
    int iii = caps;
    cout &lt;&lt; &quot;caps: &quot; &lt;&lt; iii &lt;&lt; endl;
    if (caps &amp; FMOD_CAPS_HARDWARE)
            cout &lt;&lt; &quot;HARDWARE&quot; &lt;&lt; endl;
    if (caps &amp; FMOD_CAPS_HARDWARE_EMULATED)
            cout &lt;&lt; &quot;HARDWARE EMUL&quot; &lt;&lt; endl;;
    if (caps &amp; FMOD_CAPS_OUTPUT_MULTICHANNEL)
            cout &lt;&lt; &quot;OUTPUT MULTICHANNELM&quot; &lt;&lt; endl;

    cout &lt;&lt; &quot;init...&quot; &lt;&lt; endl;
    result = m_pSystem-&gt;init(6, FMOD_INIT_NORMAL, 0);
    ERRCHECK(result);
    cout &lt;&lt; &quot;FMOD init done.&quot; &lt;&lt; endl;

    while (1)
    {
            sleep(2); // sleep for 2 seconds
            float dsp=0, stream=0, update=0, total=0;
            m_pSystem-&gt;getCPUUsage(&amp;dsp, &amp;stream, &amp;update, &amp;total);
            cout &lt;&lt; &quot;FMOD Load: dsp=&quot; &lt;&lt; dsp &lt;&lt; &quot;, stream=&quot; &lt;&lt; stream &lt;&lt; &quot;, update=&quot; &lt;&lt; update &lt;&lt; &quot;, total=&quot; &lt;&lt; total &lt;&lt; endl;
    }

    m_pSystem-&gt;close();
    m_pSystem-&gt;release();
    return 0;

}
[/code:2a6zp89l]
As you can see, the program doesn’t play any sound yet. It only prints the CPU usage every 2 seconds.

  • You must to post comments
0
0

Yes, but I tried the playsound example and it isn’t doing anything and still uses CPU cycles.

The CPU:
[code:qmy6k7rk]dsl@0[proc]$ cat cpuinfo
processor : 0
vendor_id : CentaurHauls
cpu family : 6
model : 7
model name : VIA Samuel 2
stepping : 3
cpu MHz : 599.905
cache size : 64 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 1
wp : yes
flags : fpu de tsc msr cx8 mtrr pge mmx 3dnow
bogomips : 1196.03[/code:qmy6k7rk]

I know it’s not the fastest CPU, but it’s running at 600 MHz and has mmx and 3dnow, but remember, it’s using around 2% CPU when doing virtually nothing (not even playing any sounds).

  • You must to post comments
0
0

Is anyone able to reproduce the above issue?

  • You must to post comments
0
0

That actually sounds about right. I still have a 500 MHz machine in the house and I can tell you that according to task manager, the system uses [i:2n5ewwnf]at least[/i:2n5ewwnf] 2% CPU when doing [b:2n5ewwnf]absolutely nothing[/b:2n5ewwnf]–on a fresh install of Windows. Same goes for any program I run on it: unless the program does nothing but call WaitMessage(), it’s going to use a good chunk of CPU, even if it doesn’t seem to be doing anything intensive.

64 KB is also not a very large cache.

  • You must to post comments
0
0

Noone able to reproduce this behaviour? Should I give more information?

  • You must to post comments
0
0

Do you have any ideas how I can try to lower this CPU usage?
Why is the mixer running when no audio is being played? Can I pause the mixer manually?

  • You must to post comments
0
0

Hi,

i will try it, when i will have time (after 09.05.2006). But i also have noticed, that the new fmod versions waste more performance than the older versions. But i dont tested it like you, but i will.

Have you tried the latest version (4.04.09)?

  • You must to post comments
0
0

Hi,

i will try it, when i will have time (after 09.05.2006). But i also have noticed, that the new fmod versions waste more performance than the older versions. But i dont tested it like you, but i will.

Have you tried the latest version (4.03.09)?

  • You must to post comments
0
0

Thank you.
I haven’t yet tested it with 4.03.09. I’ll try it with the new version.

  • You must to post comments
0
0

Hi,

I have been comparing the linux code from this revision to 4.01.05 and couldn’t find anything that would cause a major change in CPU usage. I did find that the older version wasn’t timing the alsa write blocking function whereas the new version was, which would explain the high DSP value in getCPUUsage, this has been fixed now.

I ran the playsound example on our linux box, and the CPU usage seems to be fine:

[code:3do22h5b]
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
8484 root 15 0 26836 2736 4152 S 0.0 1.1 0:00.03 playsound
8485 root -91 0 26836 2736 4152 S 0.0 1.1 0:00.14 playsound
8486 root -91 0 26836 2736 4152 S 0.0 1.1 0:00.00 playsound

[/code:3do22h5b]

Have u tried checking out what your cpu values are just running the playsound example?

  • You must to post comments
0
0

I just tried the PlaySound example and I get the following results:
[code:2gx6w0le] PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ Command
3072 dsl 16 0 2648 2640 1760 S 2.6 0.5 0:01.47 playsound[/code:2gx6w0le]
When playsound isn’t doing anything:

[code:2gx6w0le]dsl@0[test]$ ./playsound

PlaySound Example. Copyright (c) Firelight Technologies 2004-2005.

Press ‘1’ to Play a mono sound using software mixing
Press ‘2’ to Play a mono sound using software mixing
Press ‘3’ to Play a stereo sound using software mixing
Press ‘Esc’ to quit

Time 00:00:00/00:00:00 : Stopped : Channels Playing 0
[/code:2gx6w0le]
This is with the new libfmodex.so.4.03.09

The CPU usage is less than in my program, probably because playsound isn’t using 5point1.

  • You must to post comments
0
0

Are you looking at the CPU usage of the main thread (i’m not sure because you only posted one PID), what is the CPU usage of the two other threads playsound would have spawned? The CPU usage of the main thread is irrelevant.

  • You must to post comments
0
0

Why do you say that the CPU usage of the main thread of playsound is irrelevant? It isn’t doing anything, yet it’s consuming CPU cycles.

When not playing anything in playsound:
[code:270rsv1f] PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ Command
3208 dsl 15 0 2652 2644 1764 R 2.6 0.5 0:01.99 playsound
3206 dsl 9 0 2652 2644 1764 S 0.0 0.5 0:00.09 playsound
3207 dsl 9 0 2652 2644 1764 S 0.0 0.5 0:00.00 playsound
3209 dsl 9 0 2652 2644 1764 S 0.0 0.5 0:00.00 playsound[/code:270rsv1f]

When pressing ‘3’ to play a stereo sound in playsound:
[code:270rsv1f] PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ Command
3208 dsl 19 0 2700 2692 1788 S 3.9 0.6 0:03.74 playsound
3206 dsl 9 0 2700 2692 1788 S 0.0 0.6 0:00.09 playsound
3207 dsl 9 0 2700 2692 1788 S 0.0 0.6 0:00.00 playsound
3209 dsl 9 0 2700 2692 1788 S 0.0 0.6 0:00.00 playsound[/code:270rsv1f]

  • You must to post comments
Showing 14 results
Your Answer

Please first to submit.