无尽的加班啊,加班总是悄悄的来,没打一声招呼。
这两周抽出时间改进了一下声音引擎,短信和电话事件的测试真是麻烦啊。由于条件有限,仅有一部手机,加一个红外线适配器。短信事件把我测得郁闷了,模拟器不能测试这种事件,只能不断把打包的程序发送到手机,然后启动程序,再发送一个文件到手机造成短信事件来测试,经过进百次的传输,终于OK了。
在这里也参考了OGGPLAY的代码。仅在MaoscPlayComplete里处理了KErrDied和KErrInUse错误,在发生这两种错误时我做了小段时间的等待后重新建立CMdaAudioOutputStream,没有象《编写安全的Symbian C++游戏代码》里说的需要重新建立混合线程,只是在重新建立CMdaAudioOutputStream时主线程需要做短时间的等待,而且在短信事件中这两种错误都出现了,还出现了KErrAbort错误,但是可以不用处理。在启动声音引擎后也要让主线程做短时间的等待,这只在SYMBIAN第一版的SDK和真机需要这样做,可能是这个版本的BUG。
上周还添加了一个裁剪器,能够随意设置屏幕上的裁剪区域。在接下来的时间需要测试一下电话事件打断后是否能够正常,并增加RLE压缩的材质类,进一步压缩程序执行过程中的内存占用量。
在OGGPLAY中的检测电话事件的代码(应该不能在第三版中用): Tint COggActive::CallBack(TAny* aPtr) { COggActive* self= (COggActive*)aPtr; if(self->iAppUi->iIsStartup) { self->iAppUi->PostConstructL(); } self->iAppUi->NotifyUpdate(); if( self->iLine ) { RPhone::TLineInfo LInfo; self->iPhone->GetLineInfo(self->iLineToMonitor,LInfo); self->iLine->Open(*self->iPhone,LInfo.iName); TInt nCalls=0; self->iLine->EnumerateCall(nCalls); self->iLine->Close(); TBool isRinging = nCalls > self->iLineCallsReportedAtIdle; TBool isIdle = nCalls == self->iLineCallsReportedAtIdle; if (isRinging && !self->iInterrupted) { // the phone is ringing or someone is making a call, pause the music if any if (self->iAppUi->iOggPlayback->State()==CAbsPlayback::EPlaying) { TRACELF("GSM is active"); self->iInterrupted= ETrue; self->iAppUi->HandleCommandL(EOggPauseResume); } } else if (self->iInterrupted) { // our music was interrupted by a phone call, now what if (isIdle) { TRACELF("GSM is idle"); // okay, the phone is idle again, let's continue with the music self->iInterrupted= EFalse; if (self->iAppUi->iOggPlayback->State()==CAbsPlayback::EPaused) self->iAppUi->HandleCommandL(EOggPauseResume); } } } return 1; }
OGGPLAY中处理电话事件和短信事件的代码: void COggPlayback::MaoscPlayComplete(TInt aError) { // Error codes: // KErrCancel -3 // KErrUnderflow -10 // KErrDied -13 (interrupted by higher priority) // KErrInUse -14
if (iState==EPaused || iState==EClosed) return;
if (aError == KErrUnderflow) return; if (aError == KErrInUse) aError= KErrNone;
if (aError == KErrCancel) return;
if (aError == KErrDied) { iObserver->NotifyPlayInterrupted(); return; }
if (aError != KErrNone) { TBuf<256> buf,tbuf; CEikonEnv::Static()->ReadResource(tbuf,R_OGG_ERROR_18); CEikonEnv::Static()->ReadResource(buf,R_OGG_ERROR_16); buf.AppendNum(aError); iEnv->OggErrorMsgL(tbuf,buf); if (iObserver ) { if (!iEof ) iObserver->NotifyPlayInterrupted(); } } }
|