首页 > 其他 > 详细

Not do time consuming task in MoBu Real-time engine thread even it worked in previous MoBu versions

时间:2014-11-20 11:39:25      阅读:232      评论:0      收藏:0      [点我收藏+]

I got a question from one of our partner, and they got a crash while calling FBPlayerControl::GotoStart() from within a device real-time engine thread, and he mentioned it worked fine up to MoBu 2014, and crashes in Mobu 2015.


Actually, it‘s possible it worked in some of previous Mobu version, but as the best practice, it’s not suggested because the SDK doc clearly mentioned that some methods like DeviceIONotify() and DeviceEvaluationNotify() are called by the Real-time engine thread, and they should consume as little CPU time as possible and return as soon as possible. So it should not contain much things especially some UI related operation like FBPlayerControl::GotoStart().

bubuko.com,布布扣


Back to the problem itself, so how to solve this issue? or any workaround for this? Let’s take this as an example:


The problem is that partner made a device plugin, and they want to control the transport control player from an external device, so they’d like to fire the FBPlayerControls from within the method of DeviceIONotify() or DeviceEvaluationNotify().

To solve the problem, I removed the UI operation codes(FBPlayerControl::GotoStart()) out of the real-time engine( DeviceIONotify() and DeviceEvaluationNotify() ), just save the status of the operation, then use the system OnUIIdle callback to check the status, if need to operate the transport control, call the FBPlayerControl::GotoStart(). The main touched code is as follow, and the result worked as good as expectation, no crash any more.


Initialize the following code like:
m_ NeedToPlay = false;
FBSystem().TheOne().OnUIIdle.Add( this,(FBCallback) &ORDevice_Template::EventUIIdle );

 

Update the DeviceEvaluationNotify to save the status:

bool ORDevice_Template::DeviceEvaluationNotify( kTransportMode pMode, FBEvaluateInfo* pEvaluateInfo )

{

    ……

  if(***)

    m_NeedToPlay = true;

   return true;

}

Call the UI operation inside a UI Idle event:

void

ORDevice_Template::EventUIIdle(HISender pSender, HKEvent pEvent )

{

    if(m_NeedToPlay)

    {

        FBPlayerControl player;

        player.GotoStart();

    }

    m_NeedToPlay = false;

}

Not do time consuming task in MoBu Real-time engine thread even it worked in previous MoBu versions

原文:http://www.cnblogs.com/johnonsoftware/p/4110150.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!