zoukankan      html  css  js  c++  java
  • Don't performan heavy tasks in the MoBu Real-time engine thread, even if it worked before

    Recently we received a question about a crash while calling FBPlayerControl::GotoStart() from within a device real-time engine thread. It seems this worked fine up to MoBu 2014, and crashes in Mobu 2015.


    Actually, it's possible it worked in previous Mobu versions, but as the best practice, it’s not suggested because the SDK doc clearly says 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 contain only minimal operations, and especially should avoid UI related operations like FBPlayerControl::GotoStart().


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


    The problem is that this was reported in a device plugin, and they wanted 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, you can remove the UI operation codes(FBPlayerControl::GotoStart()) out of the real-time engine( DeviceIONotify() and DeviceEvaluationNotify() ) methods, and just save the status of the operation. Then use the system OnUIIdle callback to check the status, and if needing to operate the transport control, call the FBPlayerControl::GotoStart(). The main code is as follow, and this then prevents the crash.


    Initialize the following code like:

    Code Snippet
    1. m_NeedToPlay = false;
    2. FBSystem().TheOne().OnUIIdle.Add( this,(FBCallback) &ORDevice_Template::EventUIIdle );

    Update the DeviceEvaluationNotify to save the status:

    Code Snippet
    1. bool ORDevice_Template::DeviceEvaluationNotify( kTransportMode pMode, FBEvaluateInfo* pEvaluateInfo )
    2. {
    3.     ……
    4.   if(***)
    5.     m_NeedToPlay = true;
    6.  
    7.   returntrue;
    8. }

    Call the UI operation inside a UI Idle event:

    Code Snippet
    1. void
    2. ORDevice_Template::EventUIIdle(HISender pSender, HKEvent pEvent )
    3. {
    4.     if(m_NeedToPlay)
    5.     {
    6.         FBPlayerControl player;
    7.         player.GotoStart();
    8.     }
    9.     m_NeedToPlay = false;
    10. }
  • 相关阅读:
    维护IBM DB2数据库所应了解的底子内情知识6
    维护IBM DB2数据库所应了解的根本知识2
    教你疾速掌握DB2数据库中的相关呼吁1
    疾速把握IBM DB2数据库的常用操纵指令2
    维护IBM DB2数据库所应看法的根底常识1
    维护IBM DB2数据库所应了解的根蒂基本常识9
    维护IBM DB2数据库所应懂得的根基常识7
    维护IBM DB2数据库所应了解的根柢常识11
    疾速把握IBM DB2数据库的常用操纵指令3
    维护IBM DB2数据库所应领会的基本常识8
  • 原文地址:https://www.cnblogs.com/johnonsoftware/p/4110150.html
Copyright © 2011-2022 走看看