BREW multitreading | developer.brewmp.com BREW multitreading | developer.brewmp.com

Developer

BREW multitreading

Forums:

BREW does not support multiple thread....
But one can do co operative multitasking....

my question is....

i'm developing video application...for video without audio i'm getting nearly 3fps on VX 6000...now i want to incorporate audio....3fps means i need audio of 333ms in between two frames...and i'm planning to use qcp....

now point is if i display a frame and then i have to put audio.... it will take full 333ms to play and then only i can show next frame....

so i want to know is it possible to give life like video with proper audio synchronizationon brew phone...

sdg

You can have cooperative multithreading. From BREW 2.1 onwards there is even IThread to do cooperative multithreading. It works.
ruben

You can have cooperative multithreading. From BREW 2.1 onwards there is even IThread to do cooperative multithreading. It works.
ruben

thanks ruben....
but the problem is still not solved...see this is what i'm trying to do...
///////////////////////
decode frame and display
//////
play audio
//////
go back and do decoding
/////////////////////////
since playing audio will take some finite time the decoding will not start untill the audio stops.....
now how to make these two things work together i.e. the audio will in backgroud and the decoding is also started....
thanks
sdg:confused:

thanks ruben....
but the problem is still not solved...see this is what i'm trying to do...
///////////////////////
decode frame and display
//////
play audio
//////
go back and do decoding
/////////////////////////
since playing audio will take some finite time the decoding will not start untill the audio stops.....
now how to make these two things work together i.e. the audio will in backgroud and the decoding is also started....
thanks
sdg:confused:

I would recommend using IThread interface (available from BREW 2.1 onwards), which will make life little easier, and code will be little more managable.
1. At the start of your application, start your main timer thread, which will do only playback of audio and display video.
2. You also should start, a thread calling ITHREAD_Start, specifying start function. In the start function, set up thread local storage and start thread loop.
3. The thread created in step 2 would do only data decoding for you.
4. Please note that you cann't run your data decoding thread continuously. Don't exit your data decoding thread, untill you finish playing back all the frames. Once you stop IThread you cann't restart the same one, ofcourse you can start a new one though.
ruben

I would recommend using IThread interface (available from BREW 2.1 onwards), which will make life little easier, and code will be little more managable.
1. At the start of your application, start your main timer thread, which will do only playback of audio and display video.
2. You also should start, a thread calling ITHREAD_Start, specifying start function. In the start function, set up thread local storage and start thread loop.
3. The thread created in step 2 would do only data decoding for you.
4. Please note that you cann't run your data decoding thread continuously. Don't exit your data decoding thread, untill you finish playing back all the frames. Once you stop IThread you cann't restart the same one, ofcourse you can start a new one though.
ruben

Quote:Originally posted by sdg
thanks ruben....
but the problem is still not solved...see this is what i'm trying to do...
///////////////////////
decode frame and display
//////
play audio
//////
go back and do decoding
/////////////////////////
since playing audio will take some finite time the decoding will not start untill the audio stops.....
now how to make these two things work together i.e. the audio will in backgroud and the decoding is also started....
thanks
sdg:confused:
As far as I can tell, the actual playing of audio takes place on another thread automatically.
You regain context through the callbacks that tell you when the audio is done playing, when a tick has occured, etc.
So you could do some work on your own timer (decode a bit, check done flag, decode a bit more, etc). Or even at every tick - without interrupting the audio.
There would be no guaranteeing you would finish the decoding before the previous bit of stream ends, but I guess that is up to you to make the decoding fast enough.

Quote:Originally posted by sdg
thanks ruben....
but the problem is still not solved...see this is what i'm trying to do...
///////////////////////
decode frame and display
//////
play audio
//////
go back and do decoding
/////////////////////////
since playing audio will take some finite time the decoding will not start untill the audio stops.....
now how to make these two things work together i.e. the audio will in backgroud and the decoding is also started....
thanks
sdg:confused:
As far as I can tell, the actual playing of audio takes place on another thread automatically.
You regain context through the callbacks that tell you when the audio is done playing, when a tick has occured, etc.
So you could do some work on your own timer (decode a bit, check done flag, decode a bit more, etc). Or even at every tick - without interrupting the audio.
There would be no guaranteeing you would finish the decoding before the previous bit of stream ends, but I guess that is up to you to make the decoding fast enough.

Hi
What u can do is start audio, once the buffer read for audio is complete , u get a callback , decode the video & display them @ whatever rate u want it in a loop or using timer callback.
U can control the video rate as u want either 15/10/5 fps.
But audio will be played as it is encoded. So u need to just encode the audio properly & play it. Since there is no concept of streaming audio frames one by one in brew 2.0 we cant control the audio.
U have to provide audio in one step.
I hope that solves ur problem.
Aysha

Hi
What u can do is start audio, once the buffer read for audio is complete , u get a callback , decode the video & display them @ whatever rate u want it in a loop or using timer callback.
U can control the video rate as u want either 15/10/5 fps.
But audio will be played as it is encoded. So u need to just encode the audio properly & play it. Since there is no concept of streaming audio frames one by one in brew 2.0 we cant control the audio.
U have to provide audio in one step.
I hope that solves ur problem.
Aysha

this is what i have obseved on emulator...
i've tried both Time Callback and RegisterNotify to switch between decoding/displaying frame and audio.... and i found that the stack size goes on increasing and emulator hangs after some time...also the sound heard on emulator is non-continuous....
i want to know that is QCP playback non blocking... i.e. is it played on other thread ....
also so far what is success in implementing video codec on BREW (third party not mpeg4 which BREW is supporting)...
sdg

this is what i have obseved on emulator...
i've tried both Time Callback and RegisterNotify to switch between decoding/displaying frame and audio.... and i found that the stack size goes on increasing and emulator hangs after some time...also the sound heard on emulator is non-continuous....
i want to know that is QCP playback non blocking... i.e. is it played on other thread ....
also so far what is success in implementing video codec on BREW (third party not mpeg4 which BREW is supporting)...
sdg

The emulator and the phone behave VERY differently where sound is concerned. The same can often be said handset to handset. I have had to make many handset specific changes to code where sound is concerned.

The emulator and the phone behave VERY differently where sound is concerned. The same can often be said handset to handset. I have had to make many handset specific changes to code where sound is concerned.

There are certain features which is relatively difficult to emulate, for example sound, file I/O, as these features are depends a lot on hardware.
It is always better to test these features and any kinds of performance related stuff in real device.
ruben

There are certain features which is relatively difficult to emulate, for example sound, file I/O, as these features are depends a lot on hardware.
It is always better to test these features and any kinds of performance related stuff in real device.
ruben

fianaly i got the audio on deivce....and it plays well...without break and surprisingly does not affect frame rate...
but i found following problems with VX6000.... 1)Audio out volume is very low... to hear properly device need to be held very close to ears.... 2) AEECLSID_MEDIAMIDIOUTQCP with ISHELL_CreateInstance is not working.... using this i thought the volume may get better.....
sdg:cool:

fianaly i got the audio on deivce....and it plays well...without break and surprisingly does not affect frame rate...
but i found following problems with VX6000.... 1)Audio out volume is very low... to hear properly device need to be held very close to ears.... 2) AEECLSID_MEDIAMIDIOUTQCP with ISHELL_CreateInstance is not working.... using this i thought the volume may get better.....
sdg:cool:

QCPs play softly on a number of handsets, particularly the LG handsets. According to BREW support, there is no code workaround for this.
With that said, pump up your handset's earpiece (NOT ringer!) volume and you should be able to hear those QCPs.

QCPs play softly on a number of handsets, particularly the LG handsets. According to BREW support, there is no code workaround for this.
With that said, pump up your handset's earpiece (NOT ringer!) volume and you should be able to hear those QCPs.

Quote:Originally posted by sdg
fianaly i got the audio on deivce....and it plays well...without break and surprisingly does not affect frame rate...
but i found following problems with VX6000.... 1)Audio out volume is very low... to hear properly device need to be held very close to ears.... 2) AEECLSID_MEDIAMIDIOUTQCP with ISHELL_CreateInstance is not working.... using this i thought the volume may get better.....
sdg:cool:
Hi, SDG, could you so kind to tell me how do u manage to play audio softly?

Quote:Originally posted by sdg
fianaly i got the audio on deivce....and it plays well...without break and surprisingly does not affect frame rate...
but i found following problems with VX6000.... 1)Audio out volume is very low... to hear properly device need to be held very close to ears.... 2) AEECLSID_MEDIAMIDIOUTQCP with ISHELL_CreateInstance is not working.... using this i thought the volume may get better.....
sdg:cool:
Hi, SDG, could you so kind to tell me how do u manage to play audio softly?

You can have cooperative multithreading.
use ISHELL_SetTimer() ............. avoid tighter loops ...
it works

You can have cooperative multithreading.
use ISHELL_SetTimer() ............. avoid tighter loops ...
it works

thats the answer....

thats the answer....

thx all, I'll try.

thx all, I'll try.