cec: send opcode_image_view_on instead of text_view_on
[deb_libcec.git] / src / lib / CECProcessor.cpp
index 74f03b379698d3965d48e6cdef662358d1b1d70f..44b2acb44dbcdae590f3646f11b618e7fedf8978 100644 (file)
@@ -59,7 +59,10 @@ CCECProcessor::~CCECProcessor(void)
 bool CCECProcessor::Start(void)
 {
   if (!m_communication || !m_communication->IsOpen())
+  {
+    m_controller->AddLog(CEC_LOG_ERROR, "connection is closed");
     return false;
+  }
 
   if (!SetLogicalAddress(m_iLogicalAddress))
   {
@@ -79,7 +82,7 @@ void *CCECProcessor::Process(void)
 {
   m_controller->AddLog(CEC_LOG_DEBUG, "processor thread started");
 
-  while (!m_bStop)
+  while (!IsStopped())
   {
     bool bParseFrame(false);
     {
@@ -87,18 +90,17 @@ void *CCECProcessor::Process(void)
       cec_frame msg;
       msg.clear();
 
-      if (!m_bStop && m_communication->IsOpen() && m_communication->Read(msg, CEC_BUTTON_TIMEOUT))
-        bParseFrame = ParseMessage(msg);
+      if (m_communication->IsOpen() && m_communication->Read(msg, CEC_BUTTON_TIMEOUT))
+        bParseFrame = ParseMessage(msg) && !IsStopped();
     }
 
-    if (!m_bStop && bParseFrame)
+    if (bParseFrame)
       ParseCurrentFrame();
 
-    if (!m_bStop)
-    {
-      m_controller->CheckKeypressTimeout();
+    m_controller->CheckKeypressTimeout();
+
+    if (!IsStopped())
       Sleep(50);
-    }
   }
 
   return NULL;
@@ -116,7 +118,7 @@ bool CCECProcessor::PowerOnDevices(cec_logical_address address /* = CECDEVICE_TV
   frame.clear();
 
   frame.push_back(GetSourceDestination(address));
-  frame.push_back((uint8_t) CEC_OPCODE_TEXT_VIEW_ON);
+  frame.push_back((uint8_t) CEC_OPCODE_IMAGE_VIEW_ON);
   return Transmit(frame);
 }
 
@@ -551,8 +553,11 @@ void CCECProcessor::ParseCurrentFrame(void)
   }
   else if (destination == (uint8_t) CECDEVICE_BROADCAST)
   {
+    CStdString strLog;
     if (opCode == CEC_OPCODE_REQUEST_ACTIVE_SOURCE)
     {
+      strLog.Format("%i requests active source", initiator);
+      m_controller->AddLog(CEC_LOG_DEBUG, strLog.c_str());
       BroadcastActiveSource();
     }
     else if (opCode == CEC_OPCODE_SET_STREAM_PATH)
@@ -560,7 +565,6 @@ void CCECProcessor::ParseCurrentFrame(void)
       if (m_currentframe.size >= 4)
       {
         int streamaddr = ((int)m_currentframe.data[2] << 8) | ((int)m_currentframe.data[3]);
-        CStdString strLog;
         strLog.Format("%i requests stream path from physical address %04x", initiator, streamaddr);
         m_controller->AddLog(CEC_LOG_DEBUG, strLog.c_str());
         if (streamaddr == m_physicaladdress)