From: Lars Op den Kamp Date: Fri, 25 Nov 2011 09:34:07 +0000 (+0100) Subject: cec: store the status of a bus device: present, not present or handled by libcec X-Git-Tag: upstream/2.2.0~1^2~44^2~108 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=f8ae32954754d261552c2c11a6a9055f02d61bba;p=deb_libcec.git cec: store the status of a bus device: present, not present or handled by libcec --- diff --git a/include/cectypes.h b/include/cectypes.h index ce042cc..bc661a8 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -582,6 +582,14 @@ typedef enum cec_adapter_messagecode MSGCODE_FRAME_ACK = 0x40, } cec_adapter_messagecode; +typedef enum cec_bus_device_status +{ + CEC_DEVICE_STATUS_UNKNOWN, + CEC_DEVICE_STATUS_PRESENT, + CEC_DEVICE_STATUS_NOT_PRESENT, + CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC +} cec_bus_device_status; + typedef enum cec_vendor_id { CEC_VENDOR_SAMSUNG = 0x00F0, diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index a7ff64c..cf64053 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -158,6 +158,7 @@ bool CCECProcessor::TryLogicalAddress(cec_logical_address address, unsigned int } m_busDevices[address]->m_powerStatus = CEC_POWER_STATUS_STANDBY; m_busDevices[address]->m_cecVersion = CEC_VERSION_1_3A; + m_busDevices[address]->m_deviceStatus = CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC; m_logicalAddresses.Set(address); diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index 1227f8d..20fe43b 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -54,7 +54,8 @@ CCECBusDevice::CCECBusDevice(CCECProcessor *processor, cec_logical_address iLogi m_bActiveSource(false), m_iLastCommandSent(0), m_iLastActive(0), - m_cecVersion(CEC_VERSION_UNKNOWN) + m_cecVersion(CEC_VERSION_UNKNOWN), + m_deviceStatus(CEC_DEVICE_STATUS_UNKNOWN) { m_handler = new CCECCommandHandler(this); @@ -240,6 +241,20 @@ bool CCECBusDevice::MyLogicalAddressContains(cec_logical_address address) const return m_processor->HasLogicalAddress(address); } +cec_bus_device_status CCECBusDevice::GetStatus(void) +{ + CLockObject lock(&m_mutex); + if (m_deviceStatus == CEC_DEVICE_STATUS_UNKNOWN) + { + if (m_processor->PollDevice(m_iLogicalAddress)) + m_deviceStatus = CEC_DEVICE_STATUS_PRESENT; + else + m_deviceStatus = CEC_DEVICE_STATUS_NOT_PRESENT; + } + + return m_deviceStatus; +} + //@} /** @name Setters */ diff --git a/src/lib/devices/CECBusDevice.h b/src/lib/devices/CECBusDevice.h index 748758c..d7f4e27 100644 --- a/src/lib/devices/CECBusDevice.h +++ b/src/lib/devices/CECBusDevice.h @@ -54,22 +54,23 @@ namespace CEC virtual bool PowerOn(void); virtual bool Standby(void); - virtual cec_version GetCecVersion(void); - virtual CCECCommandHandler *GetHandler(void) const { return m_handler; }; - virtual uint64_t GetCommandSent(void) const { return m_iLastCommandSent; } - virtual uint64_t GetLastActive(void) const { return m_iLastActive; } - virtual cec_logical_address GetLogicalAddress(void) const { return m_iLogicalAddress; } - virtual const char* GetLogicalAddressName(void) const; - virtual cec_menu_language & GetMenuLanguage(void); - virtual cec_logical_address GetMyLogicalAddress(void) const; - virtual uint16_t GetMyPhysicalAddress(void) const; - virtual uint16_t GetPhysicalAddress(void) const { return m_iPhysicalAddress; } - virtual cec_power_status GetPowerStatus(void); - virtual CCECProcessor * GetProcessor(void) const { return m_processor; } - virtual cec_device_type GetType(void) const { return m_type; } - virtual cec_vendor_id GetVendorId(void); - virtual const char * GetVendorName(void); - virtual bool MyLogicalAddressContains(cec_logical_address address) const; + virtual cec_version GetCecVersion(void); + virtual CCECCommandHandler * GetHandler(void) const { return m_handler; }; + virtual uint64_t GetCommandSent(void) const { return m_iLastCommandSent; } + virtual uint64_t GetLastActive(void) const { return m_iLastActive; } + virtual cec_logical_address GetLogicalAddress(void) const { return m_iLogicalAddress; } + virtual const char* GetLogicalAddressName(void) const; + virtual cec_menu_language & GetMenuLanguage(void); + virtual cec_logical_address GetMyLogicalAddress(void) const; + virtual uint16_t GetMyPhysicalAddress(void) const; + virtual uint16_t GetPhysicalAddress(void) const { return m_iPhysicalAddress; } + virtual cec_power_status GetPowerStatus(void); + virtual CCECProcessor * GetProcessor(void) const { return m_processor; } + virtual cec_device_type GetType(void) const { return m_type; } + virtual cec_vendor_id GetVendorId(void); + virtual const char * GetVendorName(void); + virtual bool MyLogicalAddressContains(cec_logical_address address) const; + virtual cec_bus_device_status GetStatus(void); virtual void SetInactiveDevice(void); virtual void SetActiveDevice(void); @@ -95,23 +96,24 @@ namespace CEC virtual bool TransmitVendorID(cec_logical_address dest); protected: - cec_device_type m_type; - CStdString m_strDeviceName; - uint16_t m_iPhysicalAddress; - uint16_t m_iStreamPath; - cec_logical_address m_iLogicalAddress; - cec_power_status m_powerStatus; - cec_menu_language m_menuLanguage; - CCECProcessor *m_processor; - CCECCommandHandler *m_handler; - cec_vendor_id m_vendor; - cec_menu_state m_menuState; - bool m_bActiveSource; - uint64_t m_iLastCommandSent; - uint64_t m_iLastActive; - cec_version m_cecVersion; - CMutex m_transmitMutex; - CMutex m_mutex; - CCondition m_condition; + cec_device_type m_type; + CStdString m_strDeviceName; + uint16_t m_iPhysicalAddress; + uint16_t m_iStreamPath; + cec_logical_address m_iLogicalAddress; + cec_power_status m_powerStatus; + cec_menu_language m_menuLanguage; + CCECProcessor * m_processor; + CCECCommandHandler * m_handler; + cec_vendor_id m_vendor; + cec_menu_state m_menuState; + bool m_bActiveSource; + uint64_t m_iLastCommandSent; + uint64_t m_iLastActive; + cec_version m_cecVersion; + cec_bus_device_status m_deviceStatus; + CMutex m_transmitMutex; + CMutex m_mutex; + CCondition m_condition; }; };