00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00044 #include <e32std.h>
00045 #include <f32file.h>
00046 #include "audioengine.h"
00047 #include "audiorecorder_p.h"
00048
00049 _LIT(KAudioFile, "c:\\sounds\\new.wav");
00050
00055 CAudioRecorderEngine* CAudioRecorderEngine::NewL(AudioRecorderPrivate* audioRecorderPvt)
00056 {
00057 CAudioRecorderEngine* self = CAudioRecorderEngine::NewLC(audioRecorderPvt);
00058 CleanupStack::Pop(self);
00059 return self;
00060 }
00061
00065 CAudioRecorderEngine* CAudioRecorderEngine::NewLC(AudioRecorderPrivate* audioRecorderPvt)
00066 {
00067 CAudioRecorderEngine* self = new (ELeave) CAudioRecorderEngine(audioRecorderPvt);
00068 CleanupStack::PushL(self);
00069 self->ConstructL();
00070 return self;
00071 }
00072
00073
00077 CAudioRecorderEngine::CAudioRecorderEngine(AudioRecorderPrivate* audioRecorderPvt):iAudioRecorderPvt(audioRecorderPvt)
00078 {
00079 }
00083 CAudioRecorderEngine::~CAudioRecorderEngine()
00084 {
00085 iFs.Close();
00086 iRecorderUtility->Close();
00087 delete iRecorderUtility;
00088 }
00089
00093 void CAudioRecorderEngine::ConstructL()
00094 {
00095 User::LeaveIfError(iFs.Connect());
00096 iRecorderUtility = CMdaAudioRecorderUtility::NewL(*this);
00097
00098 iRecorderUtility->SetVolume(iRecorderUtility->MaxVolume()/2);
00099
00100 iRecorderUtility->OpenFileL(KAudioFile);
00101 }
00102
00107 void CAudioRecorderEngine::MoscoStateChangeEvent(CBase* , TInt ,
00108 TInt aCurrentState, TInt aErrorCode)
00109 {
00110 }
00111
00115 void CAudioRecorderEngine::PlayL()
00116 {
00117 TRAPD(err,iRecorderUtility->PlayL());
00118 if(err == KErrNone)
00119 {
00120 _LIT(KSuccess,"Play Back");
00121 iResponse = KSuccess;
00122 }
00123 else
00124 {
00125 _LIT(KFailure,"Playing the recording failed");
00126 iResponse = KFailure;
00127 }
00128 iAudioRecorderPvt->printResponse();
00129 }
00130
00134 void CAudioRecorderEngine::Stop()
00135 {
00136 iRecorderUtility->Stop();
00137 _LIT(KSuccess,"Stopped");
00138 iResponse = KSuccess;
00139 iAudioRecorderPvt->printResponse();
00140 }
00141
00145 void CAudioRecorderEngine::RecordL()
00146 {
00147 TRAPD(err,iRecorderUtility->RecordL());
00148 if(err == KErrNone)
00149 {
00150 _LIT(KSuccess,"Recording started");
00151 iResponse = KSuccess;
00152 }
00153 else
00154 {
00155 _LIT(KFailure,"Starting recording failed");
00156 iResponse = KFailure;
00157 }
00158 iAudioRecorderPvt->printResponse();
00159 }
00160
00161