cec: keep a power and menu state pew device
authorLars Op den Kamp <lars@opdenkamp.eu>
Sun, 6 Nov 2011 12:27:42 +0000 (13:27 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Sun, 6 Nov 2011 12:27:42 +0000 (13:27 +0100)
src/lib/CECProcessor.cpp
src/lib/devices/CECBusDevice.cpp
src/lib/devices/CECBusDevice.h

index 5eed4a888f650802c3238d47c5a391275617e242..07698adff5a012752e8e304fd9705540a51aa3f8 100644 (file)
@@ -151,6 +151,7 @@ bool CCECProcessor::TryLogicalAddress(cec_logical_address address, const char *s
     /* only set our OSD name for the primary device */
     if (m_logicalAddresses.empty())
       m_busDevices[address]->m_strDeviceName = m_strDeviceName;
+    m_busDevices[address]->m_powerStatus = CEC_POWER_STATUS_ON;
     m_logicalAddresses.set(address);
 
     // TODO
index 3d1a7cda80c9da25a4b1a4ed00978ff1707bf023..8b6c54d93b618bbdc10f557c14665472f628770a 100644 (file)
@@ -44,6 +44,7 @@ CCECBusDevice::CCECBusDevice(CCECProcessor *processor, cec_logical_address iLogi
   m_iLogicalAddress(iLogicalAddress),
   m_powerStatus(CEC_POWER_STATUS_UNKNOWN),
   m_processor(processor),
+  m_bMenuActive(true),
   m_iVendorClass(CEC_VENDOR_UNKNOWN),
   m_iLastActive(0),
   m_cecVersion(CEC_VERSION_1_3A)
@@ -300,16 +301,16 @@ bool CCECBusDevice::ReportDeckStatus(cec_logical_address dest)
   return false;
 }
 
-bool CCECBusDevice::ReportMenuState(cec_logical_address dest, bool bActive /* = true */)
+bool CCECBusDevice::ReportMenuState(cec_logical_address dest)
 {
-  if (bActive)
+  if (m_bMenuActive)
     AddLog(CEC_LOG_NOTICE, "<< reporting menu state as active");
   else
     AddLog(CEC_LOG_NOTICE, "<< reporting menu state as inactive");
 
   cec_command command;
   cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_MENU_STATUS);
-  command.parameters.push_back(bActive ? (uint8_t) CEC_MENU_STATE_ACTIVATED : (uint8_t) CEC_MENU_STATE_DEACTIVATED);
+  command.parameters.push_back(m_bMenuActive ? (uint8_t) CEC_MENU_STATE_ACTIVATED : (uint8_t) CEC_MENU_STATE_DEACTIVATED);
 
   return m_processor->Transmit(command);
 }
@@ -330,12 +331,13 @@ bool CCECBusDevice::ReportOSDName(cec_logical_address dest)
 
 bool CCECBusDevice::ReportPowerState(cec_logical_address dest)
 {
-  AddLog(CEC_LOG_NOTICE, "<< reporting \"On\" power status");
+  CStdString strLog;
+  strLog.Format("<< reporting power status '%d'", m_powerStatus);
+  AddLog(CEC_LOG_NOTICE, strLog);
 
   cec_command command;
   cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_REPORT_POWER_STATUS);
-//  command.parameters.push_back(bOn ? (uint8_t) CEC_POWER_STATUS_ON : (uint8_t) CEC_POWER_STATUS_STANDBY);
-  command.parameters.push_back((uint8_t) CEC_POWER_STATUS_ON);
+  command.parameters.push_back((uint8_t) m_powerStatus);
 
   return m_processor->Transmit(command);
 }
index ef2db219e0f74c19b4c72edea5e9d5ae14aa795b..5a5229d4059551fee0d899f0ba3bb130253f56d8 100644 (file)
@@ -83,7 +83,7 @@ namespace CEC
 
     virtual bool ReportCECVersion(cec_logical_address dest);
     virtual bool ReportDeckStatus(cec_logical_address dest);
-    virtual bool ReportMenuState(cec_logical_address dest, bool bActive = true);
+    virtual bool ReportMenuState(cec_logical_address dest);
     virtual bool ReportOSDName(cec_logical_address dest);
     virtual bool ReportPowerState(cec_logical_address dest);
     virtual bool ReportVendorID(cec_logical_address dest);
@@ -103,6 +103,7 @@ namespace CEC
     CCECProcessor      *m_processor;
     CCECCommandHandler *m_handler;
     cec_vendor          m_vendor;
+    bool                m_bMenuActive;
     uint8_t             m_iVendorClass;
     uint64_t            m_iLastActive;
     cec_version         m_cecVersion;