Ticket #12754: libcec2-deadlock-fix.v3.patch

File libcec2-deadlock-fix.v3.patch, 1.9 KB (added by Bradley Baetz <bbaetz@…>, 4 years ago)

Patch against latest fixes/0.28

  • mythtv/libs/libmythui/cecadapter.cpp

    From 8fbebb00f7dffe1d2c664d9c005691f59d25e664 Mon Sep 17 00:00:00 2001
    From: Bradley Baetz <bbaetz@gmail.com>
    Date: Sun, 4 Dec 2016 15:08:47 +1100
    Subject: [PATCH] Fix deadlock in libcec initialization.
    
    Configuring the TV at startup is done from the main thread. However, when the
    TV state changes as a result of this, libCEC sends a message to the callback
    handler on its own thread, which tries to get the UI lock to reset the
    screensaver state. This results in a deadlock because the main thread already
    has the UI lock during startup time.
    
    Instead, run the initial setup activity at the start of the CEC handler thread.
    
    This was missed in the patch applied for #11986.
    
    Fixes #12754.
    ---
     mythtv/libs/libmythui/cecadapter.cpp | 11 +++++++----
     1 file changed, 7 insertions(+), 4 deletions(-)
    
    diff --git a/mythtv/libs/libmythui/cecadapter.cpp b/mythtv/libs/libmythui/cecadapter.cpp
    index 10451a0..ba63c49 100644
    a b class CECAdapterPriv 
    214214
    215215        LOG(VB_GENERAL, LOG_INFO, LOC + "Opened CEC device.");
    216216
    217         // all good to go
    218         valid = true;
    219 
    220217        // turn on tv (if configured)
    221218        powerOnTV = powerOnTVOnStart;
    222219
    223220        // switch input (if configured)
    224221        switchInput = true;
    225222
    226         HandleActions();
     223        // all good to go
     224        valid = true;
    227225
    228226        return true;
    229227    }
    CECAdapter::CECAdapter() : MThread("CECAdapter"), m_priv(new CECAdapterPriv) 
    11481146void CECAdapter::run()
    11491147{
    11501148    RunProlog();
     1149    // Handle any actions at startup
     1150    // This is done outside the lock to handle initial setup -
     1151    // we know that nothing else can be calling us this early.
     1152    m_priv->HandleActions();
     1153
    11511154    while (IsValid()) {
    11521155        // Note that a lock is used because the QWaitCondition needs it
    11531156        // None of the other HandleActions callers need the lock because