X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fimplementations%2FVLCommandHandler.cpp;h=59eb5747cb6cc9693415286f836337647c5e1aab;hb=ae0f8fe4a09c5a4a3bb8fef267c6146d6df9d1e0;hp=87a3037e432a4bde4f872b7a820ee7c2e04bcf93;hpb=b78b4e339dd201d11c5e6dbfec36534d6bc5fd69;p=deb_libcec.git diff --git a/src/lib/implementations/VLCommandHandler.cpp b/src/lib/implementations/VLCommandHandler.cpp index 87a3037..59eb574 100644 --- a/src/lib/implementations/VLCommandHandler.cpp +++ b/src/lib/implementations/VLCommandHandler.cpp @@ -34,6 +34,7 @@ #include "../devices/CECBusDevice.h" #include "../CECProcessor.h" #include "../LibCEC.h" +#include "../CECClient.h" #define VL_POWER_CHANGE 0x20 #define VL_POWERED_UP 0x00 @@ -42,19 +43,33 @@ using namespace CEC; using namespace PLATFORM; +#define LIB_CEC m_busDevice->GetProcessor()->GetLib() +#define ToString(p) LIB_CEC->ToString(p) + CVLCommandHandler::CVLCommandHandler(CCECBusDevice *busDevice) : CCECCommandHandler(busDevice), m_bActiveSourcePending(false), m_bPowerUpEventReceived(false) { m_vendorId = CEC_VENDOR_PANASONIC; + + /* use the VL commandhandler for the primary device that is handled by libCEC */ + if (busDevice->GetLogicalAddress() == CECDEVICE_TV) + { + CCECBusDevice *primary = m_processor->GetPrimaryDevice(); + if (primary && m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress()) + { + primary->SetVendorId(CEC_VENDOR_PANASONIC); + primary->ReplaceHandler(false); + } + } } bool CVLCommandHandler::InitHandler(void) { CCECBusDevice *primary = m_processor->GetPrimaryDevice(); if (primary->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE) - return m_processor->ChangeDeviceType(CEC_DEVICE_TYPE_RECORDING_DEVICE, CEC_DEVICE_TYPE_PLAYBACK_DEVICE); + return m_processor->GetPrimaryClient()->ChangeDeviceType(CEC_DEVICE_TYPE_RECORDING_DEVICE, CEC_DEVICE_TYPE_PLAYBACK_DEVICE); return CCECCommandHandler::InitHandler(); } @@ -67,7 +82,7 @@ bool CVLCommandHandler::HandleDeviceVendorCommandWithId(const cec_command &comma { if (command.parameters.At(4) == VL_POWERED_UP) { - CLibCEC::AddLog(CEC_LOG_DEBUG, "TV powered up"); + LIB_CEC->AddLog(CEC_LOG_DEBUG, "TV powered up"); { CLockObject lock(m_mutex); m_bPowerUpEventReceived = true; @@ -75,9 +90,9 @@ bool CVLCommandHandler::HandleDeviceVendorCommandWithId(const cec_command &comma m_processor->TransmitPendingActiveSourceCommands(); } else if (command.parameters.At(4) == VL_POWERED_DOWN) - CLibCEC::AddLog(CEC_LOG_DEBUG, "TV powered down"); + LIB_CEC->AddLog(CEC_LOG_DEBUG, "TV powered down"); else if (command.parameters.At(4) == VL_POWERED_DOWN) - CLibCEC::AddLog(CEC_LOG_DEBUG, "unknown vendor command"); + LIB_CEC->AddLog(CEC_LOG_DEBUG, "unknown vendor command"); return true; } @@ -89,15 +104,11 @@ bool CVLCommandHandler::TransmitActiveSource(const cec_logical_address iInitiato { bool bPowerUpEventReceived(false); + CCECBusDevice *tv = m_processor->GetDevice(CECDEVICE_TV); + if (tv && tv->GetCurrentVendorId() == CEC_VENDOR_PANASONIC) { - CLockObject lock(m_mutex); - if (!m_bPowerUpEventReceived) - { - // just assume it's been sent when the tv is powered on - cec_power_status powerStatus = m_processor->m_busDevices[CECDEVICE_TV]->GetPowerStatus(); - m_bPowerUpEventReceived = (powerStatus == CEC_POWER_STATUS_ON); - } - bPowerUpEventReceived = m_bPowerUpEventReceived; + CVLCommandHandler *handler = static_cast(tv->GetHandler()); + bPowerUpEventReceived = handler ? handler->PowerUpEventReceived() : false; } if (!bPowerUpEventReceived) @@ -125,8 +136,23 @@ bool CVLCommandHandler::TransmitPendingActiveSourceCommands(void) if (bTransmitCommand) { - CLibCEC::AddLog(CEC_LOG_DEBUG, "transmitting delayed activate source command"); - return CCECCommandHandler::TransmitActiveSource(m_busDevice->GetLogicalAddress(), m_busDevice->GetPhysicalAddress(false, true)); + LIB_CEC->AddLog(CEC_LOG_DEBUG, "transmitting delayed activate source command"); + return CCECCommandHandler::TransmitActiveSource(m_busDevice->GetLogicalAddress(), m_busDevice->GetCurrentPhysicalAddress()); } return true; } + +bool CVLCommandHandler::PowerUpEventReceived(void) +{ + { + CLockObject lock(m_mutex); + if (m_bPowerUpEventReceived) + return true; + } + + cec_power_status powerStatus = m_busDevice->GetCurrentPowerStatus(); + + CLockObject lock(m_mutex); + m_bPowerUpEventReceived = (powerStatus == CEC_POWER_STATUS_ON); + return m_bPowerUpEventReceived; +}