/*
* This file is part of the libCEC(R) library.
*
- * libCEC(R) is Copyright (C) 2011 Pulse-Eight Limited. All rights reserved.
+ * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited. All rights reserved.
* libCEC(R) is an original work, containing original code.
*
* libCEC(R) is a trademark of Pulse-Eight Limited.
#include "../implementations/ANCommandHandler.h"
#include "../implementations/CECCommandHandler.h"
#include "../implementations/SLCommandHandler.h"
-#include "../platform/timeutils.h"
+#include "../implementations/VLCommandHandler.h"
+#include "../LibCEC.h"
+#include "../platform/util/timeutils.h"
using namespace CEC;
+using namespace PLATFORM;
+
+#define ToString(p) m_processor->ToString(p)
CCECBusDevice::CCECBusDevice(CCECProcessor *processor, cec_logical_address iLogicalAddress, uint16_t iPhysicalAddress) :
+ m_type(CEC_DEVICE_TYPE_RESERVED),
m_iPhysicalAddress(iPhysicalAddress),
+ m_iStreamPath(0),
m_iLogicalAddress(iLogicalAddress),
m_powerStatus(CEC_POWER_STATUS_UNKNOWN),
m_processor(processor),
- m_iVendorClass(CEC_VENDOR_UNKNOWN),
+ m_vendor(CEC_VENDOR_UNKNOWN),
+ m_bReplaceHandler(false),
+ m_menuState(CEC_MENU_STATE_ACTIVATED),
+ m_bActiveSource(false),
m_iLastActive(0),
- m_cecVersion(CEC_VERSION_UNKNOWN)
+ m_iLastPowerStateUpdate(0),
+ m_cecVersion(CEC_VERSION_UNKNOWN),
+ m_deviceStatus(CEC_DEVICE_STATUS_UNKNOWN)
{
m_handler = new CCECCommandHandler(this);
+
for (unsigned int iPtr = 0; iPtr < 4; iPtr++)
m_menuLanguage.language[iPtr] = '?';
m_menuLanguage.language[3] = 0;
m_menuLanguage.device = iLogicalAddress;
- m_vendor.vendor = CEC_VENDOR_UNKNOWN;
- switch(iLogicalAddress)
- {
- case CECDEVICE_AUDIOSYSTEM:
- m_type = CEC_DEVICE_TYPE_AUDIO_SYSTEM;
- m_strDeviceName = "Audio";
- case CECDEVICE_PLAYBACKDEVICE1:
- case CECDEVICE_PLAYBACKDEVICE2:
- case CECDEVICE_PLAYBACKDEVICE3:
- m_type = CEC_DEVICE_TYPE_PLAYBACK_DEVICE;
- m_strDeviceName = "Player";
- case CECDEVICE_RECORDINGDEVICE1:
- case CECDEVICE_RECORDINGDEVICE2:
- case CECDEVICE_RECORDINGDEVICE3:
- m_type = CEC_DEVICE_TYPE_RECORDING_DEVICE;
- m_strDeviceName = "Recorder";
- case CECDEVICE_TUNER1:
- case CECDEVICE_TUNER2:
- case CECDEVICE_TUNER3:
- case CECDEVICE_TUNER4:
- m_type = CEC_DEVICE_TYPE_TUNER;
- m_strDeviceName = "Tuner";
- case CECDEVICE_TV:
- m_type = CEC_DEVICE_TYPE_TV;
- m_strDeviceName = "TV";
- default:
- m_type = CEC_DEVICE_TYPE_RESERVED;
- m_strDeviceName = "Unknown";
- }
+ m_strDeviceName = ToString(m_iLogicalAddress);
}
CCECBusDevice::~CCECBusDevice(void)
{
- m_condition.Broadcast();
delete m_handler;
}
-cec_logical_address CCECBusDevice::GetMyLogicalAddress(void) const
+bool CCECBusDevice::HandleCommand(const cec_command &command)
{
- return m_processor->GetLogicalAddress();
+ bool bHandled(false);
+
+ /* update "last active" */
+ {
+ CLockObject lock(m_mutex);
+ m_iLastActive = GetTimeMs();
+
+ if (m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC)
+ m_deviceStatus = CEC_DEVICE_STATUS_PRESENT;
+ }
+
+ /* handle the command */
+ bHandled = m_handler->HandleCommand(command);
+
+ /* change status to present */
+ if (bHandled)
+ {
+ CLockObject lock(m_mutex);
+ if (m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC)
+ {
+ if (m_deviceStatus != CEC_DEVICE_STATUS_PRESENT)
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "device %s (%x) status changed to present after command %s", GetLogicalAddressName(), (uint8_t)GetLogicalAddress(), ToString(command.opcode));
+ m_deviceStatus = CEC_DEVICE_STATUS_PRESENT;
+ }
+ }
+
+ return bHandled;
}
-bool CCECBusDevice::MyLogicalAddressContains(cec_logical_address address) const
+bool CCECBusDevice::PowerOn(void)
{
- return m_processor->HasLogicalAddress(address);
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "<< powering on '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
+
+ if (m_handler->TransmitImageViewOn(GetMyLogicalAddress(), m_iLogicalAddress))
+ {
+ {
+ CLockObject lock(m_mutex);
+// m_powerStatus = CEC_POWER_STATUS_UNKNOWN;
+ m_powerStatus = CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON;
+ }
+// cec_power_status status = GetPowerStatus();
+// if (status == CEC_POWER_STATUS_STANDBY || status == CEC_POWER_STATUS_UNKNOWN)
+// {
+// /* sending the normal power on command appears to have failed */
+// CStdString strLog;
+// strLog.Format("<< sending power on keypress to '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
+// CLibCEC::AddLog(CEC_LOG_DEBUG, strLog.c_str());
+//
+// TransmitKeypress(CEC_USER_CONTROL_CODE_POWER);
+// return TransmitKeyRelease();
+// }
+ return true;
+ }
+
+ return false;
}
-uint16_t CCECBusDevice::GetMyPhysicalAddress(void) const
+bool CCECBusDevice::Standby(void)
{
- return m_processor->GetPhysicalAddress();
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "<< putting '%s' (%X) in standby mode", GetLogicalAddressName(), m_iLogicalAddress);
+ return m_handler->TransmitStandby(GetMyLogicalAddress(), m_iLogicalAddress);
}
-void CCECBusDevice::AddLog(cec_log_level level, const CStdString &strMessage)
+/** @name Getters */
+//@{
+cec_version CCECBusDevice::GetCecVersion(bool bUpdate /* = false */)
{
- m_processor->AddLog(level, strMessage);
+ bool bRequestUpdate(false);
+ {
+ CLockObject lock(m_mutex);
+ bRequestUpdate = (GetStatus() == CEC_DEVICE_STATUS_PRESENT &&
+ (bUpdate || m_cecVersion == CEC_VERSION_UNKNOWN));
+ }
+
+ if (bRequestUpdate)
+ RequestCecVersion();
+
+ CLockObject lock(m_mutex);
+ return m_cecVersion;
}
-void CCECBusDevice::SetMenuLanguage(const cec_menu_language &language)
+bool CCECBusDevice::RequestCecVersion(void)
{
- if (language.device == m_iLogicalAddress)
+ bool bReturn(false);
+
+ if (!MyLogicalAddressContains(m_iLogicalAddress))
{
- CStdString strLog;
- strLog.Format("device %d menu language set to '%s'", m_iLogicalAddress, language.language);
- m_processor->AddLog(CEC_LOG_DEBUG, strLog);
- m_menuLanguage = language;
+ m_handler->MarkBusy();
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< requesting CEC version of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
+
+ bReturn = m_handler->TransmitRequestCecVersion(GetMyLogicalAddress(), m_iLogicalAddress);
+ m_handler->MarkReady();
}
+ return bReturn;
}
-void CCECBusDevice::SetCecVersion(const cec_version newVersion)
+const char* CCECBusDevice::GetLogicalAddressName(void) const
{
- CStdString strLog;
- m_cecVersion = newVersion;
+ return ToString(m_iLogicalAddress);
+}
- switch (newVersion)
+cec_menu_language &CCECBusDevice::GetMenuLanguage(bool bUpdate /* = false */)
+{
+ bool bRequestUpdate(false);
{
- case CEC_VERSION_1_2:
- strLog.Format("device %d reports CEC version 1.2", m_iLogicalAddress);
- break;
- case CEC_VERSION_1_2A:
- strLog.Format("device %d reports CEC version 1.2a", m_iLogicalAddress);
- break;
- case CEC_VERSION_1_3:
- strLog.Format("device %d reports CEC version 1.3", m_iLogicalAddress);
- break;
- case CEC_VERSION_1_3A:
- strLog.Format("device %d reports CEC version 1.3a", m_iLogicalAddress);
- break;
- default:
- strLog.Format("device %d reports an unknown CEC version", m_iLogicalAddress);
- m_cecVersion = CEC_VERSION_UNKNOWN;
- break;
+ CLockObject lock(m_mutex);
+ bRequestUpdate = (GetStatus() == CEC_DEVICE_STATUS_PRESENT &&
+ (bUpdate || !strcmp(m_menuLanguage.language, "???")));
}
- AddLog(CEC_LOG_DEBUG, strLog);
+
+ if (bRequestUpdate)
+ RequestMenuLanguage();
+
+ CLockObject lock(m_mutex);
+ return m_menuLanguage;
}
-void CCECBusDevice::SetPowerStatus(const cec_power_status powerStatus)
+bool CCECBusDevice::RequestMenuLanguage(void)
{
- if (m_powerStatus != powerStatus)
+ bool bReturn(false);
+
+ if (!MyLogicalAddressContains(m_iLogicalAddress) &&
+ !IsUnsupportedFeature(CEC_OPCODE_GET_MENU_LANGUAGE))
{
- CStdString strLog;
- strLog.Format("device %d power status changed from %2x to %2x", m_iLogicalAddress, m_powerStatus, powerStatus);
- m_processor->AddLog(CEC_LOG_DEBUG, strLog);
- m_powerStatus = powerStatus;
+ m_handler->MarkBusy();
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< requesting menu language of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
+ bReturn = m_handler->TransmitRequestMenuLanguage(GetMyLogicalAddress(), m_iLogicalAddress);
+ m_handler->MarkReady();
}
+ return bReturn;
+}
+
+cec_menu_state CCECBusDevice::GetMenuState(void)
+{
+ CLockObject lock(m_mutex);
+ return m_menuState;
+}
+
+cec_logical_address CCECBusDevice::GetMyLogicalAddress(void) const
+{
+ return m_processor->GetLogicalAddress();
}
-void CCECBusDevice::SetVendorId(const cec_datapacket &data)
+uint16_t CCECBusDevice::GetMyPhysicalAddress(void) const
{
- if (data.size < 3)
+ return m_processor->GetPhysicalAddress();
+}
+
+CStdString CCECBusDevice::GetOSDName(bool bUpdate /* = false */)
+{
+ bool bRequestUpdate(false);
{
- AddLog(CEC_LOG_WARNING, "invalid vendor ID received");
- return;
+ CLockObject lock(m_mutex);
+ bRequestUpdate = (GetStatus() == CEC_DEVICE_STATUS_PRESENT &&
+ (bUpdate || m_strDeviceName.Equals(ToString(m_iLogicalAddress))) &&
+ m_type != CEC_DEVICE_TYPE_TV);
}
- uint64_t iVendorId = ((uint64_t)data[0] << 3) +
- ((uint64_t)data[1] << 2) +
- (uint64_t)data[2];
+ if (bRequestUpdate)
+ RequestOSDName();
- SetVendorId(iVendorId, data.size >= 4 ? data[3] : 0);
+ CLockObject lock(m_mutex);
+ return m_strDeviceName;
}
-void CCECBusDevice::SetVendorId(uint64_t iVendorId, uint8_t iVendorClass /* = 0 */)
+bool CCECBusDevice::RequestOSDName(void)
{
- m_vendor.vendor = (cec_vendor_id)iVendorId;
- m_iVendorClass = iVendorClass;
+ bool bReturn(false);
- switch (iVendorId)
+ if (!MyLogicalAddressContains(m_iLogicalAddress) &&
+ !IsUnsupportedFeature(CEC_OPCODE_GIVE_OSD_NAME))
{
- case CEC_VENDOR_SAMSUNG:
- if (m_handler->GetVendorId() != CEC_VENDOR_SAMSUNG)
- {
- delete m_handler;
- m_handler = new CANCommandHandler(this);
- }
- break;
- case CEC_VENDOR_LG:
- if (m_handler->GetVendorId() != CEC_VENDOR_LG)
- {
- delete m_handler;
- m_handler = new CSLCommandHandler(this);
- }
- break;
- default:
- if (m_handler->GetVendorId() != CEC_VENDOR_UNKNOWN)
- {
- delete m_handler;
- m_handler = new CCECCommandHandler(this);
- }
- break;
+ m_handler->MarkBusy();
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< requesting OSD name of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
+ bReturn = m_handler->TransmitRequestOSDName(GetMyLogicalAddress(), m_iLogicalAddress);
+ m_handler->MarkReady();
}
-
- CStdString strLog;
- strLog.Format("device %d: vendor = %s (%06x) class = %2x", m_iLogicalAddress, GetVendorName(), GetVendorId(), GetVendorClass());
- m_processor->AddLog(CEC_LOG_DEBUG, strLog.c_str());
+ return bReturn;
}
-bool CCECBusDevice::HandleCommand(const cec_command &command)
+uint16_t CCECBusDevice::GetPhysicalAddress(bool bUpdate /* = false */)
{
- CLockObject lock(&m_mutex);
- m_iLastActive = GetTimeMs();
- m_handler->HandleCommand(command);
- m_condition.Signal();
- return true;
+ bool bRequestUpdate(false);
+ {
+ CLockObject lock(m_mutex);
+ bRequestUpdate = (GetStatus() == CEC_DEVICE_STATUS_PRESENT &&
+ (m_iPhysicalAddress == 0xFFFF || bUpdate));
+ }
+
+ if (bRequestUpdate && !RequestPhysicalAddress())
+ CLibCEC::AddLog(CEC_LOG_ERROR, "failed to request the physical address");
+
+ CLockObject lock(m_mutex);
+ return m_iPhysicalAddress;
}
-const cec_vendor &CCECBusDevice::GetVendor(void)
+bool CCECBusDevice::RequestPhysicalAddress(void)
{
- if (m_vendor.vendor == CEC_VENDOR_UNKNOWN)
+ bool bReturn(false);
+
+ if (!MyLogicalAddressContains(m_iLogicalAddress))
{
- AddLog(CEC_LOG_NOTICE, "<< requesting vendor ID");
- cec_command command;
- cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
- CLockObject lock(&m_mutex);
+ m_handler->MarkBusy();
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< requesting physical address of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
+ bReturn = m_handler->TransmitRequestPhysicalAddress(GetMyLogicalAddress(), m_iLogicalAddress);
+ m_handler->MarkReady();
+ }
+ return bReturn;
+}
- if (m_processor->Transmit(command))
- m_condition.Wait(&m_mutex, 1000);
+cec_power_status CCECBusDevice::GetPowerStatus(bool bUpdate /* = false */)
+{
+ bool bRequestUpdate(false);
+ {
+ CLockObject lock(m_mutex);
+ bRequestUpdate = (GetStatus() == CEC_DEVICE_STATUS_PRESENT &&
+ (bUpdate || m_powerStatus == CEC_POWER_STATUS_UNKNOWN ||
+ m_powerStatus == CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON ||
+ m_powerStatus == CEC_POWER_STATUS_IN_TRANSITION_ON_TO_STANDBY ||
+ GetTimeMs() - m_iLastPowerStateUpdate >= CEC_POWER_STATE_REFRESH_TIME));
}
- return m_vendor;
+ if (bRequestUpdate)
+ RequestPowerStatus();
+
+ CLockObject lock(m_mutex);
+ return m_powerStatus;
}
-void CCECBusDevice::PollVendorId(void)
+bool CCECBusDevice::RequestPowerStatus(void)
{
- CLockObject lock(&m_mutex);
- if (m_iLastActive > 0 && m_iLogicalAddress != CECDEVICE_BROADCAST &&
- m_vendor.vendor == CEC_VENDOR_UNKNOWN &&
- GetTimeMs() - m_iLastActive > 5000)
+ bool bReturn(false);
+
+ if (!MyLogicalAddressContains(m_iLogicalAddress) &&
+ !IsUnsupportedFeature(CEC_OPCODE_GIVE_DEVICE_POWER_STATUS))
{
- m_iLastActive = GetTimeMs();
+ m_handler->MarkBusy();
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< requesting power status of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
+ bReturn = m_handler->TransmitRequestPowerStatus(GetMyLogicalAddress(), m_iLogicalAddress);
+ m_handler->MarkReady();
+ }
+ return bReturn;
+}
- cec_command command;
- cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
- if (m_processor->Transmit(command))
- m_condition.Wait(&m_mutex, 1000);
+cec_vendor_id CCECBusDevice::GetVendorId(bool bUpdate /* = false */)
+{
+ bool bRequestUpdate(false);
+ {
+ CLockObject lock(m_mutex);
+ bRequestUpdate = (GetStatus() == CEC_DEVICE_STATUS_PRESENT &&
+ (bUpdate || m_vendor == CEC_VENDOR_UNKNOWN));
}
+
+ if (bRequestUpdate)
+ RequestVendorId();
+
+ CLockObject lock(m_mutex);
+ return m_vendor;
}
-void CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress, uint16_t iOldAddress /* = 0 */)
+bool CCECBusDevice::RequestVendorId(void)
{
- if (iNewAddress > 0)
+ bool bReturn(false);
+
+ if (!MyLogicalAddressContains(m_iLogicalAddress))
{
- CStdString strLog;
- strLog.Format(">> %i changed physical address from %04x to %04x", m_iLogicalAddress, m_iPhysicalAddress, iNewAddress);
- AddLog(CEC_LOG_DEBUG, strLog.c_str());
+ m_handler->MarkBusy();
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< requesting vendor ID of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
+ bReturn = m_handler->TransmitRequestVendorId(GetMyLogicalAddress(), m_iLogicalAddress);
+ m_handler->MarkReady();
- m_iPhysicalAddress = iNewAddress;
+ ReplaceHandler(true);
}
+ return bReturn;
}
-bool CCECBusDevice::PowerOn(void)
+const char *CCECBusDevice::GetVendorName(bool bUpdate /* = false */)
{
- CStdString strLog;
- strLog.Format("<< powering on device with logical address %d", (int8_t)m_iLogicalAddress);
- AddLog(CEC_LOG_DEBUG, strLog.c_str());
+ return ToString(GetVendorId(bUpdate));
+}
- cec_command command;
- cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_IMAGE_VIEW_ON);
+bool CCECBusDevice::MyLogicalAddressContains(cec_logical_address address) const
+{
+ return m_processor->HasLogicalAddress(address);
+}
- return m_processor->Transmit(command);
+bool CCECBusDevice::NeedsPoll(void)
+{
+ bool bSendPoll(false);
+ switch (m_iLogicalAddress)
+ {
+ case CECDEVICE_PLAYBACKDEVICE3:
+ if (m_processor->m_busDevices[CECDEVICE_PLAYBACKDEVICE2]->GetStatus() == CEC_DEVICE_STATUS_PRESENT)
+ bSendPoll = true;
+ break;
+ case CECDEVICE_PLAYBACKDEVICE2:
+ if (m_processor->m_busDevices[CECDEVICE_PLAYBACKDEVICE1]->GetStatus() == CEC_DEVICE_STATUS_PRESENT)
+ bSendPoll = true;
+ break;
+ case CECDEVICE_RECORDINGDEVICE3:
+ if (m_processor->m_busDevices[CECDEVICE_RECORDINGDEVICE2]->GetStatus() == CEC_DEVICE_STATUS_PRESENT)
+ bSendPoll = true;
+ break;
+ case CECDEVICE_RECORDINGDEVICE2:
+ if (m_processor->m_busDevices[CECDEVICE_RECORDINGDEVICE1]->GetStatus() == CEC_DEVICE_STATUS_PRESENT)
+ bSendPoll = true;
+ break;
+ case CECDEVICE_TUNER4:
+ if (m_processor->m_busDevices[CECDEVICE_TUNER3]->GetStatus() == CEC_DEVICE_STATUS_PRESENT)
+ bSendPoll = true;
+ break;
+ case CECDEVICE_TUNER3:
+ if (m_processor->m_busDevices[CECDEVICE_TUNER2]->GetStatus() == CEC_DEVICE_STATUS_PRESENT)
+ bSendPoll = true;
+ break;
+ case CECDEVICE_TUNER2:
+ if (m_processor->m_busDevices[CECDEVICE_TUNER1]->GetStatus() == CEC_DEVICE_STATUS_PRESENT)
+ bSendPoll = true;
+ break;
+ case CECDEVICE_AUDIOSYSTEM:
+ case CECDEVICE_PLAYBACKDEVICE1:
+ case CECDEVICE_RECORDINGDEVICE1:
+ case CECDEVICE_TUNER1:
+ case CECDEVICE_TV:
+ bSendPoll = true;
+ break;
+ default:
+ break;
+ }
+
+ return bSendPoll;
}
-bool CCECBusDevice::Standby(void)
+cec_bus_device_status CCECBusDevice::GetStatus(bool bForcePoll /* = false */)
{
- CStdString strLog;
- strLog.Format("<< putting device with logical address %d in standby mode", (int8_t)m_iLogicalAddress);
- AddLog(CEC_LOG_DEBUG, strLog.c_str());
+ CLockObject lock(m_mutex);
+ if (m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC &&
+ (m_deviceStatus == CEC_DEVICE_STATUS_UNKNOWN || bForcePoll))
+ {
+ lock.Unlock();
+ bool bPollAcked(false);
+ if (bForcePoll || NeedsPoll())
+ bPollAcked = m_processor->PollDevice(m_iLogicalAddress);
- cec_command command;
- cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_STANDBY);
+ lock.Lock();
+ m_deviceStatus = bPollAcked ? CEC_DEVICE_STATUS_PRESENT : CEC_DEVICE_STATUS_NOT_PRESENT;
+ }
- return m_processor->Transmit(command);
+ return m_deviceStatus;
}
-bool CCECBusDevice::SetOSDString(cec_display_control duration, const char *strMessage)
+//@}
+
+/** @name Setters */
+//@{
+void CCECBusDevice::SetCecVersion(const cec_version newVersion)
{
- CStdString strLog;
- strLog.Format("<< display message '%s'", strMessage);
- AddLog(CEC_LOG_NOTICE, strLog.c_str());
+ m_cecVersion = newVersion;
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "%s (%X): CEC version %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(newVersion));
+}
- cec_command command;
- cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_SET_OSD_STRING);
- command.parameters.push_back((uint8_t)duration);
+void CCECBusDevice::SetMenuLanguage(const cec_menu_language &language)
+{
+ CLockObject lock(m_mutex);
+ if (language.device == m_iLogicalAddress)
+ {
+ CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %s (%X): menu language set to '%s'", GetLogicalAddressName(), m_iLogicalAddress, language.language);
+ m_menuLanguage = language;
+ }
+}
- for (unsigned int iPtr = 0; iPtr < strlen(strMessage); iPtr++)
- command.parameters.push_back(strMessage[iPtr]);
+void CCECBusDevice::SetOSDName(CStdString strName)
+{
+ CLockObject lock(m_mutex);
+ if (m_strDeviceName != strName)
+ {
+ CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %s (%X): osd name set to '%s'", GetLogicalAddressName(), m_iLogicalAddress, strName.c_str());
+ m_strDeviceName = strName;
+ }
+}
- return m_processor->Transmit(command);
+void CCECBusDevice::SetMenuState(const cec_menu_state state)
+{
+ CLockObject lock(m_mutex);
+ if (m_menuState != state)
+ {
+ CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %s (%X): menu state set to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_menuState));
+ m_menuState = state;
+ }
+}
+
+void CCECBusDevice::SetInactiveSource(void)
+{
+ {
+ CLockObject lock(m_mutex);
+ m_bActiveSource = false;
+ }
+
+ if (MyLogicalAddressContains(m_iLogicalAddress))
+ SetPowerStatus(CEC_POWER_STATUS_STANDBY);
}
-bool CCECBusDevice::ReportCECVersion(cec_logical_address dest)
+void CCECBusDevice::SetActiveSource(void)
{
- AddLog(CEC_LOG_NOTICE, "<< reporting CEC version as 1.3a");
+ CLockObject lock(m_mutex);
+ if (!m_bActiveSource)
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "making %s (%x) the active source", GetLogicalAddressName(), m_iLogicalAddress);
- cec_command command;
- cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_CEC_VERSION);
- command.parameters.push_back(CEC_VERSION_1_3A);
+ for (int iPtr = 0; iPtr < 16; iPtr++)
+ if (iPtr != m_iLogicalAddress)
+ m_processor->m_busDevices[iPtr]->SetInactiveSource();
- return m_processor->Transmit(command);
+ m_bActiveSource = true;
+ m_powerStatus = CEC_POWER_STATUS_ON;
}
-bool CCECBusDevice::ReportDeckStatus(cec_logical_address dest)
+bool CCECBusDevice::TryLogicalAddress(void)
{
- // need to support opcodes play and deck control before doing anything with this
- AddLog(CEC_LOG_NOTICE, "<< deck status requested, feature abort");
- m_processor->TransmitAbort(dest, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "trying logical address '%s'", GetLogicalAddressName());
+
+ m_processor->SetAckMask(0);
+ if (!TransmitPoll(m_iLogicalAddress))
+ {
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "using logical address '%s'", GetLogicalAddressName());
+ SetDeviceStatus(CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC);
+
+ return true;
+ }
+
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "logical address '%s' already taken", GetLogicalAddressName());
+ SetDeviceStatus(CEC_DEVICE_STATUS_PRESENT);
return false;
}
-bool CCECBusDevice::ReportMenuState(cec_logical_address dest, bool bActive /* = true */)
+void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus)
{
- if (bActive)
- AddLog(CEC_LOG_NOTICE, "<< reporting menu state as active");
- else
- AddLog(CEC_LOG_NOTICE, "<< reporting menu state as inactive");
+ CLockObject lock(m_mutex);
+ switch (newStatus)
+ {
+ case CEC_DEVICE_STATUS_UNKNOWN:
+ m_iStreamPath = 0;
+ m_powerStatus = CEC_POWER_STATUS_UNKNOWN;
+ m_vendor = CEC_VENDOR_UNKNOWN;
+ m_menuState = CEC_MENU_STATE_ACTIVATED;
+ m_bActiveSource = false;
+ m_iLastActive = 0;
+ m_cecVersion = CEC_VERSION_UNKNOWN;
+ m_deviceStatus = newStatus;
+ break;
+ case CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC:
+ m_iStreamPath = 0;
+ m_powerStatus = CEC_POWER_STATUS_ON;
+ m_vendor = CEC_VENDOR_UNKNOWN;
+ m_menuState = CEC_MENU_STATE_ACTIVATED;
+ m_bActiveSource = false;
+ m_iLastActive = 0;
+ m_cecVersion = CEC_VERSION_1_3A;
+ m_deviceStatus = newStatus;
+ break;
+ case CEC_DEVICE_STATUS_PRESENT:
+ case CEC_DEVICE_STATUS_NOT_PRESENT:
+ m_deviceStatus = newStatus;
+ break;
+ }
+}
- 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);
+void CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress)
+{
+ CLockObject lock(m_mutex);
+ if (iNewAddress > 0 && m_iPhysicalAddress != iNewAddress)
+ {
+ CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %s (%X): physical address changed from %04x to %04x", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress, iNewAddress);
+ m_iPhysicalAddress = iNewAddress;
+ }
+}
+
+void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* = 0 */)
+{
+ CLockObject lock(m_mutex);
+ if (iNewAddress > 0)
+ {
+ CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %s (%X): stream path changed from %04x to %04x", GetLogicalAddressName(), m_iLogicalAddress, iOldAddress == 0 ? m_iStreamPath : iOldAddress, iNewAddress);
+ m_iStreamPath = iNewAddress;
- return m_processor->Transmit(command);
+ if (iNewAddress > 0)
+ {
+ lock.Unlock();
+ SetPowerStatus(CEC_POWER_STATUS_ON);
+ }
+ }
}
-bool CCECBusDevice::ReportOSDName(cec_logical_address dest)
+void CCECBusDevice::SetPowerStatus(const cec_power_status powerStatus)
{
- const char *osdname = m_processor->GetDeviceName().c_str();
- CStdString strLog;
- strLog.Format("<< reporting OSD name as %s", osdname);
- AddLog(CEC_LOG_NOTICE, strLog.c_str());
+ CLockObject lock(m_mutex);
+ if (m_powerStatus != powerStatus)
+ {
+ m_iLastPowerStateUpdate = GetTimeMs();
+ CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %s (%X): power status changed from '%s' to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_powerStatus), ToString(powerStatus));
+ m_powerStatus = powerStatus;
+ }
+}
+
+bool CCECBusDevice::ReplaceHandler(bool bActivateSource /* = true */)
+{
+ CLockObject lock(m_mutex);
+ CLockObject handlerLock(m_handlerMutex);
+
+ if (m_vendor != m_handler->GetVendorId())
+ {
+ if (CCECCommandHandler::HasSpecificHandler(m_vendor))
+ {
+ CStdString strLog;
+ if (m_handler->InUse())
+ {
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "handler for device '%s' (%x) is being used. not replacing the command handler", GetLogicalAddressName(), GetLogicalAddress());
+ return false;
+ }
+
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "replacing the command handler for device '%s' (%x)", GetLogicalAddressName(), GetLogicalAddress());
+ delete m_handler;
- cec_command command;
- cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_SET_OSD_NAME);
- for (unsigned int iPtr = 0; iPtr < strlen(osdname); iPtr++)
- command.parameters.push_back(osdname[iPtr]);
+ switch (m_vendor)
+ {
+ case CEC_VENDOR_SAMSUNG:
+ m_handler = new CANCommandHandler(this);
+ break;
+ case CEC_VENDOR_LG:
+ m_handler = new CSLCommandHandler(this);
+ break;
+ case CEC_VENDOR_PANASONIC:
+ m_handler = new CVLCommandHandler(this);
+ break;
+ default:
+ m_handler = new CCECCommandHandler(this);
+ break;
+ }
+
+ m_handler->SetVendorId(m_vendor);
+ m_handler->InitHandler();
+
+ if (bActivateSource && m_processor->GetLogicalAddresses().IsSet(m_iLogicalAddress) && m_processor->IsInitialised() && IsActiveSource())
+ m_handler->ActivateSource();
+ }
+ }
- return m_processor->Transmit(command);
+ return true;
}
-bool CCECBusDevice::ReportPowerState(cec_logical_address dest)
+bool CCECBusDevice::SetVendorId(uint64_t iVendorId)
{
- AddLog(CEC_LOG_NOTICE, "<< reporting \"On\" power status");
+ bool bVendorChanged(false);
- 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);
+ {
+ CLockObject lock(m_mutex);
+ bVendorChanged = (m_vendor != (cec_vendor_id)iVendorId);
+ m_vendor = (cec_vendor_id)iVendorId;
+ }
+
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "%s (%X): vendor = %s (%06x)", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_vendor), m_vendor);
- return m_processor->Transmit(command);
+ return bVendorChanged;
}
+//@}
-bool CCECBusDevice::ReportVendorID(cec_logical_address dest)
+/** @name Transmit methods */
+//@{
+bool CCECBusDevice::TransmitActiveSource(void)
{
- AddLog(CEC_LOG_NOTICE, "<< vendor ID requested, feature abort");
- m_processor->TransmitAbort(dest, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
+ bool bSendActiveSource(false);
+
+ {
+ CLockObject lock(m_mutex);
+ if (m_powerStatus != CEC_POWER_STATUS_ON)
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "<< %s (%X) is not powered on", GetLogicalAddressName(), m_iLogicalAddress);
+ else if (m_bActiveSource)
+ {
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> broadcast (F): active source (%4x)", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress);
+ bSendActiveSource = true;
+ }
+ else
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "<< %s (%X) is not the active source", GetLogicalAddressName(), m_iLogicalAddress);
+ }
+
+ if (bSendActiveSource)
+ {
+ m_handler->TransmitImageViewOn(m_iLogicalAddress, CECDEVICE_TV);
+ m_handler->TransmitActiveSource(m_iLogicalAddress, m_iPhysicalAddress);
+ return true;
+ }
+
return false;
}
-bool CCECBusDevice::BroadcastActiveView(void)
+bool CCECBusDevice::TransmitCECVersion(cec_logical_address dest)
{
- AddLog(CEC_LOG_DEBUG, "<< setting active view");
-
- cec_command command;
- cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_ACTIVE_SOURCE);
- command.parameters.push_back((m_iPhysicalAddress >> 8) & 0xFF);
- command.parameters.push_back(m_iPhysicalAddress & 0xFF);
+ cec_version version;
+ {
+ CLockObject lock(m_mutex);
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> %s (%X): cec version %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_cecVersion));
+ version = m_cecVersion;
+ }
- return m_processor->Transmit(command);
+ return m_handler->TransmitCECVersion(m_iLogicalAddress, dest, version);
}
-bool CCECBusDevice::BroadcastInactiveView(void)
+bool CCECBusDevice::TransmitInactiveSource(void)
{
- AddLog(CEC_LOG_DEBUG, "<< setting inactive view");
+ uint16_t iPhysicalAddress;
+ {
+ CLockObject lock(m_mutex);
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> broadcast (F): inactive source", GetLogicalAddressName(), m_iLogicalAddress);
+ iPhysicalAddress = m_iPhysicalAddress;
+ }
+
+ return m_handler->TransmitInactiveSource(m_iLogicalAddress, iPhysicalAddress);
+}
- cec_command command;
- cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_INACTIVE_SOURCE);
- command.parameters.push_back((m_iPhysicalAddress >> 8) & 0xFF);
- command.parameters.push_back(m_iPhysicalAddress & 0xFF);
+bool CCECBusDevice::TransmitMenuState(cec_logical_address dest)
+{
+ cec_menu_state menuState;
+ {
+ CLockObject lock(m_mutex);
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> %s (%X): menu state '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_menuState));
+ menuState = m_menuState;
+ }
- return m_processor->Transmit(command);
+ return m_handler->TransmitMenuState(m_iLogicalAddress, dest, menuState);
}
-bool CCECBusDevice::BroadcastPhysicalAddress(void)
+bool CCECBusDevice::TransmitOSDName(cec_logical_address dest)
{
- CStdString strLog;
- strLog.Format("<< reporting physical address as %04x", m_iPhysicalAddress);
- AddLog(CEC_LOG_NOTICE, strLog.c_str());
+ CStdString strDeviceName;
+ {
+ CLockObject lock(m_mutex);
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> %s (%X): OSD name '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, m_strDeviceName.c_str());
+ strDeviceName = m_strDeviceName;
+ }
- cec_command command;
- cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_REPORT_PHYSICAL_ADDRESS);
- command.parameters.push_back((uint8_t) ((m_iPhysicalAddress >> 8) & 0xFF));
- command.parameters.push_back((uint8_t) (m_iPhysicalAddress & 0xFF));
- command.parameters.push_back((uint8_t) (CEC_DEVICE_TYPE_PLAYBACK_DEVICE));
+ return m_handler->TransmitOSDName(m_iLogicalAddress, dest, strDeviceName);
+}
- return m_processor->Transmit(command);
+bool CCECBusDevice::TransmitOSDString(cec_logical_address dest, cec_display_control duration, const char *strMessage)
+{
+ if (!IsUnsupportedFeature(CEC_OPCODE_SET_OSD_STRING))
+ {
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> %s (%X): display OSD message '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, strMessage);
+ return m_handler->TransmitOSDString(m_iLogicalAddress, dest, duration, strMessage);
+ }
+ return false;
}
-bool CCECBusDevice::BroadcastActiveSource(void)
+bool CCECBusDevice::TransmitPhysicalAddress(void)
{
- AddLog(CEC_LOG_NOTICE, "<< broadcasting active source");
+ uint16_t iPhysicalAddress;
+ cec_device_type type;
+ {
+ CLockObject lock(m_mutex);
+ if (m_iPhysicalAddress == 0xffff)
+ return false;
- cec_command command;
- cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_ACTIVE_SOURCE);
- command.parameters.push_back((uint8_t) ((m_iPhysicalAddress >> 8) & 0xFF));
- command.parameters.push_back((uint8_t) (m_iPhysicalAddress & 0xFF));
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> broadcast (F): physical adddress %4x", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress);
+ iPhysicalAddress = m_iPhysicalAddress;
+ type = m_type;
+ }
- return m_processor->Transmit(command);
+ return m_handler->TransmitPhysicalAddress(m_iLogicalAddress, iPhysicalAddress, type);
}
-cec_version CCECBusDevice::GetCecVersion(bool bRefresh /* = true */)
+bool CCECBusDevice::TransmitPoll(cec_logical_address dest)
{
- if (bRefresh || m_cecVersion == CEC_VERSION_UNKNOWN)
+ bool bReturn(false);
+ if (dest == CECDEVICE_UNKNOWN)
+ dest = m_iLogicalAddress;
+
+ CCECBusDevice *destDevice = m_processor->m_busDevices[dest];
+ if (destDevice->m_deviceStatus == CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC)
+ return bReturn;
+
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> %s (%X): POLL", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest);
+ bReturn = m_handler->TransmitPoll(m_iLogicalAddress, dest);
+ CLibCEC::AddLog(CEC_LOG_DEBUG, bReturn ? ">> POLL sent" : ">> POLL not sent");
+
+ CLockObject lock(m_mutex);
+ if (bReturn)
{
- AddLog(CEC_LOG_NOTICE, "<< requesting CEC version");
- cec_command command;
- cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GET_CEC_VERSION);
- CLockObject lock(&m_mutex);
- if (m_processor->Transmit(command))
- m_condition.Wait(&m_mutex, 1000);
+ m_iLastActive = GetTimeMs();
+ destDevice->m_deviceStatus = CEC_DEVICE_STATUS_PRESENT;
}
+ else
+ destDevice->m_deviceStatus = CEC_DEVICE_STATUS_NOT_PRESENT;
- return m_cecVersion;
+ return bReturn;
}
-cec_menu_language &CCECBusDevice::GetMenuLanguage(bool bRefresh /* = true */)
+bool CCECBusDevice::TransmitPowerState(cec_logical_address dest)
{
- if (bRefresh || !strcmp(m_menuLanguage.language, "???"))
+ cec_power_status state;
{
- AddLog(CEC_LOG_NOTICE, "<< requesting menu language");
- cec_command command;
- cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GET_MENU_LANGUAGE);
- CLockObject lock(&m_mutex);
- if (m_processor->Transmit(command))
- m_condition.Wait(&m_mutex, 1000);
+ CLockObject lock(m_mutex);
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> %s (%X): %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_powerStatus));
+ state = m_powerStatus;
}
- return m_menuLanguage;
+ return m_handler->TransmitPowerState(m_iLogicalAddress, dest, state);
}
-cec_power_status CCECBusDevice::GetPowerStatus(bool bRefresh /* = true */)
+bool CCECBusDevice::TransmitVendorID(cec_logical_address dest, bool bSendAbort /* = true */)
{
- if (bRefresh || m_powerStatus == CEC_POWER_STATUS_UNKNOWN)
+ uint64_t iVendorId;
{
- AddLog(CEC_LOG_NOTICE, "<< requesting power status");
- cec_command command;
- cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_POWER_STATUS);
- CLockObject lock(&m_mutex);
- if (m_processor->Transmit(command))
- m_condition.Wait(&m_mutex, 1000);
+ CLockObject lock(m_mutex);
+ iVendorId = (uint64_t)m_vendor;
}
- return m_powerStatus;
+ if (iVendorId == CEC_VENDOR_UNKNOWN)
+ {
+ if (bSendAbort)
+ {
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> %s (%X): vendor id feature abort", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest);
+ m_processor->TransmitAbort(dest, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
+ }
+ return false;
+ }
+ else
+ {
+ CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> %s (%X): vendor id %s (%x)", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString((cec_vendor_id)iVendorId), iVendorId);
+ return m_handler->TransmitVendorID(m_iLogicalAddress, iVendorId);
+ }
}
-bool CCECBusDevice::PollDevice(cec_logical_address source /* = CECDEVICE_UNKNOWN */)
+bool CCECBusDevice::TransmitKeypress(cec_user_control_code key, bool bWait /* = true */)
{
- bool bReturn(false);
+ return m_handler->TransmitKeypress(m_processor->GetLogicalAddress(), m_iLogicalAddress, key, bWait);
+}
+
+bool CCECBusDevice::TransmitKeyRelease(bool bWait /* = true */)
+{
+ return m_handler->TransmitKeyRelease(m_processor->GetLogicalAddress(), m_iLogicalAddress, bWait);
+}
+
+bool CCECBusDevice::IsUnsupportedFeature(cec_opcode opcode) const
+{
+ return m_unsupportedFeatures.find(opcode) != m_unsupportedFeatures.end();
+}
- if (source == CECDEVICE_UNKNOWN)
- source = GetMyLogicalAddress();
+void CCECBusDevice::SetUnsupportedFeature(cec_opcode opcode)
+{
+ m_unsupportedFeatures.insert(opcode);
+}
- CStdString strLog;
- strLog.Format("<< sending POLL from device %1x to device %1x", (int8_t)source, m_iLogicalAddress);
- AddLog(CEC_LOG_DEBUG, strLog);
+bool CCECBusDevice::ActivateSource(void)
+{
+ CLockObject lock(m_mutex);
+ return m_handler->ActivateSource();
+}
- cec_command command;
- cec_command::format(command, source, m_iLogicalAddress, CEC_OPCODE_NONE);
- CLockObject lock(&m_mutex);
+void CCECBusDevice::HandlePoll(cec_logical_address iDestination)
+{
+ CLockObject lock(m_mutex);
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "<< POLL: %s (%x) -> %s (%x)", ToString(m_iLogicalAddress), m_iLogicalAddress, ToString(iDestination), iDestination);
+ m_bAwaitingReceiveFailed = true;
+}
- bReturn = m_processor->Transmit(command);
- AddLog(CEC_LOG_DEBUG, bReturn ? ">> POLL sent" : ">> POLL not sent");
+bool CCECBusDevice::HandleReceiveFailed(void)
+{
+ CLockObject lock(m_handlerMutex);
+ bool bReturn = m_bAwaitingReceiveFailed;
+ m_bAwaitingReceiveFailed = false;
return bReturn;
}
+
+//@}