From 91ef4e2d039e2b4171cfb77f7895bde87c5309a6 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Tue, 19 Jun 2012 16:59:12 +0200 Subject: [PATCH] cec: fixed missing virtual keyword in CCECCommandHandler::GetReplacementDeviceType(). replace the handler (if needed) in GetHandler() --- src/lib/CECClient.cpp | 1 + src/lib/CECProcessor.cpp | 7 ++++++- src/lib/devices/CECBusDevice.cpp | 7 +++++++ src/lib/devices/CECBusDevice.h | 14 +++++++++++++- src/lib/implementations/CECCommandHandler.h | 2 +- src/lib/implementations/VLCommandHandler.cpp | 1 + 6 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/lib/CECClient.cpp b/src/lib/CECClient.cpp index 7cf542b..008831b 100644 --- a/src/lib/CECClient.cpp +++ b/src/lib/CECClient.cpp @@ -269,6 +269,7 @@ void CCECClient::SetSupportedDeviceTypes(void) if (!types.IsSet(type)) types.Add(type); } + m_processor->GetTV()->MarkHandlerReady(); // set the new type list m_configuration.deviceTypes = types; diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index ca323fc..848800e 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -208,6 +208,7 @@ void CCECProcessor::CheckPendingActiveSource(void) { if (it->second->GetHandler()->ActiveSourcePending()) it->second->ActivateSource(); + it->second->MarkHandlerReady(); } } @@ -413,6 +414,7 @@ bool CCECProcessor::Transmit(const cec_command &data) m_iLastTransmission = GetTimeMs(); // set the number of tries iMaxTries = initiator->GetHandler()->GetTransmitRetries() + 1; + initiator->MarkHandlerReady(); } // and try to send the command @@ -565,7 +567,9 @@ bool CCECProcessor::HandleReceiveFailed(cec_logical_address initiator) bool CCECProcessor::SetStreamPath(uint16_t iPhysicalAddress) { // stream path changes are sent by the TV - return GetTV()->GetHandler()->TransmitSetStreamPath(iPhysicalAddress); + bool bReturn = GetTV()->GetHandler()->TransmitSetStreamPath(iPhysicalAddress); + GetTV()->MarkHandlerReady(); + return bReturn; } bool CCECProcessor::CanPersistConfiguration(void) @@ -729,6 +733,7 @@ bool CCECProcessor::RegisterClient(CCECClient *client) CCECCommandHandler *handler = GetTV()->GetHandler(); if (handler) handler->InitHandler(); + GetTV()->MarkHandlerReady(); } return bReturn; diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index 8f966a2..e1697c3 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -148,6 +148,13 @@ bool CCECBusDevice::ReplaceHandler(bool bActivateSource /* = true */) return true; } +CCECCommandHandler *CCECBusDevice::GetHandler(void) +{ + ReplaceHandler(false); + MarkBusy(); + return m_handler; +} + bool CCECBusDevice::HandleCommand(const cec_command &command) { bool bHandled(false); diff --git a/src/lib/devices/CECBusDevice.h b/src/lib/devices/CECBusDevice.h index 0e11d42..dcfbbbc 100644 --- a/src/lib/devices/CECBusDevice.h +++ b/src/lib/devices/CECBusDevice.h @@ -56,7 +56,19 @@ namespace CEC virtual ~CCECBusDevice(void); virtual bool ReplaceHandler(bool bActivateSource = true); - virtual CCECCommandHandler * GetHandler(void) const { return m_handler; }; + + // TODO use something smarter than this + /*! + * @brief Get the command handler for this device. Call MarkHandlerReady() when done with it. + * @return The current handler. + */ + virtual CCECCommandHandler * GetHandler(void); + + /*! + * @brief To be called after GetHandler(), when no longer using it. + */ + virtual void MarkHandlerReady(void) { MarkReady(); } + virtual CCECProcessor * GetProcessor(void) const { return m_processor; } virtual uint64_t GetLastActive(void) const { return m_iLastActive; } virtual cec_device_type GetType(void) const { return m_type; } diff --git a/src/lib/implementations/CECCommandHandler.h b/src/lib/implementations/CECCommandHandler.h index 3a9bd6f..1ede442 100644 --- a/src/lib/implementations/CECCommandHandler.h +++ b/src/lib/implementations/CECCommandHandler.h @@ -164,7 +164,7 @@ namespace CEC virtual bool ActiveSourcePending(void); virtual bool SupportsDeviceType(const cec_device_type UNUSED(type)) const { return true; }; - cec_device_type GetReplacementDeviceType(const cec_device_type type) const { return type; } + virtual cec_device_type GetReplacementDeviceType(const cec_device_type type) const { return type; } protected: virtual bool HandleActiveSource(const cec_command &command); diff --git a/src/lib/implementations/VLCommandHandler.cpp b/src/lib/implementations/VLCommandHandler.cpp index 3d96004..455a062 100644 --- a/src/lib/implementations/VLCommandHandler.cpp +++ b/src/lib/implementations/VLCommandHandler.cpp @@ -111,6 +111,7 @@ bool CVLCommandHandler::TransmitActiveSource(const cec_logical_address iInitiato { CVLCommandHandler *handler = static_cast(tv->GetHandler()); bPowerUpEventReceived = handler ? handler->PowerUpEventReceived() : false; + tv->MarkHandlerReady(); } if (!bPowerUpEventReceived) -- 2.34.1