Hi All,
I have created one application to record the voice into one wave file.
Below is the code which is creating the problem.
void CMediaClientEngine::RecordL(const TDesC &aFile)
{
__ASSERT_DEBUG(iState == CMediaClientEngine::EIdle, Panic(CMediaClientEngine::EInProgress));
// Set up file to record to, the recording format, codec, and settings
iLocation.iName = aFile;
iCodec.iBits = TMdaPcmWavCodec::E8BitPcm;
iSettings.iSampleRate=TMdaAudioDataSettings::ESampleRate8000Hz;
iSettings.iChannels=TMdaAudioDataSettings::EChannelsMono;
iAudioRecorderUtility = CMdaAudioRecorderUtility::NewL(*this);
iAudioRecorderUtility -> OpenL(&iLocation, &iFormat, &iCodec, &iSettings);
iState = ERecordPrepare;
iEngineObserver -> HandleEngineState(iState,KErrNone);
// This will call back MoscoStateChangeEvent() when preparation is complete
}
// Audio is now prepared to record a file
// from MMdaObjectStateChangeObserver
void CMediaClientEngine::MoscoStateChangeEvent(CBase* aObject,
TInt /*aPreviousState*/, TInt aCurrentState, TInt aErrorCode)
{
__ASSERT_ALWAYS(aObject == iAudioRecorderUtility, Panic(CMediaClientEngine::EWrongState));
__ASSERT_DEBUG(iState == CMediaClientEngine::ERecordPrepare || iState == CMediaClientEngine::ERecording,
Panic(CMediaClientEngine::EWrongState));
if (aErrorCode)
RecordCleanup();
else if (aCurrentState == CMdaAudioClipUtility::EOpen)
{
// Set the gain
iAudioRecorderUtility -> SetGain(iAudioRecorderUtility -> MaxGain()/iGain);
// And mode
iAudioRecorderUtility -> SetAudioDeviceMode(CMdaAudioRecorderUtility::ELocal);
// and start recording
iAudioRecorderUtility -> RecordL();
iState = ERecording;
}
iEngineObserver -> HandleEngineState(iState,aErrorCode);
}
The problem is that the function �MoscoStateChangeEvent� is getting called with some error code due to which it cleans up the recorder by calling �RecordCleanup� function. Also, this function �MoscoStateChangeEvent� is getting called with �aCurrentState� equal to �ENotReady�. For this application to record �aCurrentState� should be �EOpen�.
The function �MoscoStateChangeEvent� is called by Media Server and it calls this function with �ENotReady� as current state when the media server is not able to open the file to record to. The file is getting created at the specified location so i am not getting that why it is not able to open that file for recording.
Can anyone throw some light on this?
Thanks in advance.
Pinky