From: Lars Op den Kamp Date: Mon, 15 Oct 2012 12:11:32 +0000 (+0200) Subject: Merge branch 'development'. closes #67 X-Git-Tag: upstream/2.2.0~1^2~14^2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=270e872981d615bd362407527100d345684e2f3d;hp=b272f558d4b0567f581d8cea04a6ac2b6ed49146;p=deb_libcec.git Merge branch 'development'. closes #67 --- diff --git a/ChangeLog b/ChangeLog index ccb10d2..983d006 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +libcec (2.0.2-2) unstable; urgency=medium + + * fixed: + * updating the device status after a poll was broken and could reset the + status of devices that were marked as handled by libCEC to 'not + present' + * don't keep spamming the bus with a vendor command when an active source + switch is pending for panasonic, but only send it when needed + * reset CVLCommandHandler::m_bCapabilitiesSent when the TV goes to standby + + -- Pulse-Eight Packaging Mon, 15 Oct 2012 13:52:00 +0100 + libcec (2.0.2-1) unstable; urgency=low * changed/added: diff --git a/configure.ac b/configure.ac index d3b17e9..df63c2d 100644 --- a/configure.ac +++ b/configure.ac @@ -110,7 +110,7 @@ AC_CHECK_FUNCS([pthread_mutexattr_init pthread_cond_init pthread_cond_destroy pt AC_SEARCH_LIBS([dlopen], [dl], [test "$ac_cv_search_dlopen" = "none required" || LIBS_DL=$ac_cv_search_dlopen], AC_MSG_ERROR($msg_dl_missing)) -AC_CHECK_FUNCS([dlopen dlcose dlsym]) +AC_CHECK_FUNCS([dlopen dlclose dlsym]) ## platform specific libs, required by all targets case "${host}" in diff --git a/debian/changelog b/debian/changelog index ccb10d2..983d006 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +libcec (2.0.2-2) unstable; urgency=medium + + * fixed: + * updating the device status after a poll was broken and could reset the + status of devices that were marked as handled by libCEC to 'not + present' + * don't keep spamming the bus with a vendor command when an active source + switch is pending for panasonic, but only send it when needed + * reset CVLCommandHandler::m_bCapabilitiesSent when the TV goes to standby + + -- Pulse-Eight Packaging Mon, 15 Oct 2012 13:52:00 +0100 + libcec (2.0.2-1) unstable; urgency=low * changed/added: diff --git a/include/cec.h b/include/cec.h index d10f433..ba12a87 100644 --- a/include/cec.h +++ b/include/cec.h @@ -36,7 +36,7 @@ #include "cectypes.h" -#define LIBCEC_VERSION_CURRENT CEC_SERVER_VERSION_2_0_1 +#define LIBCEC_VERSION_CURRENT CEC_SERVER_VERSION_2_0_2 namespace CEC { diff --git a/include/cectypes.h b/include/cectypes.h index f68007b..6b7f73c 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -1375,6 +1375,7 @@ typedef enum cec_client_version CEC_CLIENT_VERSION_1_99_0 = 0x1990, CEC_CLIENT_VERSION_2_0_0 = 0x2000, CEC_CLIENT_VERSION_2_0_1 = 0x2001, + CEC_CLIENT_VERSION_2_0_2 = 0x2002, } cec_client_version; typedef enum cec_server_version @@ -1398,6 +1399,7 @@ typedef enum cec_server_version CEC_SERVER_VERSION_1_99_0 = 0x1990, CEC_SERVER_VERSION_2_0_0 = 0x2000, CEC_SERVER_VERSION_2_0_1 = 0x2001, + CEC_SERVER_VERSION_2_0_2 = 0x2002, } cec_server_version; struct libcec_configuration diff --git a/project/cec-config.rc b/project/cec-config.rc index bc1299d..7a9da22 100644 Binary files a/project/cec-config.rc and b/project/cec-config.rc differ diff --git a/project/libCEC.nsi b/project/libCEC.nsi index 5148406..5860b2e 100644 --- a/project/libCEC.nsi +++ b/project/libCEC.nsi @@ -7,7 +7,7 @@ !include "LogicLib.nsh" !include "x64.nsh" -Name "Pulse-Eight libCEC version 2.0.0" +Name "Pulse-Eight libCEC version 2.0.2" OutFile "..\build\libCEC-installer.exe" XPStyle on diff --git a/project/libcec.rc b/project/libcec.rc index 2f85a67..b925f41 100644 Binary files a/project/libcec.rc and b/project/libcec.rc differ diff --git a/project/testclient.rc b/project/testclient.rc index 1d6382b..abb8ee4 100644 Binary files a/project/testclient.rc and b/project/testclient.rc differ diff --git a/src/CecSharpTester/CecSharpClient.cs b/src/CecSharpTester/CecSharpClient.cs index 37b04e9..cd9b0e9 100644 --- a/src/CecSharpTester/CecSharpClient.cs +++ b/src/CecSharpTester/CecSharpClient.cs @@ -43,7 +43,7 @@ namespace CecSharpClient Config = new LibCECConfiguration(); Config.DeviceTypes.Types[0] = CecDeviceType.RecordingDevice; Config.DeviceName = "CEC Tester"; - Config.ClientVersion = CecClientVersion.Version2_0_0; + Config.ClientVersion = CecClientVersion.Version2_0_2; Config.SetCallbacks(this); LogLevel = (int)CecLogLevel.All; diff --git a/src/CecSharpTester/Properties/AssemblyInfo.cs b/src/CecSharpTester/Properties/AssemblyInfo.cs index 799111d..23128fc 100644 --- a/src/CecSharpTester/Properties/AssemblyInfo.cs +++ b/src/CecSharpTester/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.1.0")] -[assembly: AssemblyFileVersion("2.0.1.0")] +[assembly: AssemblyVersion("2.0.2.0")] +[assembly: AssemblyFileVersion("2.0.2.0")] diff --git a/src/LibCecSharp/AssemblyInfo.cpp b/src/LibCecSharp/AssemblyInfo.cpp index bb64ab4..fe944b5 100644 --- a/src/LibCecSharp/AssemblyInfo.cpp +++ b/src/LibCecSharp/AssemblyInfo.cpp @@ -13,7 +13,7 @@ using namespace System::Security::Permissions; [assembly:AssemblyTrademarkAttribute("")]; [assembly:AssemblyCultureAttribute("")]; -[assembly:AssemblyVersionAttribute("2.0.1.0")]; +[assembly:AssemblyVersionAttribute("2.0.2.0")]; [assembly:ComVisible(false)]; [assembly:CLSCompliantAttribute(true)]; diff --git a/src/LibCecSharp/CecSharpTypes.h b/src/LibCecSharp/CecSharpTypes.h index 908b3fc..e183be3 100644 --- a/src/LibCecSharp/CecSharpTypes.h +++ b/src/LibCecSharp/CecSharpTypes.h @@ -1167,7 +1167,11 @@ namespace CecSharp /// /// v2.0.1 /// - Version2_0_1 = 0x2001 + Version2_0_1 = 0x2001, + /// + /// v2.0.2 + /// + Version2_0_2 = 0x2002 }; /// @@ -1250,7 +1254,11 @@ namespace CecSharp /// /// v2.0.1 /// - Version2_0_1 = 0x2001 + Version2_0_1 = 0x2001, + /// + /// v2.0.2 + /// + Version2_0_2 = 0x2002 }; /// diff --git a/src/LibCecTray/Properties/AssemblyInfo.cs b/src/LibCecTray/Properties/AssemblyInfo.cs index 80c33c6..aad28dd 100644 --- a/src/LibCecTray/Properties/AssemblyInfo.cs +++ b/src/LibCecTray/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.1.0")] -[assembly: AssemblyFileVersion("2.0.1.0")] +[assembly: AssemblyVersion("2.0.2.0")] +[assembly: AssemblyFileVersion("2.0.2.0")] diff --git a/src/LibCecTray/controller/CECController.cs b/src/LibCecTray/controller/CECController.cs index f81cd94..ebce4ba 100644 --- a/src/LibCecTray/controller/CECController.cs +++ b/src/LibCecTray/controller/CECController.cs @@ -438,7 +438,7 @@ namespace LibCECTray.controller { if (_config == null) { - _config = new LibCECConfiguration { DeviceName = "CEC Tray", ClientVersion = CecClientVersion.Version2_0_0 }; + _config = new LibCECConfiguration { DeviceName = "CEC Tray", ClientVersion = CecClientVersion.Version2_0_2 }; _config.DeviceTypes.Types[0] = CecDeviceType.RecordingDevice; _config.SetCallbacks(this); diff --git a/src/cec-config/cec-config.cpp b/src/cec-config/cec-config.cpp index 380adee..a7cae9c 100644 --- a/src/cec-config/cec-config.cpp +++ b/src/cec-config/cec-config.cpp @@ -160,7 +160,7 @@ bool OpenConnection(cec_device_type type = CEC_DEVICE_TYPE_RECORDING_DEVICE) g_config.Clear(); snprintf(g_config.strDeviceName, 13, "CEC-config"); g_config.callbackParam = NULL; - g_config.clientVersion = (uint32_t)CEC_CLIENT_VERSION_2_0_0; + g_config.clientVersion = (uint32_t)CEC_CLIENT_VERSION_2_0_2; g_callbacks.CBCecLogMessage = &CecLogMessage; g_callbacks.CBCecKeyPress = &CecKeyPress; g_callbacks.CBCecCommand = &CecCommand; diff --git a/src/lib/CECClient.cpp b/src/lib/CECClient.cpp index f85a53c..a5a960e 100644 --- a/src/lib/CECClient.cpp +++ b/src/lib/CECClient.cpp @@ -1255,7 +1255,7 @@ bool CCECClient::PollDevice(const cec_logical_address iAddress) CCECBusDevice *primary = GetPrimaryDevice(); // poll the destination, with the primary as source if (primary) - return primary->TransmitPoll(iAddress, false); + return primary->TransmitPoll(iAddress, true); return m_processor ? m_processor->PollDevice(iAddress) : false; } diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index cc6adda..73c921d 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -315,11 +315,11 @@ bool CCECProcessor::PollDevice(cec_logical_address iAddress) CCECBusDevice *primary = GetPrimaryDevice(); // poll the destination, with the primary as source if (primary) - return primary->TransmitPoll(iAddress, false); + return primary->TransmitPoll(iAddress, true); CCECBusDevice *device = m_busDevices->At(CECDEVICE_UNREGISTERED); if (device) - return device->TransmitPoll(iAddress, false); + return device->TransmitPoll(iAddress, true); return false; } diff --git a/src/lib/CECTypeUtils.h b/src/lib/CECTypeUtils.h index 5d34b46..21a651d 100644 --- a/src/lib/CECTypeUtils.h +++ b/src/lib/CECTypeUtils.h @@ -559,6 +559,8 @@ namespace CEC return "2.0.0"; case CEC_CLIENT_VERSION_2_0_1: return "2.0.1"; + case CEC_CLIENT_VERSION_2_0_2: + return "2.0.2"; default: return "Unknown"; } @@ -602,10 +604,12 @@ namespace CEC return "1.9.0"; case CEC_SERVER_VERSION_1_99_0: return "2.0.0-pre"; - case CEC_CLIENT_VERSION_2_0_0: + case CEC_SERVER_VERSION_2_0_0: return "2.0.0"; - case CEC_CLIENT_VERSION_2_0_1: + case CEC_SERVER_VERSION_2_0_1: return "2.0.1"; + case CEC_SERVER_VERSION_2_0_2: + return "2.0.2"; default: return "Unknown"; } diff --git a/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.cpp b/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.cpp index cf97ea9..717e7d3 100644 --- a/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.cpp +++ b/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.cpp @@ -85,7 +85,9 @@ uint16_t CUSBCECAdapterCommands::RequestFirmwareVersion(void) while (m_persistedConfiguration.iFirmwareVersion == CEC_FW_VERSION_UNKNOWN && iFwVersionTry++ < 3) { +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "requesting the firmware version"); +#endif cec_datapacket response = RequestSetting(MSGCODE_FIRMWARE_VERSION); if (response.size == 2) m_persistedConfiguration.iFirmwareVersion = (response[0] << 8 | response[1]); @@ -107,7 +109,9 @@ uint16_t CUSBCECAdapterCommands::RequestFirmwareVersion(void) bool CUSBCECAdapterCommands::RequestSettingAutoEnabled(void) { +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "requesting autonomous mode setting"); +#endif cec_datapacket response = RequestSetting(MSGCODE_GET_AUTO_ENABLED); if (response.size == 1) @@ -121,7 +125,9 @@ bool CUSBCECAdapterCommands::RequestSettingAutoEnabled(void) bool CUSBCECAdapterCommands::RequestSettingCECVersion(void) { +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "requesting CEC version setting"); +#endif cec_datapacket response = RequestSetting(MSGCODE_GET_HDMI_VERSION); if (response.size == 1) @@ -137,7 +143,9 @@ p8_cec_adapter_type CUSBCECAdapterCommands::RequestAdapterType(void) { if (m_adapterType == P8_ADAPTERTYPE_UNKNOWN) { +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "requesting adapter type"); +#endif cec_datapacket response = RequestSetting(MSGCODE_GET_ADAPTER_TYPE); if (response.size == 1) @@ -150,7 +158,9 @@ uint32_t CUSBCECAdapterCommands::RequestBuildDate(void) { if (m_iBuildDate == CEC_FW_BUILD_UNKNOWN) { +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "requesting firmware build date"); +#endif cec_datapacket response = RequestSetting(MSGCODE_GET_BUILDDATE); if (response.size == 4) @@ -161,7 +171,9 @@ uint32_t CUSBCECAdapterCommands::RequestBuildDate(void) bool CUSBCECAdapterCommands::RequestSettingDefaultLogicalAddress(void) { +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "requesting default logical address setting"); +#endif cec_datapacket response = RequestSetting(MSGCODE_GET_DEFAULT_LOGICAL_ADDRESS); if (response.size == 1) @@ -175,7 +187,9 @@ bool CUSBCECAdapterCommands::RequestSettingDefaultLogicalAddress(void) bool CUSBCECAdapterCommands::RequestSettingDeviceType(void) { +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "requesting device type setting"); +#endif m_persistedConfiguration.deviceTypes.Clear(); cec_datapacket response = RequestSetting(MSGCODE_GET_DEVICE_TYPE); @@ -191,7 +205,9 @@ bool CUSBCECAdapterCommands::RequestSettingDeviceType(void) bool CUSBCECAdapterCommands::RequestSettingLogicalAddressMask(void) { +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "requesting logical address mask setting"); +#endif cec_datapacket response = RequestSetting(MSGCODE_GET_LOGICAL_ADDRESS_MASK); if (response.size == 2) @@ -205,7 +221,9 @@ bool CUSBCECAdapterCommands::RequestSettingLogicalAddressMask(void) bool CUSBCECAdapterCommands::RequestSettingOSDName(void) { +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "requesting OSD name setting"); +#endif memset(m_persistedConfiguration.strDeviceName, 0, 13); cec_datapacket response = RequestSetting(MSGCODE_GET_OSD_NAME); @@ -227,7 +245,9 @@ bool CUSBCECAdapterCommands::RequestSettingOSDName(void) bool CUSBCECAdapterCommands::RequestSettingPhysicalAddress(void) { +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "requesting physical address setting"); +#endif cec_datapacket response = RequestSetting(MSGCODE_GET_PHYSICAL_ADDRESS); if (response.size == 2) @@ -544,7 +564,9 @@ bool CUSBCECAdapterCommands::GetConfiguration(libcec_configuration &configuratio bool CUSBCECAdapterCommands::PingAdapter(void) { +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "sending ping"); +#endif CCECAdapterMessage params; CCECAdapterMessage *message = m_comm->SendCommand(MSGCODE_PING, params); diff --git a/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp b/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp index daaa72a..e1fcae6 100644 --- a/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp +++ b/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp @@ -110,7 +110,9 @@ void CRPiCECAdapterCommunication::OnDataReceived(uint32_t header, uint32_t p0, u { VC_CEC_NOTIFY_T reason = (VC_CEC_NOTIFY_T)CEC_CB_REASON(header); +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "received data: header:%08X p0:%08X p1:%08X p2:%08X p3:%08X reason:%x", header, p0, p1, p2, p3, reason); +#endif switch (reason) { diff --git a/src/lib/adapter/RPi/RPiCECAdapterMessageQueue.cpp b/src/lib/adapter/RPi/RPiCECAdapterMessageQueue.cpp index df9a374..656a25d 100644 --- a/src/lib/adapter/RPi/RPiCECAdapterMessageQueue.cpp +++ b/src/lib/adapter/RPi/RPiCECAdapterMessageQueue.cpp @@ -151,11 +151,13 @@ bool CRPiCECAdapterMessageQueue::Write(const cec_command &command, bool bIsReply message.payload[iPtr + 1] = command.parameters.At(iPtr); } +#ifdef CEC_DEBUGGING CStdString strDump; strDump.Format("len = %d, payload = %X%X", message.length, (int)message.initiator, (int)message.follower); for (uint8_t iPtr = 0; iPtr < message.length - 1; iPtr++) strDump.AppendFormat(":%02X", message.payload[iPtr]); LIB_CEC->AddLog(CEC_LOG_DEBUG, "sending data: %s", strDump.c_str()); +#endif int iReturn = vc_cec_send_message2(&message); #else @@ -172,11 +174,13 @@ bool CRPiCECAdapterMessageQueue::Write(const cec_command &command, bool bIsReply payload[iPtr + 1] = command.parameters.At(iPtr); } +#ifdef CEC_DEBUGGING CStdString strDump; strDump.Format("len = %d, payload = %X%X", iLength, (int)command.initiator, (int)command.destination); for (uint8_t iPtr = 0; iPtr < iLength; iPtr++) strDump.AppendFormat(":%02X", payload[iPtr]); LIB_CEC->AddLog(CEC_LOG_DEBUG, "sending data: %s", strDump.c_str()); +#endif int iReturn = vc_cec_send_message((uint32_t)command.destination, (uint8_t*)&payload, iLength, bIsReply); #endif diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index b42230d..5137cfb 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -618,7 +618,6 @@ bool CCECBusDevice::RequestPowerStatus(const cec_logical_address initiator, bool !IsUnsupportedFeature(CEC_OPCODE_GIVE_DEVICE_POWER_STATUS)) { MarkBusy(); - LIB_CEC->AddLog(CEC_LOG_DEBUG, "<< requesting power status of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress); bReturn = m_handler->TransmitRequestPowerStatus(initiator, m_iLogicalAddress, bWaitForResponse); MarkReady(); } @@ -741,7 +740,8 @@ cec_bus_device_status CCECBusDevice::GetStatus(bool bForcePoll /* = false */, bo CLockObject lock(m_mutex); status = m_deviceStatus; bNeedsPoll = !bSuppressPoll && - (bForcePoll || m_deviceStatus == CEC_DEVICE_STATUS_UNKNOWN); + (bForcePoll || m_deviceStatus == CEC_DEVICE_STATUS_UNKNOWN) && + m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC; } if (bNeedsPoll) @@ -782,6 +782,7 @@ void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus, cec_v if (m_deviceStatus != newStatus) LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s (%X): device status changed into 'present'", GetLogicalAddressName(), m_iLogicalAddress); m_deviceStatus = newStatus; + m_iLastActive = GetTimeMs(); break; case CEC_DEVICE_STATUS_NOT_PRESENT: if (m_deviceStatus != newStatus) @@ -819,7 +820,7 @@ void CCECBusDevice::ResetDeviceStatus(void) m_deviceStatus = CEC_DEVICE_STATUS_UNKNOWN; } -bool CCECBusDevice::TransmitPoll(const cec_logical_address dest, bool bIsReply) +bool CCECBusDevice::TransmitPoll(const cec_logical_address dest, bool bUpdateDeviceStatus) { bool bReturn(false); cec_logical_address destination(dest); @@ -832,17 +833,11 @@ bool CCECBusDevice::TransmitPoll(const cec_logical_address dest, bool bIsReply) MarkBusy(); LIB_CEC->AddLog(CEC_LOG_DEBUG, "<< %s (%X) -> %s (%X): POLL", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest); - bReturn = m_handler->TransmitPoll(m_iLogicalAddress, destination, bIsReply); + bReturn = m_handler->TransmitPoll(m_iLogicalAddress, destination, false); LIB_CEC->AddLog(CEC_LOG_DEBUG, bReturn ? ">> POLL sent" : ">> POLL not sent"); - CLockObject lock(m_mutex); - if (bReturn) - { - m_iLastActive = GetTimeMs(); - SetDeviceStatus(CEC_DEVICE_STATUS_PRESENT); - } - else - SetDeviceStatus(CEC_DEVICE_STATUS_NOT_PRESENT); + if (bUpdateDeviceStatus) + destDevice->SetDeviceStatus(bReturn ? CEC_DEVICE_STATUS_PRESENT : CEC_DEVICE_STATUS_NOT_PRESENT); MarkReady(); return bReturn; diff --git a/src/lib/devices/CECBusDevice.h b/src/lib/devices/CECBusDevice.h index d208fd9..fad7191 100644 --- a/src/lib/devices/CECBusDevice.h +++ b/src/lib/devices/CECBusDevice.h @@ -206,7 +206,7 @@ namespace CEC virtual cec_bus_device_status GetStatus(bool bForcePoll = false, bool bSuppressPoll = false); virtual void SetDeviceStatus(const cec_bus_device_status newStatus, cec_version libCECSpecVersion = CEC_VERSION_1_4); virtual void ResetDeviceStatus(void); - virtual bool TransmitPoll(const cec_logical_address destination, bool bIsReply); + virtual bool TransmitPoll(const cec_logical_address destination, bool bUpdateDeviceStatus); virtual void HandlePoll(const cec_logical_address destination); virtual void HandlePollFrom(const cec_logical_address initiator); virtual bool HandleReceiveFailed(void); diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 8dcc255..5398513 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -48,6 +48,7 @@ using namespace PLATFORM; #define LIB_CEC m_busDevice->GetProcessor()->GetLib() #define ToString(p) CCECTypeUtils::ToString(p) +#define REQUEST_POWER_STATUS_TIMEOUT 5000 CCECCommandHandler::CCECCommandHandler(CCECBusDevice *busDevice, int32_t iTransmitTimeout /* = CEC_DEFAULT_TRANSMIT_TIMEOUT */, @@ -62,7 +63,8 @@ CCECCommandHandler::CCECCommandHandler(CCECBusDevice *busDevice, m_bHandlerInited(false), m_bOPTSendDeckStatusUpdateOnActiveSource(false), m_vendorId(CEC_VENDOR_UNKNOWN), - m_iActiveSourcePending(iActiveSourcePending) + m_iActiveSourcePending(iActiveSourcePending), + m_iPowerStatusRequested(0) { } @@ -815,7 +817,14 @@ bool CCECCommandHandler::TransmitImageViewOn(const cec_logical_address iInitiato cec_command command; cec_command::Format(command, iInitiator, iDestination, CEC_OPCODE_IMAGE_VIEW_ON); - return Transmit(command, false, false); + if (Transmit(command, false, false)) + { + CCECBusDevice* dest = m_processor->GetDevice(iDestination); + if (dest && dest->GetCurrentPowerStatus() != CEC_POWER_STATUS_ON) + dest->SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON); + return true; + } + return false; } bool CCECCommandHandler::TransmitStandby(const cec_logical_address iInitiator, const cec_logical_address iDestination) @@ -868,6 +877,16 @@ bool CCECCommandHandler::TransmitRequestPhysicalAddress(const cec_logical_addres bool CCECCommandHandler::TransmitRequestPowerStatus(const cec_logical_address iInitiator, const cec_logical_address iDestination, bool bWaitForResponse /* = true */) { + if (iDestination == CECDEVICE_TV) + { + int64_t now(GetTimeMs()); + if (now - m_iPowerStatusRequested < REQUEST_POWER_STATUS_TIMEOUT) + return true; + m_iPowerStatusRequested = now; + } + + LIB_CEC->AddLog(CEC_LOG_DEBUG, "<< requesting power status of '%s' (%X)", m_busDevice->GetLogicalAddressName(), iDestination); + cec_command command; cec_command::Format(command, iInitiator, iDestination, CEC_OPCODE_GIVE_DEVICE_POWER_STATUS); @@ -1100,7 +1119,9 @@ bool CCECCommandHandler::Transmit(cec_command &command, bool bSuppressWait, bool { if ((bReturn = m_processor->Transmit(command, bIsReply)) == true) { +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "command transmitted"); +#endif if (bExpectResponse) { bReturn = m_busDevice->WaitForOpcode(expectedResponse); @@ -1126,7 +1147,9 @@ bool CCECCommandHandler::ActivateSource(bool bTransmitDelayedCommandsOnly /* = f if (m_iActiveSourcePending == 0 || GetTimeMs() < m_iActiveSourcePending) return false; +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "transmitting delayed activate source command"); +#endif } } diff --git a/src/lib/implementations/CECCommandHandler.h b/src/lib/implementations/CECCommandHandler.h index fca8a96..1a6cd56 100644 --- a/src/lib/implementations/CECCommandHandler.h +++ b/src/lib/implementations/CECCommandHandler.h @@ -152,15 +152,16 @@ namespace CEC virtual bool SourceSwitchAllowed(void) { return true; } - CCECBusDevice * m_busDevice; - CCECProcessor * m_processor; - int32_t m_iTransmitTimeout; - int32_t m_iTransmitWait; - int8_t m_iTransmitRetries; - bool m_bHandlerInited; - bool m_bOPTSendDeckStatusUpdateOnActiveSource; - cec_vendor_id m_vendorId; - int64_t m_iActiveSourcePending; - PLATFORM::CMutex m_mutex; + CCECBusDevice * m_busDevice; + CCECProcessor * m_processor; + int32_t m_iTransmitTimeout; + int32_t m_iTransmitWait; + int8_t m_iTransmitRetries; + bool m_bHandlerInited; + bool m_bOPTSendDeckStatusUpdateOnActiveSource; + cec_vendor_id m_vendorId; + int64_t m_iActiveSourcePending; + PLATFORM::CMutex m_mutex; + int64_t m_iPowerStatusRequested; }; }; diff --git a/src/lib/implementations/VLCommandHandler.cpp b/src/lib/implementations/VLCommandHandler.cpp index 90e8777..b7cdb7a 100644 --- a/src/lib/implementations/VLCommandHandler.cpp +++ b/src/lib/implementations/VLCommandHandler.cpp @@ -45,8 +45,6 @@ #define VL_POWERED_DOWN 0x01 #define VL_UNKNOWN1 0x06 -#define VL_REQUEST_POWER_STATUS_TIMEOUT 5000 - using namespace CEC; using namespace PLATFORM; @@ -63,8 +61,7 @@ CVLCommandHandler::CVLCommandHandler(CCECBusDevice *busDevice, int64_t iActiveSourcePending /* = 0 */) : CCECCommandHandler(busDevice, iTransmitTimeout, iTransmitWait, iTransmitRetries, iActiveSourcePending), m_iPowerUpEventReceived(0), - m_bCapabilitiesSent(false), - m_iPowerStatusRequested(0) + m_bCapabilitiesSent(false) { m_vendorId = CEC_VENDOR_PANASONIC; } @@ -203,6 +200,7 @@ int CVLCommandHandler::HandleStandby(const cec_command &command) { CLockObject lock(m_mutex); m_iPowerUpEventReceived = 0; + m_bCapabilitiesSent = false; } return CCECCommandHandler::HandleStandby(command); @@ -221,14 +219,14 @@ void CVLCommandHandler::VendorPreActivateSourceHook(void) void CVLCommandHandler::SendVendorCommandCapabilities(const cec_logical_address initiator, const cec_logical_address destination) { - cec_command response; - cec_command::Format(response, initiator, destination, CEC_OPCODE_VENDOR_COMMAND); - uint8_t iResponseData[] = {0x10, 0x02, 0xFF, 0xFF, 0x00, 0x05, 0x05, 0x45, 0x55, 0x5c, 0x58, 0x32}; - response.PushArray(12, iResponseData); - - if (Transmit(response, false, true)) + if (PowerUpEventReceived()) { - if (PowerUpEventReceived()) + cec_command response; + cec_command::Format(response, initiator, destination, CEC_OPCODE_VENDOR_COMMAND); + uint8_t iResponseData[] = {0x10, 0x02, 0xFF, 0xFF, 0x00, 0x05, 0x05, 0x45, 0x55, 0x5c, 0x58, 0x32}; + response.PushArray(12, iResponseData); + + if (Transmit(response, false, true)) { CLockObject lock(m_mutex); m_bCapabilitiesSent = true; @@ -252,16 +250,9 @@ int CVLCommandHandler::HandleVendorCommand(const cec_command &command) return CEC_ABORT_REASON_INVALID_OPERAND; } -bool CVLCommandHandler::TransmitRequestPowerStatus(const cec_logical_address iInitiator, const cec_logical_address iDestination, bool bWaitForResponse /* = true */) -{ - m_iPowerStatusRequested = GetTimeMs(); - return CCECCommandHandler::TransmitRequestPowerStatus(iInitiator, iDestination, bWaitForResponse); -} - bool CVLCommandHandler::SourceSwitchAllowed(void) { - int64_t now(GetTimeMs()); - if (!PowerUpEventReceived() && now - m_iPowerStatusRequested > VL_REQUEST_POWER_STATUS_TIMEOUT) + if (!PowerUpEventReceived()) TransmitRequestPowerStatus(m_processor->GetPrimaryDevice()->GetLogicalAddress(), CECDEVICE_TV, false); return PowerUpEventReceived(); diff --git a/src/lib/implementations/VLCommandHandler.h b/src/lib/implementations/VLCommandHandler.h index b878ca9..3ad80b4 100644 --- a/src/lib/implementations/VLCommandHandler.h +++ b/src/lib/implementations/VLCommandHandler.h @@ -55,7 +55,6 @@ namespace CEC bool PowerUpEventReceived(void); bool SupportsDeviceType(const cec_device_type type) const { return type != CEC_DEVICE_TYPE_RECORDING_DEVICE; }; cec_device_type GetReplacementDeviceType(const cec_device_type type) const { return type == CEC_DEVICE_TYPE_RECORDING_DEVICE ? CEC_DEVICE_TYPE_PLAYBACK_DEVICE : type; } - bool TransmitRequestPowerStatus(const cec_logical_address iInitiator, const cec_logical_address iDestination, bool bWaitForResponse = true); bool SourceSwitchAllowed(void); @@ -67,6 +66,5 @@ namespace CEC PLATFORM::CMutex m_mutex; uint64_t m_iPowerUpEventReceived; bool m_bCapabilitiesSent; - int64_t m_iPowerStatusRequested; }; }; diff --git a/src/testclient/main.cpp b/src/testclient/main.cpp index 24ddde5..2050ee9 100644 --- a/src/testclient/main.cpp +++ b/src/testclient/main.cpp @@ -48,7 +48,7 @@ using namespace CEC; using namespace std; using namespace PLATFORM; -#define CEC_CONFIG_VERSION CEC_CLIENT_VERSION_2_0_1; +#define CEC_CONFIG_VERSION CEC_CLIENT_VERSION_2_0_2; #include "../../include/cecloader.h"