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

Developer

Forums

Forums:

Hello,

my app keeps crashing when I call ISOUNDPLAYER_Stop...

I create the soundplayer instance, register callback to null, call ISOUNDPLAYER_Set with SDT_FILE and the name of the file, start playing midi tune with ISOUNDPLAYER_Play. I hear the song playing, then I call cleanup which has _Stop and _Release.

But when the app gets to Stop it crashes... I've looked at the past messages on the board but haven't found the answer yet...

Is it happenning in emulator or device? If it is happenning in emulator, post your debug log.
ruben

Is it happenning in emulator or device? If it is happenning in emulator, post your debug log.
ruben

try using ISOUNDPLAYER_SetInfo() instead of ISOUNDPLAYER_Set()
Thanks

try using ISOUNDPLAYER_SetInfo() instead of ISOUNDPLAYER_Set()
Thanks

The problem is happenning in the emulator only. But I also have a problem on the device.
I start a midi tune, then I want to start another so I call ISOUNDPLAYER_Stop then the following line I call ISOUNDPLAYER_SetInfo and then ISOUNDPLAYER_Play. But the play doesn't work, the first tune stops but the second one doesn't start.... (on both emulator and device)
Can I do that? Calling setinfo or play right after the stop or do I have to wait for the stop to send me a AEE_SOUNDPLAYER_DONE in order to start the next tune?

The problem is happenning in the emulator only. But I also have a problem on the device.
I start a midi tune, then I want to start another so I call ISOUNDPLAYER_Stop then the following line I call ISOUNDPLAYER_SetInfo and then ISOUNDPLAYER_Play. But the play doesn't work, the first tune stops but the second one doesn't start.... (on both emulator and device)
Can I do that? Calling setinfo or play right after the stop or do I have to wait for the stop to send me a AEE_SOUNDPLAYER_DONE in order to start the next tune?

What you are experiencing is a common problem. You can't do that. You need to revert control back to the OS at least once before you can start a new track.

What you are experiencing is a common problem. You can't do that. You need to revert control back to the OS at least once before you can start a new track.

Ok, i converted my sound object with a messaging system so that if I ask for a second play, and it's already playing a tune, it'll stop the tune, wait for the DONE message, then start the next one. It now works beautifully in the emulator without any memory leaks or crashes... but not on the phone... on the phone, the first tune starts, then, when the second one is supposed to start, nothing happens...
Have you guys had any luck with the logger? I read someplace that we can put dbg msgs in the code and have them output in the logger? I haven't had any luck getting it to work, any advice?

Ok, i converted my sound object with a messaging system so that if I ask for a second play, and it's already playing a tune, it'll stop the tune, wait for the DONE message, then start the next one. It now works beautifully in the emulator without any memory leaks or crashes... but not on the phone... on the phone, the first tune starts, then, when the second one is supposed to start, nothing happens...
Have you guys had any luck with the logger? I read someplace that we can put dbg msgs in the code and have them output in the logger? I haven't had any luck getting it to work, any advice?

You're still not there. After you get the DONE message you will have to wait for at least one more tick and then start the next tune. Right now, you're essentially starting the tune immediately when it ends without giving control back to the OS between the end and the restart.
As for the logger, yes it works. All you have to do is use DBGPRINTF and you will have logger output. Beware though, that the use of DBGPRINTF will slow down your code significantly on a number of phones.

You're still not there. After you get the DONE message you will have to wait for at least one more tick and then start the next tune. Right now, you're essentially starting the tune immediately when it ends without giving control back to the OS between the end and the restart.
As for the logger, yes it works. All you have to do is use DBGPRINTF and you will have logger output. Beware though, that the use of DBGPRINTF will slow down your code significantly on a number of phones.

Thanks for the info. I'll try it right now.
I read somewhere on this forum that the logger doesn't work on the VX6000... search for logger... have you had any change getting it to work on this device?

Thanks for the info. I'll try it right now.
I read somewhere on this forum that the logger doesn't work on the VX6000... search for logger... have you had any change getting it to work on this device?

I think I was already there...
In my callback, when I got the done, I set a flag, and then on the next frame, when my update sound gets called, I call the setinfo and play.. so the OS probably had time to take care of the messages...
On my Stop, I've confirmed that I don't get a SUCCESS message, yet the tune stops... and it works beautifully in the emulator...

I think I was already there...
In my callback, when I got the done, I set a flag, and then on the next frame, when my update sound gets called, I call the setinfo and play.. so the OS probably had time to take care of the messages...
On my Stop, I've confirmed that I don't get a SUCCESS message, yet the tune stops... and it works beautifully in the emulator...

Here's on older version of my sound implementation
//
// SOUNDBREW.CPP
//
// Author: He
// Date: 04/14/2003
//
// This file contains the routines to play back sound on BREW
// platforms.
//
#include "stdafx.h"
ASSERTFILE( __FILE__ );
// SoundInit
//--------------------------------------
// Initialize the sound player
//
G3bool
SoundInit( applet *curApp )
{
G3bool retFlag = FALSE;
curApp->Sound = NULL;
ISHELL_CreateInstance( curApp->a.m_pIShell, AEECLSID_SOUNDPLAYER, (void **)&curApp->Sound );
if ( NULL != curApp->Sound )
{
curApp->SoundInfo = new AEESoundPlayerInfo;
if ( NULL != curApp->SoundInfo )
{
curApp->SoundInfo->eInput = SDT_BUFFER;
curApp->SoundInfo->pData = new G3byte[ 4000 ];
if ( NULL != curApp->SoundInfo->pData )
{
retFlag = TRUE;
}
}
}
return retFlag;

// SoundExit
//--------------------------------------
// Shut down the sound engine and clean
// up the buffers.
//
void
SoundExit( applet *curApp )
{
if ( NULL != curApp->Sound )
{
ISOUNDPLAYER_Release( curApp->Sound );
curApp->Sound = NULL;
}
if ( NULL != curApp->SoundInfo )
{
delete curApp->SoundInfo->pData;
delete curApp->SoundInfo;
}

// SoundSuspend
//--------------------------------------
// When an external call comes in we
// need to suspend the sound player.
//
void
SoundSuspend( applet *curApp )
{
if ( NULL != curApp->Sound )
{
ISOUNDPLAYER_Stop( curApp->Sound );
}

// SoundResume
//--------------------------------------
// Once the call is over, we simply
// continue where we left off.
//
void
SoundResume( applet *curApp )
{
if ( NULL != curApp->Sound && TRUE != curApp->SoundToggle )
{
ISOUNDPLAYER_Play( curApp->Sound );
}

// StartTrack
//--------------------------------------
// Play back a track from a file.
// If loopFlg is TRUE, the track will
// be looped continuously. Otherwise it will
// be played as a single-shot.
//
G3bool
StartTrack( applet *curApp, G3word trackName, G3bool loopFlag )
{
G3bool success = FALSE;
G3word length;
if ( NULL != curApp->Sound && TRUE != curApp->SoundToggle )
{
StopTrack( curApp );
LoadDataResource( curApp, trackName, curApp->SoundInfo->pData, &length );
curApp->SoundInfo->dwSize = length;
ISOUNDPLAYER_SetInfo( curApp->Sound, curApp->SoundInfo );
if ( TRUE == loopFlag )
{
ISOUNDPLAYER_RegisterNotify( curApp->Sound, (PFNSOUNDPLAYERSTATUS) SoundLoopCallback, (void *) curApp );
}
ISOUNDPLAYER_Play( curApp->Sound );
success = TRUE;
}
return success;

// StopTrack
//--------------------------------------
// Stop playback of the current track.
//
void
StopTrack( applet *curApp )
{
if ( NULL != curApp->Sound )
{
ISOUNDPLAYER_Stop( curApp->Sound );
ISOUNDPLAYER_RegisterNotify( curApp->Sound, NULL, NULL ); // Prevent legacy callbacks
}

static void
SoundTrigger( void *userPtr )
{
applet *curApp = (applet *)userPtr;
if ( NULL != curApp->Sound && TRUE != curApp->SoundToggle )
{
ISOUNDPLAYER_RegisterNotify( curApp->Sound, (PFNSOUNDPLAYERSTATUS) SoundLoopCallback, (void *) curApp );
ISOUNDPLAYER_Play( curApp->Sound );
}

// SoundLoopCallback
//--------------------------------------
// This is the callback function that
// makes sure a track is restarted once
// it has completed playback.
//
void
SoundLoopCallback( void *userData, AEESoundCmd cmd, AEESoundStatus status, uint32 para )
{
applet *curApp = (applet *)userData;
para = 0; // Just to avoid a WARNING C4100, unreferenced parameter
Assert( NULL != userData ); // Make sure we have a valid callback here
if ( AEE_SOUNDPLAYER_PLAY_CB == cmd )
{
if ( AEE_SOUNDPLAYER_DONE == status ) // If the sound is finished,
{
ISOUNDPLAYER_Stop( curApp->Sound ); // simply restart it
// Create a really short timer that will then
// trigger a restart of the MIDI track.
//
// Sadly we can't just STOP and START them - another BREW glitch. :-(
//
ISHELL_SetTimer( curApp->a.m_pIShell, 1, SoundTrigger, (void *)curApp );
}
}

This works on all handsets I've come across. Hope it helps.

Here's on older version of my sound implementation
//
// SOUNDBREW.CPP
//
// Author: He
// Date: 04/14/2003
//
// This file contains the routines to play back sound on BREW
// platforms.
//
#include "stdafx.h"
ASSERTFILE( __FILE__ );
// SoundInit
//--------------------------------------
// Initialize the sound player
//
G3bool
SoundInit( applet *curApp )
{
G3bool retFlag = FALSE;
curApp->Sound = NULL;
ISHELL_CreateInstance( curApp->a.m_pIShell, AEECLSID_SOUNDPLAYER, (void **)&curApp->Sound );
if ( NULL != curApp->Sound )
{
curApp->SoundInfo = new AEESoundPlayerInfo;
if ( NULL != curApp->SoundInfo )
{
curApp->SoundInfo->eInput = SDT_BUFFER;
curApp->SoundInfo->pData = new G3byte[ 4000 ];
if ( NULL != curApp->SoundInfo->pData )
{
retFlag = TRUE;
}
}
}
return retFlag;

// SoundExit
//--------------------------------------
// Shut down the sound engine and clean
// up the buffers.
//
void
SoundExit( applet *curApp )
{
if ( NULL != curApp->Sound )
{
ISOUNDPLAYER_Release( curApp->Sound );
curApp->Sound = NULL;
}
if ( NULL != curApp->SoundInfo )
{
delete curApp->SoundInfo->pData;
delete curApp->SoundInfo;
}

// SoundSuspend
//--------------------------------------
// When an external call comes in we
// need to suspend the sound player.
//
void
SoundSuspend( applet *curApp )
{
if ( NULL != curApp->Sound )
{
ISOUNDPLAYER_Stop( curApp->Sound );
}

// SoundResume
//--------------------------------------
// Once the call is over, we simply
// continue where we left off.
//
void
SoundResume( applet *curApp )
{
if ( NULL != curApp->Sound && TRUE != curApp->SoundToggle )
{
ISOUNDPLAYER_Play( curApp->Sound );
}

// StartTrack
//--------------------------------------
// Play back a track from a file.
// If loopFlg is TRUE, the track will
// be looped continuously. Otherwise it will
// be played as a single-shot.
//
G3bool
StartTrack( applet *curApp, G3word trackName, G3bool loopFlag )
{
G3bool success = FALSE;
G3word length;
if ( NULL != curApp->Sound && TRUE != curApp->SoundToggle )
{
StopTrack( curApp );
LoadDataResource( curApp, trackName, curApp->SoundInfo->pData, &length );
curApp->SoundInfo->dwSize = length;
ISOUNDPLAYER_SetInfo( curApp->Sound, curApp->SoundInfo );
if ( TRUE == loopFlag )
{
ISOUNDPLAYER_RegisterNotify( curApp->Sound, (PFNSOUNDPLAYERSTATUS) SoundLoopCallback, (void *) curApp );
}
ISOUNDPLAYER_Play( curApp->Sound );
success = TRUE;
}
return success;

// StopTrack
//--------------------------------------
// Stop playback of the current track.
//
void
StopTrack( applet *curApp )
{
if ( NULL != curApp->Sound )
{
ISOUNDPLAYER_Stop( curApp->Sound );
ISOUNDPLAYER_RegisterNotify( curApp->Sound, NULL, NULL ); // Prevent legacy callbacks
}

static void
SoundTrigger( void *userPtr )
{
applet *curApp = (applet *)userPtr;
if ( NULL != curApp->Sound && TRUE != curApp->SoundToggle )
{
ISOUNDPLAYER_RegisterNotify( curApp->Sound, (PFNSOUNDPLAYERSTATUS) SoundLoopCallback, (void *) curApp );
ISOUNDPLAYER_Play( curApp->Sound );
}

// SoundLoopCallback
//--------------------------------------
// This is the callback function that
// makes sure a track is restarted once
// it has completed playback.
//
void
SoundLoopCallback( void *userData, AEESoundCmd cmd, AEESoundStatus status, uint32 para )
{
applet *curApp = (applet *)userData;
para = 0; // Just to avoid a WARNING C4100, unreferenced parameter
Assert( NULL != userData ); // Make sure we have a valid callback here
if ( AEE_SOUNDPLAYER_PLAY_CB == cmd )
{
if ( AEE_SOUNDPLAYER_DONE == status ) // If the sound is finished,
{
ISOUNDPLAYER_Stop( curApp->Sound ); // simply restart it
// Create a really short timer that will then
// trigger a restart of the MIDI track.
//
// Sadly we can't just STOP and START them - another BREW glitch. :-(
//
ISHELL_SetTimer( curApp->a.m_pIShell, 1, SoundTrigger, (void *)curApp );
}
}

This works on all handsets I've come across. Hope it helps.

Thanks for the help. I'm now managed to know that I get a AEE_SOUNDPLAYER_ABORTED after the stop but only on the device. I'm progressing!!.. Even seen that message?

Thanks for the help. I'm now managed to know that I get a AEE_SOUNDPLAYER_ABORTED after the stop but only on the device. I'm progressing!!.. Even seen that message?

YESSS !!!
Ok, on a VX6000, after a Stop, I receive an ABORTED msg. I checked out some msgs on the forums and some phones send this msg then a SUCCESS.. but on the VX6000, I only get an ABORTED... so I reflag my sound in the aborted msg, and on the next update, sure enough my sound starts.
Thanks for all your help!

YESSS !!!
Ok, on a VX6000, after a Stop, I receive an ABORTED msg. I checked out some msgs on the forums and some phones send this msg then a SUCCESS.. but on the VX6000, I only get an ABORTED... so I reflag my sound in the aborted msg, and on the next update, sure enough my sound starts.
Thanks for all your help!

ISHELL_LoadResData(currapp->m_pIShell,//Pointer to the IShell Interface object.
LOTUS_RES_FILE,//Resource file containing the data.
sequenceName,//ID of the data in the resource file.
RESTYPE_BINARY);//The type of resource:
i am trying to load a mid file from .bar file, have added the files in the image tab,of the resource editor, but the above api returns null,
can anyone especially dragon help me out please,
thanks in advance.
regards,
Mujeeb.

ISHELL_LoadResData(currapp->m_pIShell,//Pointer to the IShell Interface object.
LOTUS_RES_FILE,//Resource file containing the data.
sequenceName,//ID of the data in the resource file.
RESTYPE_BINARY);//The type of resource:
i am trying to load a mid file from .bar file, have added the files in the image tab,of the resource editor, but the above api returns null,
can anyone especially dragon help me out please,
thanks in advance.
regards,
Mujeeb.

Try this instead...
temp = ISHELL_LoadResDataEx( curApp->a.m_pIShell, RES_FILE_NAME, (uint16)resID, RESTYPE_IMAGE, NULL, (uint32 *)&resSize );
That will work, if the file you're trying to load really is in the bar file.

Try this instead...
temp = ISHELL_LoadResDataEx( curApp->a.m_pIShell, RES_FILE_NAME, (uint16)resID, RESTYPE_IMAGE, NULL, (uint32 *)&resSize );
That will work, if the file you're trying to load really is in the bar file.

hi :) ,
On LGEVX 6000 if my music is paused by incoming call or alarm and after attending the call or alarm if i try to resume it back it is not happening,
i tried to track down the callback events, i couldnt beleive that it is aborted message which is fired, after the pause is called,
and another thing which i have noticed is if i ignore the alarm the sound is resuming and aborted message is not called to the callback,
if the incoming call or alarm is firing some music then the aborted message is fired for the callback, making it unable to resume.which is a true brew requierement.
can you suggest what the remidy could be for this,
thanks,
Mujeeb.

hi :) ,
On LGEVX 6000 if my music is paused by incoming call or alarm and after attending the call or alarm if i try to resume it back it is not happening,
i tried to track down the callback events, i couldnt beleive that it is aborted message which is fired, after the pause is called,
and another thing which i have noticed is if i ignore the alarm the sound is resuming and aborted message is not called to the callback,
if the incoming call or alarm is firing some music then the aborted message is fired for the callback, making it unable to resume.which is a true brew requierement.
can you suggest what the remidy could be for this,
thanks,
Mujeeb.