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

Developer

Forums

Forums:

Hi all,

I am using BREW SDK 3.1.2 and currently working on the Motorola V3C hand set.
Right now i am handling the event EVT_APP_STOP and under this event my application got hung while trying to release the IMEDIA pointer. For convenience i am sending out the following stuff which i tried for such a scenario.I am using the stuff for a scenario where i have to exit the application on pressing the End key (Red Key)button. I went through various sections in the forum and i found that we have to release all the resources such as releasing the callback pointers, any network connections or cancelling the timers before exiting the application when we are handling the EVT_APP_STOP event. The stuff is like as below:

case EVT_APP_STOP:
b_result = ISHELL_CloseApplet(pMobileTV->m_AEEApplet.m_pIShell,FALSE);
(*(boolean*)dwParam) = FALSE;
break;

right after this my exit function is being called and over there my application got hung while trying to release the IMEDIA pointer.When i pass "TRUE" in the CloseApplet API then the appliaction is exiting safely but i can still have the media running in the back ground.
Could anybody please give me any kind of suggestions where i am going wrong?

I'm not sure if I understand exactly what you are trying to do, it looks like you want to send your application to the background and continue playing media? Whatever it is, I think part of your problem may be in calling ISHELL_CloseApplet in your EVT_APP_STOP handler. ISHELL_CloseApplet is a BREW function call that will cause the event system to send an EVT_APP_STOP event to your application, so I'm actually surprised that you aren't getting some kind of infinite loop here. You shouldn't really be calling ISHELL_CloseApplet here, as it's more to allow an opportunity to release resources, save settings, and such.

I'm not sure if I understand exactly what you are trying to do, it looks like you want to send your application to the background and continue playing media? Whatever it is, I think part of your problem may be in calling ISHELL_CloseApplet in your EVT_APP_STOP handler. ISHELL_CloseApplet is a BREW function call that will cause the event system to send an EVT_APP_STOP event to your application, so I'm actually surprised that you aren't getting some kind of infinite loop here. You shouldn't really be calling ISHELL_CloseApplet here, as it's more to allow an opportunity to release resources, save settings, and such.

Greg wrote:I'm not sure if I understand exactly what you are trying to do, it looks like you want to send your application to the background and continue playing media? Whatever it is, I think part of your problem may be in calling ISHELL_CloseApplet in your EVT_APP_STOP handler. ISHELL_CloseApplet is a BREW function call that will cause the event system to send an EVT_APP_STOP event to your application, so I'm actually surprised that you aren't getting some kind of infinite loop here. You shouldn't really be calling ISHELL_CloseApplet here, as it's more to allow an opportunity to release resources, save settings, and such.
Hi Greg
Thnx a lot for ur reply.
Actually i am maintaining a state for all of my screens and defining the entry points for all the screens when i am moving from one to another.You are absoulutely right that here the applet will be sent to the background.During debugging when i used to press the end key all the applets on the application stack are popped up one by one and released the resources for the respective screens.
What i need to do here is, let say i am on the fourth screen and playing a video on the same and upon pressing the end key i should exit the appliaction safely without any memory leak. But when i am trying to release the media pointer for the undergoing video the application got hung and also the control is not going to the freeAppData() functions of the rest of the screens which are still on the application stack and for the same i am having a memory leak.
So can u please suggest me what i should do in such a case and what i should do under EVT_APP_STOP? How can i release the memory and exit the application safely?
Thanks in Advance,

Greg wrote:I'm not sure if I understand exactly what you are trying to do, it looks like you want to send your application to the background and continue playing media? Whatever it is, I think part of your problem may be in calling ISHELL_CloseApplet in your EVT_APP_STOP handler. ISHELL_CloseApplet is a BREW function call that will cause the event system to send an EVT_APP_STOP event to your application, so I'm actually surprised that you aren't getting some kind of infinite loop here. You shouldn't really be calling ISHELL_CloseApplet here, as it's more to allow an opportunity to release resources, save settings, and such.
Hi Greg
Thnx a lot for ur reply.
Actually i am maintaining a state for all of my screens and defining the entry points for all the screens when i am moving from one to another.You are absoulutely right that here the applet will be sent to the background.During debugging when i used to press the end key all the applets on the application stack are popped up one by one and released the resources for the respective screens.
What i need to do here is, let say i am on the fourth screen and playing a video on the same and upon pressing the end key i should exit the appliaction safely without any memory leak. But when i am trying to release the media pointer for the undergoing video the application got hung and also the control is not going to the freeAppData() functions of the rest of the screens which are still on the application stack and for the same i am having a memory leak.
So can u please suggest me what i should do in such a case and what i should do under EVT_APP_STOP? How can i release the memory and exit the application safely?
Thanks in Advance,

Did you remove the ISHELL_CloseApplet call from your EVT_APP_STOP handler? You will probably need to fix that first before you will be able to figure out any other problems.

Did you remove the ISHELL_CloseApplet call from your EVT_APP_STOP handler? You will probably need to fix that first before you will be able to figure out any other problems.

Greg wrote:Did you remove the ISHELL_CloseApplet call from your EVT_APP_STOP handler? You will probably need to fix that first before you will be able to figure out any other problems.
Hi Greg
Yes i removed the ISHELL_CloseApplet from the EVT_APP_STOP handler and tried to return FALSE from the event handler. But the application is crashing and the control is going onto the assembly code saying the BREW simulator has triggered a break point if i am not using the IMEDIA_Stop(). Is this due to some kind of memory leaks?
But when i am trying to stop the media under the EVT_APP_STOP handler and returning FALSE then the application got hung. So please suggest me what should i do in such a case?

Greg wrote:Did you remove the ISHELL_CloseApplet call from your EVT_APP_STOP handler? You will probably need to fix that first before you will be able to figure out any other problems.
Hi Greg
Yes i removed the ISHELL_CloseApplet from the EVT_APP_STOP handler and tried to return FALSE from the event handler. But the application is crashing and the control is going onto the assembly code saying the BREW simulator has triggered a break point if i am not using the IMEDIA_Stop(). Is this due to some kind of memory leaks?
But when i am trying to stop the media under the EVT_APP_STOP handler and returning FALSE then the application got hung. So please suggest me what should i do in such a case?

Still i have not found any solution to this.....now i am simply returning from the EVT_APP_STOP with a FALSE value and in freeAppData() the application hangs after IMEDIA_Release() and that is the end of the debugging point in such a case.
I am still roaming to find out a workaround for this.
Could anybody please help me out ????? :rolleyes:

Still i have not found any solution to this.....now i am simply returning from the EVT_APP_STOP with a FALSE value and in freeAppData() the application hangs after IMEDIA_Release() and that is the end of the debugging point in such a case.
I am still roaming to find out a workaround for this.
Could anybody please help me out ????? :rolleyes:

At this point it is pretty tough for us to tell what is wrong without you having to post a ton of code. I guess my suggestion would be first to try doing it without going to the background, so you can tell if it might just be a regular bug in your shutdown routine or if there might be an issue on that phone with background apps. My initial guess would be that you might be releasing IMedia twice or something similar to that, so you would probably check to see if you are NULL-ing things out after you have released them, but it's difficult to tell.

At this point it is pretty tough for us to tell what is wrong without you having to post a ton of code. I guess my suggestion would be first to try doing it without going to the background, so you can tell if it might just be a regular bug in your shutdown routine or if there might be an issue on that phone with background apps. My initial guess would be that you might be releasing IMedia twice or something similar to that, so you would probably check to see if you are NULL-ing things out after you have released them, but it's difficult to tell.

I have not understand your requirement completely, but are you using IMedia_stop before releasing the IMedia. Please use it for safety. Also update on the issue.
Jith Thomas .T

I have not understand your requirement completely, but are you using IMedia_stop before releasing the IMedia. Please use it for safety. Also update on the issue.
Jith Thomas .T

jiththomas wrote:I have not understand your requirement completely, but are you using IMedia_stop before releasing the IMedia. Please use it for safety. Also update on the issue.
Jith Thomas .T
Hello
This is the code snippet for the IMedia pointer
void Exit( void *p)
{
boolean ret;
if (m_pMedia)
{
ret = IMEDIA_Stop(m_pMedia); ///WHEN THE EVENT COMES HERE, IT DOES NOT GO TO THE NEXT STATEMENT AND GETS HUNG.
IMEDIA_RegisterNotify(m_pMedia,MediaNotify,NULL);
IMEDIA_Release(m_pMedia);
m_pMedia = NULL;
}

boolean HandleEvent( void *p, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
case EVT_APP_STOP:
return (TRUE);

Could u tell me the reason for this behaviour :confused:

jiththomas wrote:I have not understand your requirement completely, but are you using IMedia_stop before releasing the IMedia. Please use it for safety. Also update on the issue.
Jith Thomas .T
Hello
This is the code snippet for the IMedia pointer
void Exit( void *p)
{
boolean ret;
if (m_pMedia)
{
ret = IMEDIA_Stop(m_pMedia); ///WHEN THE EVENT COMES HERE, IT DOES NOT GO TO THE NEXT STATEMENT AND GETS HUNG.
IMEDIA_RegisterNotify(m_pMedia,MediaNotify,NULL);
IMEDIA_Release(m_pMedia);
m_pMedia = NULL;
}

boolean HandleEvent( void *p, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
case EVT_APP_STOP:
return (TRUE);

Could u tell me the reason for this behaviour :confused: