aError=-5 in MaoscOpenComplete callback
| Tue, 2005-06-21 12:48 | |
|
Hi All,
I'm trying to implement a an audio repeat functionality on the SE P91oi device through the use of an observer method. The audio repeat works fine the first time but on the 2nd time, I get aError=-5 in the MaoscOpenComplete callback. I tried looking as to what does the panic 5 means in the MaoscOpenComplete callback, but couldn't find out. Any help as to what does this panic code means would be extremely grateful. Thanks & regards, Asheesh |
|






Forum posts: 57
I think it is not a panic code. it is an error code, -5 means "functionality not supported" error.
Explore beyond the limits
Forum posts: 58
Here's how I'm implementing the audio repeat functionality.
Here's my engine code.
#include "CVorbisEngine.h"
CVorbisEngine * CVorbisEngine::NewL()
{
CVorbisEngine* self = new (ELeave) CVorbisEngine;
CleanupStack::PushL( self );
self->ConstructL();
CleanupStack::Pop( self );
return self;
}
void CVorbisEngine::ConstructL()
{
}
//Open the Vorbis file
void CVorbisEngine::OpenFileL(const TDesC8 &aFileName,TInt aNumRepeat)
{
//Check if the previous file was open. If yes, close the previous file
if(iEngineState!=EStreamRepeat)
{
iNumRepeat=aNumRepeat;
iRepAudio=1;
}
if(iFileOpen)
{
ov_clear(&iVf);
iFileOpen=EFalse;
}
//Check if the previous stream was deleted. If not, then delete the previous file.
if(iOutputStream)
{
delete iOutputStream;
iOutputStream=NULL;
}
//Since stream was deleted above, we reopen the stream
if(!iOutputStream)
iOutputStream = CMdaAudioOutputStream::NewL(*this);
FILE * aFile;
char * filename ;
filename = (char *) aFileName.Ptr();
aFile = fopen((char *) aFileName.Ptr() , "r+");
if(ov_open(aFile, &iVf, NULL, 0) < 0) {
User::Leave(KErrNotSupported);
}
iAudioFileName.Zero();
iAudioFileName.Append(aFileName);
vorbis_info *vi=ov_info(&iVf,-1);
iFileOpen=ETrue;
switch(vi->rate)
{
case 8000:
iRate = TMdaAudioDataSettings::ESampleRate8000Hz;
break;
case 11025:
iRate = TMdaAudioDataSettings::ESampleRate11025Hz;
break;
case 16000:
iRate = TMdaAudioDataSettings::ESampleRate16000Hz;
break;
case 22050:
iRate = TMdaAudioDataSettings::ESampleRate22050Hz;
break;
case 32000:
iRate = TMdaAudioDataSettings::ESampleRate32000Hz;
break;
case 44100:
iRate = TMdaAudioDataSettings::ESampleRate44100Hz;
break;
case 48000:
iRate = TMdaAudioDataSettings::ESampleRate48000Hz;
break;
default:
User::Leave(KErrNotSupported);
}
switch(vi->channels)
{
case 1:
iNbChannels = TMdaAudioDataSettings::EChannelsMono;
break;
case 2:
iNbChannels = TMdaAudioDataSettings::EChannelsStereo;
break;
default:
User::Leave(KErrNotSupported);
}
TMdaAudioDataSettings settings;
settings.Query();
// Initialize the Audio Stream
settings.iSampleRate = iRate;
settings.iChannels = iNbChannels;
settings.iVolume = settings.iMaxVolume;
iEngineState=EStreamPrepare;
iOutputStream->Open(&settings);
}
int CVorbisEngine::FillSampleBufferL()
{
// Fill one buffer of PCM samples
int current_section;
TDes8 * bufPtr ;
// Swap buffers
// So that there is always one buffer ready waiting to
// be streamed.
if (iCurrentBuffer == 0)
{
bufPtr = &iPcmout1;
iCurrentBuffer = 1;
}
else
{
bufPtr = &iPcmout2;
iCurrentBuffer = 0;
}
// Decode the ogg file
long ret=ov_read(&iVf,(char *) bufPtr->Ptr(),bufPtr->MaxLength(),¤t_section);
if (ret == 0)
{
iEof=ETrue;
/* EOF */
//EndOfFileL();
}
else if (ret < 0)
{
/* error in the stream. Not a problem, just reporting it in
case we (the app) cares. In this case, we don't. */
}
else
{
/* we don't bother dealing with sample rate changes, etc, but
you'll have to*/
bufPtr->SetLength(ret);
BufferFullL(*bufPtr);
}
return ret;
}
void CVorbisEngine::BufferFullL(TDes8 &aBuffer)
{
// Write the buffer to the audio stream
iEngineState=EStreamPlaying;
iOutputStream->WriteL( aBuffer );
}
CVorbisEngine:: ~CVorbisEngine()
{
if(iOutputStream)
{
delete( iOutputStream );
iOutputStream=NULL;
}
if(iFileOpen)
ov_clear(&iVf);
CloseSTDLIB();
}
/////////////////////////////////////
// Functions used for Audio Streaming
/////////////////////////////////////
void CVorbisEngine::MaoscPlayComplete(TInt aError)
{
if(((aError==KErrUnderflow)||(aError==KErrCancel)) && (iEof=ETrue))
{
StreamCleanup();
if(iNumRepeat==1)
{
iEngineObserver->HandleAudioRepeat(iEngineState,aError,iAudioFileName);
iEngineState=EIdle;
}
else if(iRepAudio<iNumRepeat)
{
iRepAudio+=1;
iEngineState=EStreamRepeat;
iEngineObserver->HandleAudioRepeat(iEngineState,aError,iAudioFileName);
}
else if(iRepAudio==iNumRepeat)
{
iEngineState=EIdle;
iEngineObserver->HandleAudioRepeat(iEngineState,aError,iAudioFileName);
}
}
}
void CVorbisEngine::MaoscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/)
{
if (aError!=KErrNone)
{
if(aError==KErrAbort)
iEngineObserver->HandleAudioRepeat(EStreamInterrupted,aError,iAudioFileName);
else
{
iEngineState=EStreamError;
iEngineObserver->HandleAudioRepeat(iEngineState,aError,iAudioFileName);
}
return;
}
FillSampleBufferL();
}
void CVorbisEngine::MaoscOpenComplete(TInt aError)
{
if (aError)
{
StreamCleanup();
iEngineState=EStreamError;
iEngineObserver->HandleAudioRepeat(iEngineState,aError,iAudioFileName);
}
else
{
iEngineState=EStreamStarted;
iOutputStream->SetVolume(iOutputStream->MaxVolume());
iOutputStream->SetAudioPropertiesL(iRate,iNbChannels);
iOutputStream->SetPriority(EMdaPriorityMax, EMdaPriorityPreferenceQuality);
FillSampleBufferL();
FillSampleBufferL();
}
}
void CVorbisEngine::StopAudio()
{
switch(iEngineState)
{
case EStreamPrepare:
StreamCleanup();
case EStreamStarted:
case EStreamPlaying:
case EStreamRepeat:
iOutputStream->Stop();
iEngineState=EStreamStopping;
break;
}
}
void CVorbisEngine::SetEngineObserver(MExEngineObserver& aObserver)
{
iEngineObserver=&aObserver;
}
void CVorbisEngine::StreamCleanup()
{
ov_clear(&iVf);
iEof=EFalse;
iFileOpen=EFalse;
delete(iOutputStream);
iOutputStream=NULL;
}
I've implemented the HandleAudioRepeat method inside my AppUI class and here's how I'm calling it.
{
switch(aState)
{
case CVorbisEngine::EStreamRepeat:
iAudioEngine->OpenFileL(aFileName,1);
break;
case CVorbisEngine::EStreamInterrupted:
iAudioEngine->StopAudio();
break;
case CVorbisEngine::EStreamError:
break;
}
}
The code works fine on the emulator the first time but when I try to play audio for the second time, I get a -5 error
within the MaoscOpenComplete callback.
On the device, it works fine too but when I call the StopAudio function while exiting the view or the app I get a KERN-EXEC 3 error.
Thanks for your time..
Regards,
Asheesh