Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

Why after some time timer is slow down

probably going into a "sleep" mode, if you dont press any buttons within a duration of time (such as 30 seconds)..
to avoid this, catch the EVT_APP_NO_SLEEP event and return TRUE;
-Tyndal

probably going into a "sleep" mode, if you dont press any buttons within a duration of time (such as 30 seconds)..
to avoid this, catch the EVT_APP_NO_SLEEP event and return TRUE;
-Tyndal

You could get more information about this at the BREW FAQs page under Media - Display and Images.

You could get more information about this at the BREW FAQs page under Media - Display and Images.

HI ,
I have a problem with timer,may be i didn't understand the use of timers properly...
I have a game which loads a lot of pngs and play's a lot of Sound Fx based on events. I play a background music and when a soundFx is to happen , i stop the bg music and start the sfx, and after the sfx finishes i restart the music. (all the sound files are midis)
The problem i'm facing is that the whole program runs wonderfully in the emulator (it should :) ) , but when taken to device there is a huge drop in the speed.. and over that the sounds fx to be played at the event is not getting played. It stops the bg music for a breif second and then it waits for playing the sound Fx , and restarts the bg music (which is supposed to happen after the fx is played). which means the fx sounds are not getting played at that time!! is there any reason for that ??? i am giving a SetTimer(1) for every sound to start (including the bg music, same as how Dragon uses to loop the midis).
I tried my main looper to with differnt values of SetTimerEx(59), SetTimerEx(120),SetTimerEx(20) . but the everything delays the run of the game on device.
Any pointers would help, hope i am not confussing here ... :)

HI ,
I have a problem with timer,may be i didn't understand the use of timers properly...
I have a game which loads a lot of pngs and play's a lot of Sound Fx based on events. I play a background music and when a soundFx is to happen , i stop the bg music and start the sfx, and after the sfx finishes i restart the music. (all the sound files are midis)
The problem i'm facing is that the whole program runs wonderfully in the emulator (it should :) ) , but when taken to device there is a huge drop in the speed.. and over that the sounds fx to be played at the event is not getting played. It stops the bg music for a breif second and then it waits for playing the sound Fx , and restarts the bg music (which is supposed to happen after the fx is played). which means the fx sounds are not getting played at that time!! is there any reason for that ??? i am giving a SetTimer(1) for every sound to start (including the bg music, same as how Dragon uses to loop the midis).
I tried my main looper to with differnt values of SetTimerEx(59), SetTimerEx(120),SetTimerEx(20) . but the everything delays the run of the game on device.
Any pointers would help, hope i am not confussing here ... :)

* * Bump * *
Any one who can point me to some driections ?? :)

* * Bump * *
Any one who can point me to some driections ?? :)

the emulator doesnt mimic the speed of an actual handset at all, so dont expect similar speeds.
performance varies by handset.. there are lots of threads on games and timers in the forums.. there is also lots of threads on sound.. and games and sound.
search through the forums.
http://brewforums.qualcomm.com/search.php?s=
-Tyndal

the emulator doesnt mimic the speed of an actual handset at all, so dont expect similar speeds.
performance varies by handset.. there are lots of threads on games and timers in the forums.. there is also lots of threads on sound.. and games and sound.
search through the forums.
http://brewforums.qualcomm.com/search.php?s=
-Tyndal

HI Tyndal,
I did search first before even writing the post, as a goldern rule i do that. but i poseted it because i didn't get the info which can point me to the problem i have, so thats the reason, i posted it here. I even tried EVT_APP_NO_SLEEP as u mentioned in the post, still there is no imporvement, so there is some other thing which is troubling here.
and i'm not getting the right search results :(
I'm using Dragon's code as my base code to play sounds,
And it plays the back ground midi, loops it perfect, and the code is written such a way that, when there is a even occured which needs a Sound Fx to be played, it stops the music, plays the sound Fx and continues back with the back ground music, but the problem happens when playing these sound Fx, it closes the music, but doesn't play the sound Fx , waits for 1 second and restarts the music (without playing the sound Fx).
all i am trying to find is why the small sound Fxs are not getting played inbetween the stop/start of music when the event occurs.
can u help me on finding out the possible reasons, i hunted all the fourm on this, but couldn't get the needed :(
I also want to find how can i pre load the sound files in the memory and play it when i need it, instead of loading it and playing it when the event occurs !
thanks a lot in advance:)

HI Tyndal,
I did search first before even writing the post, as a goldern rule i do that. but i poseted it because i didn't get the info which can point me to the problem i have, so thats the reason, i posted it here. I even tried EVT_APP_NO_SLEEP as u mentioned in the post, still there is no imporvement, so there is some other thing which is troubling here.
and i'm not getting the right search results :(
I'm using Dragon's code as my base code to play sounds,
And it plays the back ground midi, loops it perfect, and the code is written such a way that, when there is a even occured which needs a Sound Fx to be played, it stops the music, plays the sound Fx and continues back with the back ground music, but the problem happens when playing these sound Fx, it closes the music, but doesn't play the sound Fx , waits for 1 second and restarts the music (without playing the sound Fx).
all i am trying to find is why the small sound Fxs are not getting played inbetween the stop/start of music when the event occurs.
can u help me on finding out the possible reasons, i hunted all the fourm on this, but couldn't get the needed :(
I also want to find how can i pre load the sound files in the memory and play it when i need it, instead of loading it and playing it when the event occurs !
thanks a lot in advance:)

hi...
are you loading the file from EFS....if yes then try to load it in heap... the sound playing should not create problem to app's performace....
sdg

hi...
are you loading the file from EFS....if yes then try to load it in heap... the sound playing should not create problem to app's performace....
sdg

no , i am loading it from the Resource file, i have stored all the midi's in the BAR file and loading it from them !!

no , i am loading it from the Resource file, i have stored all the midi's in the BAR file and loading it from them !!

hi...
why don't you try this...
read the file & store in heap, and play it from it...
sdg

hi...
why don't you try this...
read the file & store in heap, and play it from it...
sdg

but there is a constrain of verizon that the total number of files in the game should not exceed 8, if i put the sound file sin the directory and not in the bar files, then i will happly exceed that limit ! :(

but there is a constrain of verizon that the total number of files in the game should not exceed 8, if i put the sound file sin the directory and not in the bar files, then i will happly exceed that limit ! :(

Yes, the 8 file limit.
Have you tried containing the file inside the BAR as an image?
It's not an image, I know, but it may work. Then you can call:
ISHELL_LoadResData()
Description:
This function returns a void * data block associated with the
specified resource file, ID, and type. The memory returned must
be freed using ISHELL_FreeResData().
??? This might work.

Yes, the 8 file limit.
Have you tried containing the file inside the BAR as an image?
It's not an image, I know, but it may work. Then you can call:
ISHELL_LoadResData()
Description:
This function returns a void * data block associated with the
specified resource file, ID, and type. The memory returned must
be freed using ISHELL_FreeResData().
??? This might work.

Quote:Originally posted by Sac
HI Tyndal,
all i am trying to find is why the small sound Fxs are not getting played inbetween the stop/start of music when the event occurs.
can u help me on finding out the possible reasons, i hunted all the fourm on this, but couldn't get the needed :(
I also want to find how can i pre load the sound files in the memory and play it when i need it, instead of loading it and playing it when the event occurs !
thanks a lot in advance:)
You need to put dbgprintf statements in your sound callbacks so that you can see what is going on. Most likely there are some failure messages. Don't forget to remove these later as dbgprintf's slow things way down.

Quote:Originally posted by Sac
HI Tyndal,
all i am trying to find is why the small sound Fxs are not getting played inbetween the stop/start of music when the event occurs.
can u help me on finding out the possible reasons, i hunted all the fourm on this, but couldn't get the needed :(
I also want to find how can i pre load the sound files in the memory and play it when i need it, instead of loading it and playing it when the event occurs !
thanks a lot in advance:)
You need to put dbgprintf statements in your sound callbacks so that you can see what is going on. Most likely there are some failure messages. Don't forget to remove these later as dbgprintf's slow things way down.

use LoadResData() to load the sound data into a buffer, create a MemAStream class, and set the memastream data to be the buffer. (you should provide your own callback for freeing the buffer with SetEx ) and use SetStream() to set the MemAStream as the data for IMedia/ISound.
also, which handset(s) are you developing for.. The audio support/limitations vary greatly by handset, and many game developers simply dont use background sounds on some handsets due to limitations.
-Tyndal

use LoadResData() to load the sound data into a buffer, create a MemAStream class, and set the memastream data to be the buffer. (you should provide your own callback for freeing the buffer with SetEx ) and use SetStream() to set the MemAStream as the data for IMedia/ISound.
also, which handset(s) are you developing for.. The audio support/limitations vary greatly by handset, and many game developers simply dont use background sounds on some handsets due to limitations.
-Tyndal

Yes , I use the ISHELL_LoadResData() to load it as a Image and use ISHELL_FreeResData to release the data.
and I did print messages using "dbgprintf" at virtually every possible important state change. but the messages i always got was that "the sound is playing correctly" but i never heard these sound effects
These are the typical prints which i get
"Stopping Music..."
Music stops
"Loading Sounf Fx ID 5430"
"Playing Sounf Fx ID 5430"
There is a one second gap here as this happens after a 1 sec timer, and there is no sound heard
"Loading Music ID 5421"
"Playing Music ID 5421"
Now I can hear the music start again.
Tyndal : I haven't tried using MemAStream class, can u explain me more on this?? and meanwhile i will try to understand what it is.
Btw, the devices i am making it for is LGE VX4400 and LGE VX6000.

Yes , I use the ISHELL_LoadResData() to load it as a Image and use ISHELL_FreeResData to release the data.
and I did print messages using "dbgprintf" at virtually every possible important state change. but the messages i always got was that "the sound is playing correctly" but i never heard these sound effects
These are the typical prints which i get
"Stopping Music..."
Music stops
"Loading Sounf Fx ID 5430"
"Playing Sounf Fx ID 5430"
There is a one second gap here as this happens after a 1 sec timer, and there is no sound heard
"Loading Music ID 5421"
"Playing Music ID 5421"
Now I can hear the music start again.
Tyndal : I haven't tried using MemAStream class, can u explain me more on this?? and meanwhile i will try to understand what it is.
Btw, the devices i am making it for is LGE VX4400 and LGE VX6000.

Update :
I pre loaded all the sounds at the start and as the events occur, i just do ISOUNDPLAYER_SetInfo(soundplayer, event_sound); and then play it. now i get a small note every time a sound event happens, but still its not playing the whole sound effect.
what i did in preloading is , i loaded all the sounds from Bar to differnt char * buffers as data and set these buffers to differnt SoundPlayerInfos so i can set the right Info struct to the ISoundPLayer for every event.
am I missing something here ??
Tyndal : I still didn't try the MemAStream. thought this might work. can u tell me anything i'm missing here ??
Thanks a lot :)

Update :
I pre loaded all the sounds at the start and as the events occur, i just do ISOUNDPLAYER_SetInfo(soundplayer, event_sound); and then play it. now i get a small note every time a sound event happens, but still its not playing the whole sound effect.
what i did in preloading is , i loaded all the sounds from Bar to differnt char * buffers as data and set these buffers to differnt SoundPlayerInfos so i can set the right Info struct to the ISoundPLayer for every event.
am I missing something here ??
Tyndal : I still didn't try the MemAStream. thought this might work. can u tell me anything i'm missing here ??
Thanks a lot :)

I havent used SetInfo, so i dont know how well it works. For memastream, what have you tried? its not too complicated.
// create memastream instance
ISHELL_CreateInstance()
// set the data
IMEMASTREAM_SetEx()
// set the sound to the stream
ISOUNDPLAYER_SetStream()
-Tyndal

I havent used SetInfo, so i dont know how well it works. For memastream, what have you tried? its not too complicated.
// create memastream instance
ISHELL_CreateInstance()
// set the data
IMEMASTREAM_SetEx()
// set the sound to the stream
ISOUNDPLAYER_SetStream()
-Tyndal

In LGVx6000 phone , if u try to execute many co-operative threads using timers, the whole process will slow-down.
I guess, since u r playing many midi files at the same time using different timers, each one is not getting sufficient CPU cycles to play it contineously ...
Did u tried playing these files serially ....
One way to optimize the performance of these async timer callbacks will be to write them in assembly.
I hope this helps....

In LGVx6000 phone , if u try to execute many co-operative threads using timers, the whole process will slow-down.
I guess, since u r playing many midi files at the same time using different timers, each one is not getting sufficient CPU cycles to play it contineously ...
Did u tried playing these files serially ....
One way to optimize the performance of these async timer callbacks will be to write them in assembly.
I hope this helps....

i think it could be that, because when every sound event happens there is a 1 second timer which calls the sound player with new sound which is to be played. as as the frequency of the events increases there are that many 1 sec. timer getting started. could be because of this. how will i come across this, the sounds can'tr be serial, as it is purly event based sounds.
i don't have knowledge of using asm. can u give me some pointers on it ??

i think it could be that, because when every sound event happens there is a 1 second timer which calls the sound player with new sound which is to be played. as as the frequency of the events increases there are that many 1 sec. timer getting started. could be because of this. how will i come across this, the sounds can'tr be serial, as it is purly event based sounds.
i don't have knowledge of using asm. can u give me some pointers on it ??

Do u wanna play these sounds parallelly..
if not then set the next timer only once the previous one is finished ...
regarding asm U need to write .s files and link them to ur application ...

Do u wanna play these sounds parallelly..
if not then set the next timer only once the previous one is finished ...
regarding asm U need to write .s files and link them to ur application ...

I don't want to play it parallelly, as the device can't play multiplue midis at the same time. I want to play it randomely , one at a time, when the event occurs, and when the sound effect is finished, the background music(again a midi) should resume.

I don't want to play it parallelly, as the device can't play multiplue midis at the same time. I want to play it randomely , one at a time, when the event occurs, and when the sound effect is finished, the background music(again a midi) should resume.

I have experience a Timer Slow down as well with a very simple program.
ISHELL_SetTimer (pMe->m_pIShell , 100, FuncCB, pMe);
FuncCB (void* po)
{
char outbuff[25];
MyApp *app = (MyApp*) po
app->counter++;
SPRINTF(outbuff,"Counter: %i \n", pMe->counter);
DisplayOutput(pMe, 3, outbuff);
ISHELL_SetTimer (pMe->m_pIShell , 100, FuncCB, pMe);
}
At first, the counter goes very fast. After a while the timer slows down to about 1 second or more. And I running this in the emulator.
Maybe this is related to your problem. If you have any tips I would appreciate it as well. I think is what is causing another problem in my app.
Rafael Cortina

I have experience a Timer Slow down as well with a very simple program.
ISHELL_SetTimer (pMe->m_pIShell , 100, FuncCB, pMe);
FuncCB (void* po)
{
char outbuff[25];
MyApp *app = (MyApp*) po
app->counter++;
SPRINTF(outbuff,"Counter: %i \n", pMe->counter);
DisplayOutput(pMe, 3, outbuff);
ISHELL_SetTimer (pMe->m_pIShell , 100, FuncCB, pMe);
}
At first, the counter goes very fast. After a while the timer slows down to about 1 second or more. And I running this in the emulator.
Maybe this is related to your problem. If you have any tips I would appreciate it as well. I think is what is causing another problem in my app.
Rafael Cortina

As noted earlier in the thread, this is probably the sleep mode kicking in - see this FAQ.

As noted earlier in the thread, this is probably the sleep mode kicking in - see this FAQ.

Actually I figured out by repeated testing on the device that using lesser value for time, the speed increases,
ISHELL_SetTimer (pMe->m_pIShell , x, FuncCB, pMe); where X = 10, 15, 25, ... upto 50. anything about this shows a slowdown in the execution, But the given numbers will not work if u are playing sounds, then u need to set this value to 50 or little bit above, or else the sounds will not play. I tried it in Vx6000
I even tested with timer value being 1 and 5 also , but this will be a problem if u are executing a lot of bitmap drawings.
Hope whatever i have found out is correct. atleast i observed these results.

Actually I figured out by repeated testing on the device that using lesser value for time, the speed increases,
ISHELL_SetTimer (pMe->m_pIShell , x, FuncCB, pMe); where X = 10, 15, 25, ... upto 50. anything about this shows a slowdown in the execution, But the given numbers will not work if u are playing sounds, then u need to set this value to 50 or little bit above, or else the sounds will not play. I tried it in Vx6000
I even tested with timer value being 1 and 5 also , but this will be a problem if u are executing a lot of bitmap drawings.
Hope whatever i have found out is correct. atleast i observed these results.