Symbian多平台游戏引擎开发日记 2006-6-26

    无尽的加班啊,加班总是悄悄的来,没打一声招呼。


    这两周抽出时间改进了一下声音引擎,短信和电话事件的测试真是麻烦啊。由于条件有限,仅有一部手机,加一个红外线适配器。短信事件把我测得郁闷了,模拟器不能测试这种事件,只能不断把打包的程序发送到手机,然后启动程序,再发送一个文件到手机造成短信事件来测试,经过进百次的传输,终于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();
  }
 }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值