return m_libCec->MuteAudio(wait);
}
- bool SendKeypress(CecLogicalAddress destination, CecUserControlCode key, bool wait)
+ bool TransmitKeypress(CecLogicalAddress destination, CecUserControlCode key, bool wait)
{
- return m_libCec->SendKeypress((cec_logical_address)destination, (cec_user_control_code)key, wait);
+ return m_libCec->TransmitKeypress((cec_logical_address)destination, (cec_user_control_code)key, wait);
}
- bool SendKeyRelease(CecLogicalAddress destination, bool wait)
+ bool TransmitKeyRelease(CecLogicalAddress destination, bool wait)
{
- return m_libCec->SendKeyRelease((cec_logical_address)destination, wait);
+ return m_libCec->TransmitKeyRelease((cec_logical_address)destination, wait);
}
String ^ GetOSDName(CecLogicalAddress logicalAddress)
return bReturn;
}
-bool CCECProcessor::SendKeypress(cec_logical_address iDestination, cec_user_control_code key)
+bool CCECProcessor::TransmitKeypress(cec_logical_address iDestination, cec_user_control_code key)
{
- return m_busDevices[iDestination]->SendKeypress(key);
+ return m_busDevices[iDestination]->TransmitKeypress(key);
}
-bool CCECProcessor::SendKeyRelease(cec_logical_address iDestination)
+bool CCECProcessor::TransmitKeyRelease(cec_logical_address iDestination)
{
- return m_busDevices[iDestination]->SendKeyRelease();
+ return m_busDevices[iDestination]->TransmitKeyRelease();
}
const char *CCECProcessor::ToString(const cec_menu_state state)
if (device && device->GetStatus(true) == CEC_DEVICE_STATUS_PRESENT)
{
if (!IsStopped())
+ {
device->GetVendorId();
- Sleep(5);
+ Sleep(5);
+ }
+ if (!IsStopped())
+ {
+ device->GetPowerStatus(true);
+ Sleep(5);
+ }
}
}
}
virtual uint8_t VolumeUp(void);
virtual uint8_t VolumeDown(void);
virtual uint8_t MuteAudio(void);
- virtual bool SendKeypress(cec_logical_address iDestination, cec_user_control_code key);
- virtual bool SendKeyRelease(cec_logical_address iDestination);
+ virtual bool TransmitKeypress(cec_logical_address iDestination, cec_user_control_code key);
+ virtual bool TransmitKeyRelease(cec_logical_address iDestination);
virtual bool EnablePhysicalAddressDetection(void) { return false; };
void SetStandardLineTimeout(uint8_t iTimeout);
void SetRetryLineTimeout(uint8_t iTimeout);
bool CLibCEC::SendKeypress(cec_logical_address iDestination, cec_user_control_code key, bool bWait /* = false */)
{
if (m_cec)
- return m_cec->SendKeypress(iDestination, key);
+ return m_cec->TransmitKeypress(iDestination, key);
return false;
}
bool CLibCEC::SendKeyRelease(cec_logical_address iDestination, bool bWait /* = false */)
{
if (m_cec)
- return m_cec->SendKeyRelease(iDestination);
+ return m_cec->TransmitKeyRelease(iDestination);
return false;
}
uint8_t CCECAudioSystem::VolumeUp(void)
{
- if (SendKeypress(CEC_USER_CONTROL_CODE_VOLUME_UP))
- SendKeyRelease();
+ if (TransmitKeypress(CEC_USER_CONTROL_CODE_VOLUME_UP))
+ TransmitKeyRelease();
CLockObject lock(&m_mutex);
return m_audioStatus;
uint8_t CCECAudioSystem::VolumeDown(void)
{
- if (SendKeypress(CEC_USER_CONTROL_CODE_VOLUME_DOWN))
- SendKeyRelease();
+ if (TransmitKeypress(CEC_USER_CONTROL_CODE_VOLUME_DOWN))
+ TransmitKeyRelease();
CLockObject lock(&m_mutex);
return m_audioStatus;
uint8_t CCECAudioSystem::MuteAudio(void)
{
- if (SendKeypress(CEC_USER_CONTROL_CODE_MUTE))
- SendKeyRelease();
+ if (TransmitKeypress(CEC_USER_CONTROL_CODE_MUTE))
+ TransmitKeyRelease();
CLockObject lock(&m_mutex);
return m_audioStatus;
m_vendor(CEC_VENDOR_UNKNOWN),
m_menuState(CEC_MENU_STATE_ACTIVATED),
m_bActiveSource(false),
- m_iLastCommandSent(0),
m_iLastActive(0),
m_cecVersion(CEC_VERSION_UNKNOWN),
m_deviceStatus(CEC_DEVICE_STATUS_UNKNOWN)
bool CCECBusDevice::HandleCommand(const cec_command &command)
{
+ bool bHandled(false);
+
+ /* update "last active" */
{
CLockObject lock(&m_writeMutex);
m_iLastActive = GetTimeMs();
}
- m_handler->HandleCommand(command);
+ /* handle the command */
+ bHandled = m_handler->HandleCommand(command);
+ /* change status to present */
+ if (bHandled)
{
CLockObject lock(&m_writeMutex);
if (m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC)
m_deviceStatus = CEC_DEVICE_STATUS_PRESENT;
}
}
- return true;
+
+ return bHandled;
}
bool CCECBusDevice::PowerOn(void)
cec_power_status status = GetPowerStatus();
if (status == CEC_POWER_STATUS_STANDBY || status == CEC_POWER_STATUS_UNKNOWN)
{
- SendKeypress(CEC_USER_CONTROL_CODE_POWER);
- return SendKeyRelease();
+ /* sending the normal power on command appears to have failed */
+ CStdString strLog;
+ strLog.Format("<< sending power on keypress to '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
+ AddLog(CEC_LOG_DEBUG, strLog.c_str());
+
+ TransmitKeypress(CEC_USER_CONTROL_CODE_POWER);
+ return TransmitKeyRelease();
}
return true;
}
/** @name Getters */
//@{
-cec_version CCECBusDevice::GetCecVersion(void)
+cec_version CCECBusDevice::GetCecVersion(bool bUpdate /* = false */)
{
CLockObject lock(&m_mutex);
if (GetStatus() == CEC_DEVICE_STATUS_PRESENT &&
- m_cecVersion == CEC_VERSION_UNKNOWN)
+ (bUpdate || m_cecVersion == CEC_VERSION_UNKNOWN))
RequestCecVersion();
return m_cecVersion;
return bReturn;
}
-uint64_t CCECBusDevice::GetLastCommandSent(void) const
-{
- return GetTimeMs() - m_iLastCommandSent;
-}
-
const char* CCECBusDevice::GetLogicalAddressName(void) const
{
return ToString(m_iLogicalAddress);
}
-cec_menu_language &CCECBusDevice::GetMenuLanguage(void)
+cec_menu_language &CCECBusDevice::GetMenuLanguage(bool bUpdate /* = false */)
{
CLockObject lock(&m_mutex);
if (GetStatus() == CEC_DEVICE_STATUS_PRESENT &&
- !strcmp(m_menuLanguage.language, "???"))
+ (bUpdate || !strcmp(m_menuLanguage.language, "???")))
RequestMenuLanguage();
return m_menuLanguage;
return m_processor->GetPhysicalAddress();
}
-CStdString CCECBusDevice::GetOSDName(void)
+CStdString CCECBusDevice::GetOSDName(bool bUpdate /* = false */)
{
CLockObject lock(&m_mutex);
if (GetStatus() == CEC_DEVICE_STATUS_PRESENT &&
- m_strDeviceName.Equals(ToString(m_iLogicalAddress)) &&
+ (bUpdate || m_strDeviceName.Equals(ToString(m_iLogicalAddress))) &&
m_type != CEC_DEVICE_TYPE_TV)
RequestOSDName();
return bReturn;
}
-uint16_t CCECBusDevice::GetPhysicalAddress(bool bRefresh /* = true */)
+uint16_t CCECBusDevice::GetPhysicalAddress(bool bUpdate /* = false */)
{
CLockObject lock(&m_mutex);
if (GetStatus() == CEC_DEVICE_STATUS_PRESENT &&
- (m_iPhysicalAddress == 0xFFFF || bRefresh))
+ (m_iPhysicalAddress == 0xFFFF || bUpdate))
{
if (!RequestPhysicalAddress())
AddLog(CEC_LOG_ERROR, "failed to request the physical address");
return bReturn;
}
-cec_power_status CCECBusDevice::GetPowerStatus(void)
+cec_power_status CCECBusDevice::GetPowerStatus(bool bUpdate /* = false */)
{
CLockObject lock(&m_mutex);
if (GetStatus() == CEC_DEVICE_STATUS_PRESENT &&
- m_powerStatus == CEC_POWER_STATUS_UNKNOWN)
+ (bUpdate || m_powerStatus == CEC_POWER_STATUS_UNKNOWN))
RequestPowerStatus();
return m_powerStatus;
return bReturn;
}
-cec_vendor_id CCECBusDevice::GetVendorId(void)
+cec_vendor_id CCECBusDevice::GetVendorId(bool bUpdate /* = false */)
{
CLockObject lock(&m_mutex);
if (GetStatus() == CEC_DEVICE_STATUS_PRESENT &&
- m_vendor == CEC_VENDOR_UNKNOWN)
+ (bUpdate || m_vendor == CEC_VENDOR_UNKNOWN))
RequestVendorId();
return m_vendor;
return bReturn;
}
-const char *CCECBusDevice::GetVendorName(void)
+const char *CCECBusDevice::GetVendorName(bool bUpdate /* = false */)
{
- return ToString(GetVendorId());
+ return ToString(GetVendorId(bUpdate));
}
bool CCECBusDevice::MyLogicalAddressContains(cec_logical_address address) const
m_vendor = CEC_VENDOR_UNKNOWN;
m_menuState = CEC_MENU_STATE_ACTIVATED;
m_bActiveSource = false;
- m_iLastCommandSent = 0;
m_iLastActive = 0;
m_cecVersion = CEC_VERSION_UNKNOWN;
m_deviceStatus = newStatus;
m_vendor = CEC_VENDOR_UNKNOWN;
m_menuState = CEC_MENU_STATE_ACTIVATED;
m_bActiveSource = false;
- m_iLastCommandSent = 0;
m_iLastActive = 0;
m_cecVersion = CEC_VERSION_1_3A;
m_deviceStatus = newStatus;
}
}
-bool CCECBusDevice::SendKeypress(cec_user_control_code key)
+bool CCECBusDevice::TransmitKeypress(cec_user_control_code key)
{
- return m_handler->SendKeypress(m_processor->GetLogicalAddress(), m_iLogicalAddress, key);
+ return m_handler->TransmitKeypress(m_processor->GetLogicalAddress(), m_iLogicalAddress, key);
}
-bool CCECBusDevice::SendKeyRelease(void)
+bool CCECBusDevice::TransmitKeyRelease(void)
{
- return m_handler->SendKeyRelease(m_processor->GetLogicalAddress(), m_iLogicalAddress);
+ return m_handler->TransmitKeyRelease(m_processor->GetLogicalAddress(), m_iLogicalAddress);
}
//@}
virtual bool PowerOn(void);
virtual bool Standby(void);
- virtual cec_version GetCecVersion(void);
+ virtual cec_version GetCecVersion(bool bUpdate = false);
virtual CCECCommandHandler * GetHandler(void) const { return m_handler; };
- virtual uint64_t GetLastCommandSent(void) const;
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_menu_language & GetMenuLanguage(bool bUpdate = false);
virtual cec_logical_address GetMyLogicalAddress(void) const;
virtual uint16_t GetMyPhysicalAddress(void) const;
- virtual CStdString GetOSDName(void);
- virtual uint16_t GetPhysicalAddress(bool bRefresh = true);
- virtual cec_power_status GetPowerStatus(void);
+ virtual CStdString GetOSDName(bool bUpdate = false);
+ virtual uint16_t GetPhysicalAddress(bool bUpdate = false);
+ virtual cec_power_status GetPowerStatus(bool bUpdate = false);
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 cec_vendor_id GetVendorId(bool bUpdate = false);
+ virtual const char * GetVendorName(bool bUpdate = false);
virtual bool MyLogicalAddressContains(cec_logical_address address) const;
virtual cec_bus_device_status GetStatus(bool bForcePoll = false);
- bool RequestCecVersion(void);
- bool RequestMenuLanguage(void);
- bool RequestPowerStatus(void);
- bool RequestVendorId(void);
- bool RequestPhysicalAddress(void);
- bool RequestOSDName(void);
-
virtual void SetInactiveDevice(void);
virtual void SetActiveDevice(void);
virtual bool TryLogicalAddress(void);
virtual bool TransmitPowerState(cec_logical_address dest);
virtual bool TransmitPoll(cec_logical_address dest);
virtual bool TransmitVendorID(cec_logical_address dest);
- virtual bool SendKeypress(cec_user_control_code key);
- virtual bool SendKeyRelease(void);
+ virtual bool TransmitKeypress(cec_user_control_code key);
+ virtual bool TransmitKeyRelease(void);
protected:
+ bool RequestCecVersion(void);
+ bool RequestMenuLanguage(void);
+ bool RequestPowerStatus(void);
+ bool RequestVendorId(void);
+ bool RequestPhysicalAddress(void);
+ bool RequestOSDName(void);
+
bool NeedsPoll(void);
cec_device_type m_type;
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;
return Transmit(command);
}
-bool CCECCommandHandler::SendKeypress(const cec_logical_address iInitiator, const cec_logical_address iDestination, cec_user_control_code key)
+bool CCECCommandHandler::TransmitKeypress(const cec_logical_address iInitiator, const cec_logical_address iDestination, cec_user_control_code key)
{
cec_command command;
cec_command::Format(command, iInitiator, iDestination, CEC_OPCODE_USER_CONTROL_PRESSED, m_iTransmitTimeout);
return Transmit(command);
}
-bool CCECCommandHandler::SendKeyRelease(const cec_logical_address iInitiator, const cec_logical_address iDestination)
+bool CCECCommandHandler::TransmitKeyRelease(const cec_logical_address iInitiator, const cec_logical_address iDestination)
{
cec_command command;
cec_command::Format(command, iInitiator, iDestination, CEC_OPCODE_USER_CONTROL_RELEASE, m_iTransmitTimeout);
virtual bool TransmitSetSystemAudioMode(const cec_logical_address iInitiator, const cec_logical_address iDestination, cec_system_audio_status state);
virtual bool TransmitSystemAudioModeStatus(const cec_logical_address iInitiator, const cec_logical_address iDestination, cec_system_audio_status state);
virtual bool TransmitDeckStatus(const cec_logical_address iInitiator, const cec_logical_address iDestination, cec_deck_info state);
- virtual bool SendKeypress(const cec_logical_address iInitiator, const cec_logical_address iDestination, cec_user_control_code key);
- virtual bool SendKeyRelease(const cec_logical_address iInitiator, const cec_logical_address iDestination);
+ virtual bool TransmitKeypress(const cec_logical_address iInitiator, const cec_logical_address iDestination, cec_user_control_code key);
+ virtual bool TransmitKeyRelease(const cec_logical_address iInitiator, const cec_logical_address iDestination);
protected:
virtual bool HandleActiveSource(const cec_command &command);