From: Lars Op den Kamp Date: Thu, 2 Feb 2012 10:28:22 +0000 (+0100) Subject: cec: dropped no longer needed start condition and state boolean in CCECProcessor... X-Git-Tag: upstream/2.2.0~1^2~36^2~16 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=8e57f83c5cc5b448024c9e2c9bf8f2d93b78c756;p=deb_libcec.git cec: dropped no longer needed start condition and state boolean in CCECProcessor. this is handled by Cthread now --- diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 38c9b76..faa8d8c 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -48,7 +48,6 @@ using namespace std; using namespace PLATFORM; CCECProcessor::CCECProcessor(CLibCEC *controller, const char *strDeviceName, cec_logical_address iLogicalAddress /* = CECDEVICE_PLAYBACKDEVICE1 */, uint16_t iPhysicalAddress /* = CEC_DEFAULT_PHYSICAL_ADDRESS*/) : - m_bStarted(false), m_bInitialised(false), m_iHDMIPort(CEC_DEFAULT_HDMI_PORT), m_iBaseDevice((cec_logical_address)CEC_DEFAULT_BASE_DEVICE), @@ -68,7 +67,6 @@ CCECProcessor::CCECProcessor(CLibCEC *controller, const char *strDeviceName, cec } CCECProcessor::CCECProcessor(CLibCEC *controller, const char *strDeviceName, const cec_device_type_list &types) : - m_bStarted(false), m_bInitialised(false), m_iHDMIPort(CEC_DEFAULT_HDMI_PORT), m_iBaseDevice((cec_logical_address)CEC_DEFAULT_BASE_DEVICE), @@ -117,8 +115,6 @@ CCECProcessor::CCECProcessor(CLibCEC *controller, const char *strDeviceName, con CCECProcessor::~CCECProcessor(void) { - m_bStarted = false; - m_startCondition.Broadcast(); StopThread(); delete m_communication; @@ -241,7 +237,7 @@ bool CCECProcessor::Start(const char *strPort, uint16_t iBaudRate /* = 38400 */, return bReturn; /* create the processor thread */ - if (!CreateThread() || !m_startCondition.Wait(m_mutex) || !m_bStarted) + if (!CreateThread()) { CLibCEC::AddLog(CEC_LOG_ERROR, "could not create a processor thread"); return bReturn; @@ -416,16 +412,9 @@ void CCECProcessor::ReplaceHandlers(void) void *CCECProcessor::Process(void) { - bool bParseFrame(false); - cec_command command; - CCECAdapterMessage msg; - - { - CLockObject lock(m_mutex); - m_bStarted = true; - CLibCEC::AddLog(CEC_LOG_DEBUG, "processor thread started"); - m_startCondition.Signal(); - } + bool bParseCommand(false); + cec_command command; + CLibCEC::AddLog(CEC_LOG_DEBUG, "processor thread started"); while (!IsStopped()) { @@ -435,14 +424,14 @@ void *CCECProcessor::Process(void) { CLockObject lock(m_mutex); if (m_commandBuffer.Pop(command)) - bParseFrame = true; + bParseCommand = true; else if (m_communication->IsOpen() && m_communication->Read(command, 50)) - bParseFrame = true; + bParseCommand = true; } - if (bParseFrame) + if (bParseCommand) ParseCommand(command); - bParseFrame = false; + bParseCommand = false; Sleep(5); @@ -572,7 +561,7 @@ bool CCECProcessor::SetHDMIPort(cec_logical_address iBaseDevice, uint8_t iPort, m_iBaseDevice = iBaseDevice; m_iHDMIPort = iPort; - if (!m_bStarted && !bForce) + if (!IsRunning() && !bForce) return true; CLibCEC::AddLog(CEC_LOG_DEBUG, "setting HDMI port to %d on device %s (%d)", iPort, ToString(iBaseDevice), (int)iBaseDevice); diff --git a/src/lib/CECProcessor.h b/src/lib/CECProcessor.h index 133a70b..487f122 100644 --- a/src/lib/CECProcessor.h +++ b/src/lib/CECProcessor.h @@ -71,7 +71,6 @@ namespace CEC virtual bool IsPresentDeviceType(cec_device_type type); virtual uint16_t GetPhysicalAddress(void) const; virtual uint64_t GetLastTransmission(void) const { return m_iLastTransmission; } - virtual bool IsStarted(void) const { return m_bStarted; } virtual cec_logical_address GetActiveSource(void); virtual bool IsActiveSource(cec_logical_address iAddress); virtual bool IsInitialised(void) const { return m_bInitialised; } @@ -143,7 +142,6 @@ namespace CEC void LogOutput(const cec_command &data); void ParseCommand(cec_command &command); - bool m_bStarted; bool m_bInitialised; uint8_t m_iHDMIPort; cec_logical_address m_iBaseDevice; @@ -151,7 +149,6 @@ namespace CEC std::string m_strDeviceName; cec_device_type_list m_types; PLATFORM::CMutex m_mutex; - PLATFORM::CCondition m_startCondition; IAdapterCommunication * m_communication; CLibCEC* m_controller; bool m_bMonitor; diff --git a/src/lib/implementations/ANCommandHandler.cpp b/src/lib/implementations/ANCommandHandler.cpp index 596bcf8..d3318a1 100644 --- a/src/lib/implementations/ANCommandHandler.cpp +++ b/src/lib/implementations/ANCommandHandler.cpp @@ -46,7 +46,7 @@ CANCommandHandler::CANCommandHandler(CCECBusDevice *busDevice) : bool CANCommandHandler::HandleVendorRemoteButtonDown(const cec_command &command) { - if (m_processor->IsStarted() && command.parameters.size > 0) + if (m_processor->IsRunning() && command.parameters.size > 0) { cec_keypress key; key.duration = CEC_BUTTON_TIMEOUT; diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 331315d..27e8009 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -239,7 +239,7 @@ bool CCECCommandHandler::HandleDeviceCecVersion(const cec_command &command) bool CCECCommandHandler::HandleDeviceVendorCommandWithId(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) m_processor->TransmitAbort(command.initiator, command.opcode, CEC_ABORT_REASON_REFUSED); return true; @@ -261,7 +261,7 @@ bool CCECCommandHandler::HandleFeatureAbort(const cec_command &command) bool CCECCommandHandler::HandleGetCecVersion(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); if (device) @@ -273,7 +273,7 @@ bool CCECCommandHandler::HandleGetCecVersion(const cec_command &command) bool CCECCommandHandler::HandleGiveAudioStatus(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM) @@ -285,7 +285,7 @@ bool CCECCommandHandler::HandleGiveAudioStatus(const cec_command &command) bool CCECCommandHandler::HandleGiveDeckStatus(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); if (device && (device->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || device->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE)) @@ -297,7 +297,7 @@ bool CCECCommandHandler::HandleGiveDeckStatus(const cec_command &command) bool CCECCommandHandler::HandleGiveDevicePowerStatus(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); if (device) @@ -309,7 +309,7 @@ bool CCECCommandHandler::HandleGiveDevicePowerStatus(const cec_command &command) bool CCECCommandHandler::HandleGiveDeviceVendorId(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); if (device) @@ -321,7 +321,7 @@ bool CCECCommandHandler::HandleGiveDeviceVendorId(const cec_command &command) bool CCECCommandHandler::HandleGiveOSDName(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); if (device) @@ -333,7 +333,7 @@ bool CCECCommandHandler::HandleGiveOSDName(const cec_command &command) bool CCECCommandHandler::HandleGivePhysicalAddress(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); if (device) @@ -349,7 +349,7 @@ bool CCECCommandHandler::HandleGivePhysicalAddress(const cec_command &command) bool CCECCommandHandler::HandleGiveSystemAudioModeStatus(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM) @@ -367,7 +367,7 @@ bool CCECCommandHandler::HandleImageViewOn(const cec_command &command) bool CCECCommandHandler::HandleMenuRequest(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) { if (command.parameters[0] == CEC_MENU_REQUEST_TYPE_QUERY) { @@ -417,7 +417,7 @@ bool CCECCommandHandler::HandleReportPowerStatus(const cec_command &command) bool CCECCommandHandler::HandleRequestActiveSource(const cec_command &command) { - if (m_processor->IsStarted()) + if (m_processor->IsRunning()) { CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %i requests active source", (uint8_t) command.initiator); @@ -497,7 +497,7 @@ bool CCECCommandHandler::HandleSetOSDName(const cec_command &command) bool CCECCommandHandler::HandleSetStreamPath(const cec_command &command) { - if (m_processor->IsStarted() && command.parameters.size >= 2) + if (m_processor->IsRunning() && command.parameters.size >= 2) { uint16_t iStreamAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]); CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %i sets stream path to physical address %04x", command.initiator, iStreamAddress); @@ -518,7 +518,7 @@ bool CCECCommandHandler::HandleSetStreamPath(const cec_command &command) bool CCECCommandHandler::HandleSystemAudioModeRequest(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM) @@ -590,7 +590,7 @@ bool CCECCommandHandler::HandleTextViewOn(const cec_command &command) bool CCECCommandHandler::HandleUserControlPressed(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination) && command.parameters.size > 0) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination) && command.parameters.size > 0) { CLibCEC::AddKey(); @@ -626,7 +626,7 @@ bool CCECCommandHandler::HandleUserControlPressed(const cec_command &command) bool CCECCommandHandler::HandleUserControlRelease(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) CLibCEC::AddKey(); return true; diff --git a/src/lib/implementations/SLCommandHandler.cpp b/src/lib/implementations/SLCommandHandler.cpp index 09fcf4b..647b053 100644 --- a/src/lib/implementations/SLCommandHandler.cpp +++ b/src/lib/implementations/SLCommandHandler.cpp @@ -139,7 +139,7 @@ bool CSLCommandHandler::HandleFeatureAbort(const cec_command &command) bool CSLCommandHandler::HandleGivePhysicalAddress(const cec_command &command) { - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) + if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination)) { CCECBusDevice *device = GetDevice(command.destination); if (device)