码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2014-11-20 11:40:09      阅读:333      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   io   ar   os   sp   for   

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

标签:des   style   blog   http   io   ar   os   sp   for   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!