From b32ffd87ed707124e700477e8b2a10f6132de2c8 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Thu, 26 Apr 2012 14:32:31 +0200 Subject: [PATCH] cec: replaced a load of magic numbers --- include/cectypes.h | 8 +++++ src/cec-config/cec-config.cpp | 12 +++---- src/lib/CECProcessor.cpp | 36 ++++++++++--------- src/lib/CECProcessor.h | 6 ++-- src/lib/LibCEC.cpp | 10 +++--- src/lib/LibCEC.h | 4 +-- src/lib/adapter/AdapterCommunication.h | 2 +- .../adapter/USBCECAdapterCommunication.cpp | 12 +++---- src/lib/adapter/USBCECAdapterCommunication.h | 8 ++--- src/lib/adapter/USBCECAdapterMessageQueue.cpp | 4 ++- src/lib/devices/CECBusDevice.cpp | 12 +++---- src/lib/devices/CECBusDevice.h | 2 +- src/testclient/main.cpp | 2 +- 13 files changed, 65 insertions(+), 53 deletions(-) diff --git a/include/cectypes.h b/include/cectypes.h index 4775e74..6de565d 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -73,6 +73,9 @@ namespace CEC { #define CEC_POWER_STATE_REFRESH_TIME 30000 #define CEC_FW_VERSION_UNKNOWN 0xFFFF #define CEC_CONNECT_TRIES 3 +#define CEC_PHYSICAL_ADDRESS_TV 0 +#define CEC_MAX_PHYSICAL_ADDRESS 0xFFFE +#define CEC_INVALID_PHYSICAL_ADDRESS 0xFFFF #define CEC_DEFAULT_SETTING_USE_TV_MENU_LANGUAGE 1 #define CEC_DEFAULT_SETTING_ACTIVATE_SOURCE 1 @@ -90,6 +93,11 @@ namespace CEC { #define CEC_DEFAULT_TRANSMIT_WAIT 2000 #define CEC_DEFAULT_TRANSMIT_RETRIES 1 +#define CEC_DEFAULT_CONNECT_TIMEOUT 10000 +#define CEC_DEFAULT_CONNECT_RETRY_WAIT 1000 +#define CEC_SERIAL_DEFAULT_BAUDRATE 38400 +#define CEC_CLEAR_INPUT_DEFAULT_WAIT 1000 + #define CEC_MIN_LIB_VERSION 1 #define CEC_LIB_VERSION_MAJOR 1 #define CEC_LIB_VERSION_MINOR 6 diff --git a/src/cec-config/cec-config.cpp b/src/cec-config/cec-config.cpp index 5dbb9c8..c601afc 100644 --- a/src/cec-config/cec-config.cpp +++ b/src/cec-config/cec-config.cpp @@ -258,7 +258,7 @@ cec_logical_address FindPhysicalAddressBaseDevice(void) uint16_t FindPhysicalAddress(void) { PrintToStdOut("=== Physical Address Configuration ===\n"); - uint16_t iAddress(0xFFFF); + uint16_t iAddress(CEC_INVALID_PHYSICAL_ADDRESS); PrintToStdOut("Do you want to let libCEC try to autodetect the address (y/n)?"); string input; @@ -280,22 +280,22 @@ uint16_t FindPhysicalAddress(void) else { iAddress = g_parser->GetDevicePhysicalAddress(g_primaryAddress); - if (iAddress == 0 || iAddress == 0xFFFF) + if (iAddress == 0 || iAddress == CEC_INVALID_PHYSICAL_ADDRESS) PrintToStdOut("Failed. Please enter the address manually, or restart this wizard and use different settings."); } } - if (iAddress == 0 || iAddress == 0xFFFF) + if (iAddress == 0 || iAddress == CEC_INVALID_PHYSICAL_ADDRESS) { - PrintToStdOut("Please enter the physical address (0000 - FFFF), followed by ."); + PrintToStdOut("Please enter the physical address (0001 - FFFE), followed by ."); getline(cin, input); cin.clear(); int iAddressTmp; if (sscanf(input.c_str(), "%x", &iAddressTmp) == 1) { - if (iAddressTmp < 0 || iAddressTmp > 0xFFFF) - iAddressTmp = 0xFFFF; + if (iAddressTmp <= CEC_PHYSICAL_ADDRESS_TV || iAddressTmp > CEC_MAX_PHYSICAL_ADDRESS) + iAddressTmp = CEC_INVALID_PHYSICAL_ADDRESS; iAddress = (uint16_t)iAddressTmp; } } diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 2f7fcac..8838df6 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -47,6 +47,8 @@ using namespace CEC; using namespace std; using namespace PLATFORM; +#define CEC_PROCESSOR_SIGNAL_WAIT_TIME 1000 + CCECProcessor::CCECProcessor(CLibCEC *controller, libcec_configuration *configuration) : m_bConnectionOpened(false), m_bInitialised(false), @@ -99,29 +101,29 @@ void CCECProcessor::CreateBusDevices(void) switch(iPtr) { case CECDEVICE_AUDIOSYSTEM: - m_busDevices[iPtr] = new CCECAudioSystem(this, (cec_logical_address) iPtr, 0xFFFF); + m_busDevices[iPtr] = new CCECAudioSystem(this, (cec_logical_address) iPtr, CEC_INVALID_PHYSICAL_ADDRESS); break; case CECDEVICE_PLAYBACKDEVICE1: case CECDEVICE_PLAYBACKDEVICE2: case CECDEVICE_PLAYBACKDEVICE3: - m_busDevices[iPtr] = new CCECPlaybackDevice(this, (cec_logical_address) iPtr, 0xFFFF); + m_busDevices[iPtr] = new CCECPlaybackDevice(this, (cec_logical_address) iPtr, CEC_INVALID_PHYSICAL_ADDRESS); break; case CECDEVICE_RECORDINGDEVICE1: case CECDEVICE_RECORDINGDEVICE2: case CECDEVICE_RECORDINGDEVICE3: - m_busDevices[iPtr] = new CCECRecordingDevice(this, (cec_logical_address) iPtr, 0xFFFF); + m_busDevices[iPtr] = new CCECRecordingDevice(this, (cec_logical_address) iPtr, CEC_INVALID_PHYSICAL_ADDRESS); break; case CECDEVICE_TUNER1: case CECDEVICE_TUNER2: case CECDEVICE_TUNER3: case CECDEVICE_TUNER4: - m_busDevices[iPtr] = new CCECTuner(this, (cec_logical_address) iPtr, 0xFFFF); + m_busDevices[iPtr] = new CCECTuner(this, (cec_logical_address) iPtr, CEC_INVALID_PHYSICAL_ADDRESS); break; case CECDEVICE_TV: - m_busDevices[iPtr] = new CCECTV(this, (cec_logical_address) iPtr, 0); + m_busDevices[iPtr] = new CCECTV(this, (cec_logical_address) iPtr, CEC_PHYSICAL_ADDRESS_TV); break; default: - m_busDevices[iPtr] = new CCECBusDevice(this, (cec_logical_address) iPtr, 0xFFFF); + m_busDevices[iPtr] = new CCECBusDevice(this, (cec_logical_address) iPtr, CEC_INVALID_PHYSICAL_ADDRESS); break; } } @@ -182,7 +184,7 @@ bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint { CLibCEC::AddLog(CEC_LOG_ERROR, "could not open a connection (try %d)", ++iConnectTry); m_communication->Close(); - CEvent::Sleep(1000); + CEvent::Sleep(CEC_DEFAULT_CONNECT_RETRY_WAIT); } if (bReturn) @@ -290,7 +292,7 @@ bool CCECProcessor::Initialise(void) return bReturn; } -bool CCECProcessor::Start(const char *strPort, uint16_t iBaudRate /* = 38400 */, uint32_t iTimeoutMs /* = 10000 */) +bool CCECProcessor::Start(const char *strPort, uint16_t iBaudRate /* = CEC_SERIAL_DEFAULT_BAUDRATE */, uint32_t iTimeoutMs /* = CEC_DEFAULT_CONNECT_TIMEOUT */) { bool bReturn(false); @@ -410,7 +412,7 @@ bool CCECProcessor::ChangeDeviceType(cec_device_type from, cec_device_type to) previousDevice->SetOSDName(ToString(previousDevice->GetLogicalAddress())); newDevice->SetPhysicalAddress(previousDevice->GetPhysicalAddress()); - previousDevice->SetPhysicalAddress(0xFFFF); + previousDevice->SetPhysicalAddress(CEC_INVALID_PHYSICAL_ADDRESS); newDevice->SetPowerStatus(previousDevice->GetPowerStatus(false)); previousDevice->SetPowerStatus(CEC_POWER_STATUS_UNKNOWN); @@ -489,7 +491,7 @@ void *CCECProcessor::Process(void) while (!IsStopped() && m_communication->IsOpen()) { - if (m_inBuffer.Pop(command, 500)) + if (m_inBuffer.Pop(command, CEC_PROCESSOR_SIGNAL_WAIT_TIME)) ParseCommand(command); if (IsInitialised()) @@ -525,7 +527,7 @@ bool CCECProcessor::SetActiveSource(cec_device_type type /* = CEC_DEVICE_TYPE_RE } m_busDevices[addr]->SetActiveSource(); - if (m_busDevices[addr]->GetPhysicalAddress() != 0xFFFF) + if (m_busDevices[addr]->GetPhysicalAddress() != CEC_INVALID_PHYSICAL_ADDRESS) bReturn = m_busDevices[addr]->ActivateSource(); return bReturn; @@ -627,7 +629,7 @@ bool CCECProcessor::SetHDMIPort(cec_logical_address iBaseDevice, uint8_t iPort, iPhysicalAddress = m_busDevices[iBaseDevice]->GetPhysicalAddress(); } - if (iPhysicalAddress < 0xffff) + if (iPhysicalAddress <= CEC_MAX_PHYSICAL_ADDRESS) { if (iPhysicalAddress == 0) iPhysicalAddress += 0x1000 * iPort; @@ -819,7 +821,7 @@ CCECBusDevice *CCECProcessor::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddre CCECBusDevice *device(NULL); // invalid PA - if (iPhysicalAddress == 0xFFFF) + if (iPhysicalAddress == CEC_INVALID_PHYSICAL_ADDRESS) return device; // check each device until we found a match @@ -1512,13 +1514,13 @@ bool CCECProcessor::StartBootloader(const char *strPort /* = NULL */) { bool bReturn(false); IAdapterCommunication *comm = new CUSBCECAdapterCommunication(this, strPort); - CTimeout timeout(10000); + CTimeout timeout(CEC_DEFAULT_CONNECT_TIMEOUT); int iConnectTry(0); while (timeout.TimeLeft() > 0 && (bReturn = comm->Open(timeout.TimeLeft() / CEC_CONNECT_TRIES, true)) == false) { CLibCEC::AddLog(CEC_LOG_ERROR, "could not open a connection (try %d)", ++iConnectTry); comm->Close(); - Sleep(500); + Sleep(CEC_DEFAULT_TRANSMIT_RETRY_WAIT); } if (comm->IsOpen()) { @@ -1765,9 +1767,9 @@ void CCECProcessor::RescanActiveDevices(void) m_busDevices[iPtr]->GetStatus(true); } -bool CCECProcessor::GetDeviceInformation(const char *strPort, libcec_configuration *config, uint32_t iTimeoutMs /* = 10000 */) +bool CCECProcessor::GetDeviceInformation(const char *strPort, libcec_configuration *config, uint32_t iTimeoutMs /* = CEC_DEFAULT_CONNECT_TIMEOUT */) { - if (!OpenConnection(strPort, 38400, iTimeoutMs, false)) + if (!OpenConnection(strPort, CEC_SERIAL_DEFAULT_BAUDRATE, iTimeoutMs, false)) return false; config->iFirmwareVersion = m_communication->GetFirmwareVersion(); diff --git a/src/lib/CECProcessor.h b/src/lib/CECProcessor.h index 9b7a6e3..c93d8fe 100644 --- a/src/lib/CECProcessor.h +++ b/src/lib/CECProcessor.h @@ -70,7 +70,7 @@ namespace CEC return bReturn; } - bool Pop(cec_command &command, uint16_t iTimeout = 10000) + bool Pop(cec_command &command, uint16_t iTimeout) { bool bReturn(false); PLATFORM::CLockObject lock(m_mutex); @@ -102,7 +102,7 @@ namespace CEC CCECProcessor(CLibCEC *controller, libcec_configuration *configuration); virtual ~CCECProcessor(void); - bool Start(const char *strPort, uint16_t iBaudRate = 38400, uint32_t iTimeoutMs = 10000); + bool Start(const char *strPort, uint16_t iBaudRate = CEC_SERIAL_DEFAULT_BAUDRATE, uint32_t iTimeoutMs = CEC_DEFAULT_CONNECT_TIMEOUT); void *Process(void); void Close(void); @@ -189,7 +189,7 @@ namespace CEC void HandlePoll(cec_logical_address initiator, cec_logical_address destination); bool HandleReceiveFailed(cec_logical_address initiator); - bool GetDeviceInformation(const char *strPort, libcec_configuration *config, uint32_t iTimeoutMs = 10000); + bool GetDeviceInformation(const char *strPort, libcec_configuration *config, uint32_t iTimeoutMs = CEC_DEFAULT_CONNECT_TIMEOUT); bool TransmitPendingActiveSourceCommands(void); diff --git a/src/lib/LibCEC.cpp b/src/lib/LibCEC.cpp index 4812e39..608375f 100644 --- a/src/lib/LibCEC.cpp +++ b/src/lib/LibCEC.cpp @@ -68,7 +68,7 @@ CLibCEC::~CLibCEC(void) delete m_cec; } -bool CLibCEC::Open(const char *strPort, uint32_t iTimeoutMs /* = 10000 */) +bool CLibCEC::Open(const char *strPort, uint32_t iTimeoutMs /* = CEC_DEFAULT_CONNECT_TIMEOUT */) { if (m_cec->IsRunning()) { @@ -76,7 +76,7 @@ bool CLibCEC::Open(const char *strPort, uint32_t iTimeoutMs /* = 10000 */) return false; } - if (!m_cec->Start(strPort, 38400, iTimeoutMs)) + if (!m_cec->Start(strPort, CEC_SERIAL_DEFAULT_BAUDRATE, iTimeoutMs)) { AddLog(CEC_LOG_ERROR, "could not start CEC communications"); return false; @@ -500,7 +500,7 @@ int CLibCEC::MenuStateChanged(const cec_menu_state newState) bool CLibCEC::SetStreamPath(cec_logical_address iAddress) { uint16_t iPhysicalAddress = GetDevicePhysicalAddress(iAddress); - if (iPhysicalAddress != 0xFFFF) + if (iPhysicalAddress != CEC_INVALID_PHYSICAL_ADDRESS) return SetStreamPath(iPhysicalAddress); return false; } @@ -550,7 +550,7 @@ bool CECStartBootloader(void) if (CUSBCECAdapterDetection::FindAdapters(deviceList, 1) > 0) { CUSBCECAdapterCommunication comm(NULL, deviceList[0].comm); - CTimeout timeout(10000); + CTimeout timeout(CEC_DEFAULT_CONNECT_TIMEOUT); while (timeout.TimeLeft() > 0 && (bReturn = comm.Open(timeout.TimeLeft() / CEC_CONNECT_TRIES, true)) == false) { comm.Close(); @@ -752,7 +752,7 @@ uint16_t CLibCEC::GetMaskForType(cec_device_type type) } } -bool CLibCEC::GetDeviceInformation(const char *strPort, libcec_configuration *config, uint32_t iTimeoutMs /* = 10000 */) +bool CLibCEC::GetDeviceInformation(const char *strPort, libcec_configuration *config, uint32_t iTimeoutMs /* = CEC_DEFAULT_CONNECT_TIMEOUT */) { if (m_cec->IsRunning()) return false; diff --git a/src/lib/LibCEC.h b/src/lib/LibCEC.h index b0853de..563cec1 100644 --- a/src/lib/LibCEC.h +++ b/src/lib/LibCEC.h @@ -51,7 +51,7 @@ namespace CEC CLibCEC(libcec_configuration *configuration); virtual ~CLibCEC(void); - bool Open(const char *strPort, uint32_t iTimeout = 10000); + bool Open(const char *strPort, uint32_t iTimeout = CEC_DEFAULT_CONNECT_TIMEOUT); void Close(void); bool EnableCallbacks(void *cbParam, ICECCallbacks *callbacks); int8_t FindAdapters(cec_adapter *deviceList, uint8_t iBufSize, const char *strDevicePath = NULL); @@ -127,7 +127,7 @@ namespace CEC static uint16_t GetMaskForType(cec_logical_address address); static uint16_t GetMaskForType(cec_device_type type); - bool GetDeviceInformation(const char *strPort, libcec_configuration *config, uint32_t iTimeoutMs = 10000); + bool GetDeviceInformation(const char *strPort, libcec_configuration *config, uint32_t iTimeoutMs = CEC_DEFAULT_CONNECT_TIMEOUT); //@} static void AddLog(const cec_log_level level, const char *strFormat, ...); diff --git a/src/lib/adapter/AdapterCommunication.h b/src/lib/adapter/AdapterCommunication.h index db0fbe6..48883bb 100644 --- a/src/lib/adapter/AdapterCommunication.h +++ b/src/lib/adapter/AdapterCommunication.h @@ -81,7 +81,7 @@ namespace CEC * @param bStartListening Start a listener thread when true. False to just open a connection, read the device info, and close the connection. * @return True when connected, false otherwise */ - virtual bool Open(uint32_t iTimeoutMs = 10000, bool bSkipChecks = false, bool bStartListening = true) = 0; + virtual bool Open(uint32_t iTimeoutMs = CEC_DEFAULT_CONNECT_TIMEOUT, bool bSkipChecks = false, bool bStartListening = true) = 0; /*! * @brief Close an open connection diff --git a/src/lib/adapter/USBCECAdapterCommunication.cpp b/src/lib/adapter/USBCECAdapterCommunication.cpp index d1e3565..df295e5 100644 --- a/src/lib/adapter/USBCECAdapterCommunication.cpp +++ b/src/lib/adapter/USBCECAdapterCommunication.cpp @@ -44,7 +44,7 @@ using namespace PLATFORM; #define CEC_ADAPTER_PING_TIMEOUT 15000 -CUSBCECAdapterCommunication::CUSBCECAdapterCommunication(IAdapterCommunicationCallback *callback, const char *strPort, uint16_t iBaudRate /* = 38400 */) : +CUSBCECAdapterCommunication::CUSBCECAdapterCommunication(IAdapterCommunicationCallback *callback, const char *strPort, uint16_t iBaudRate /* = CEC_SERIAL_DEFAULT_BAUDRATE */) : IAdapterCommunication(callback), m_port(NULL), m_iLineTimeout(0), @@ -67,7 +67,7 @@ CUSBCECAdapterCommunication::~CUSBCECAdapterCommunication(void) delete m_port; } -bool CUSBCECAdapterCommunication::Open(uint32_t iTimeoutMs /* = 10000 */, bool bSkipChecks /* = false */, bool bStartListening /* = true */) +bool CUSBCECAdapterCommunication::Open(uint32_t iTimeoutMs /* = CEC_DEFAULT_CONNECT_TIMEOUT */, bool bSkipChecks /* = false */, bool bStartListening /* = true */) { bool bConnectionOpened(false); { @@ -266,7 +266,7 @@ void CUSBCECAdapterCommunication::MarkAsWaiting(const cec_logical_address dest) } } -void CUSBCECAdapterCommunication::ClearInputBytes(uint32_t iTimeout /* = 1000 */) +void CUSBCECAdapterCommunication::ClearInputBytes(uint32_t iTimeout /* = CEC_CLEAR_INPUT_DEFAULT_WAIT */) { CTimeout timeout(iTimeout); uint8_t buff[1024]; @@ -396,7 +396,7 @@ CCECAdapterMessage *CUSBCECAdapterCommunication::SendCommand(cec_adapter_message return output; } -bool CUSBCECAdapterCommunication::CheckAdapter(uint32_t iTimeoutMs /* = 10000 */) +bool CUSBCECAdapterCommunication::CheckAdapter(uint32_t iTimeoutMs /* = CEC_DEFAULT_CONNECT_TIMEOUT */) { bool bReturn(false); CTimeout timeout(iTimeoutMs > 0 ? iTimeoutMs : CEC_DEFAULT_TRANSMIT_WAIT); @@ -514,8 +514,8 @@ void *CAdapterPingThread::Process(void) { if (!m_com->PingAdapter()) { - /* sleep 1 second and retry */ - Sleep(1000); + /* sleep and retry */ + Sleep(CEC_DEFAULT_TRANSMIT_RETRY_WAIT); ++iFailedCounter; } else diff --git a/src/lib/adapter/USBCECAdapterCommunication.h b/src/lib/adapter/USBCECAdapterCommunication.h index b44a3ec..a117158 100644 --- a/src/lib/adapter/USBCECAdapterCommunication.h +++ b/src/lib/adapter/USBCECAdapterCommunication.h @@ -61,12 +61,12 @@ namespace CEC * @param strPort The name of the com port to use. * @param iBaudRate The baudrate to use on the com port connection. */ - CUSBCECAdapterCommunication(IAdapterCommunicationCallback *callback, const char *strPort, uint16_t iBaudRate = 38400); + CUSBCECAdapterCommunication(IAdapterCommunicationCallback *callback, const char *strPort, uint16_t iBaudRate = CEC_SERIAL_DEFAULT_BAUDRATE); virtual ~CUSBCECAdapterCommunication(void); /** @name IAdapterCommunication implementation */ ///{ - bool Open(uint32_t iTimeoutMs = 10000, bool bSkipChecks = false, bool bStartListening = true); + bool Open(uint32_t iTimeoutMs = CEC_DEFAULT_CONNECT_TIMEOUT, bool bSkipChecks = false, bool bStartListening = true); void Close(void); bool IsOpen(void); CStdString GetError(void) const; @@ -91,7 +91,7 @@ namespace CEC * @brief Clear all input bytes. * @param iTimeout Timeout when anything was received. */ - void ClearInputBytes(uint32_t iTimeout = 1000); + void ClearInputBytes(uint32_t iTimeout = CEC_CLEAR_INPUT_DEFAULT_WAIT); /*! * @brief Change the current CEC line timeout. @@ -125,7 +125,7 @@ namespace CEC * @param iTimeoutMs The timeout after which this fails if no proper data was received. * @return True when the checks passed, false otherwise. */ - bool CheckAdapter(uint32_t iTimeoutMs = 10000); + bool CheckAdapter(uint32_t iTimeoutMs = CEC_DEFAULT_CONNECT_TIMEOUT); /*! * @brief Handle a poll message inside the adapter message (checks if one is present). diff --git a/src/lib/adapter/USBCECAdapterMessageQueue.cpp b/src/lib/adapter/USBCECAdapterMessageQueue.cpp index 64f9f00..71289ce 100644 --- a/src/lib/adapter/USBCECAdapterMessageQueue.cpp +++ b/src/lib/adapter/USBCECAdapterMessageQueue.cpp @@ -39,6 +39,8 @@ using namespace CEC; using namespace PLATFORM; using namespace std; +#define MESSAGE_QUEUE_SIGNAL_WAIT_TIME 1000 + CCECAdapterMessageQueueEntry::CCECAdapterMessageQueueEntry(CCECAdapterMessage *message) : m_message(message), m_iPacketsLeft(message->IsTranmission() ? message->Size() / 4 : 1), @@ -230,7 +232,7 @@ void *CCECAdapterMessageQueue::Process(void) while (!IsStopped()) { /* wait for a new message */ - if (m_writeQueue.Pop(message, 1000)) + if (m_writeQueue.Pop(message, MESSAGE_QUEUE_SIGNAL_WAIT_TIME)) { /* write this message */ m_com->WriteToDevice(message->m_message); diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index 0cd28d5..8f02ac7 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -47,7 +47,7 @@ using namespace PLATFORM; CCECBusDevice::CCECBusDevice(CCECProcessor *processor, cec_logical_address iLogicalAddress, uint16_t iPhysicalAddress) : m_type (CEC_DEVICE_TYPE_RESERVED), m_iPhysicalAddress (iPhysicalAddress), - m_iStreamPath (0xFFFF), + m_iStreamPath (CEC_INVALID_PHYSICAL_ADDRESS), m_iLogicalAddress (iLogicalAddress), m_powerStatus (CEC_POWER_STATUS_UNKNOWN), m_processor (processor), @@ -301,7 +301,7 @@ uint16_t CCECBusDevice::GetPhysicalAddress(bool bSuppressUpdate /* = true */) bool bRequestUpdate(false); { CLockObject lock(m_mutex); - bRequestUpdate = bIsPresent && m_iPhysicalAddress == 0xFFFF; + bRequestUpdate = bIsPresent && m_iPhysicalAddress == CEC_INVALID_PHYSICAL_ADDRESS; } if (bRequestUpdate) @@ -591,7 +591,7 @@ void CCECBusDevice::ResetDeviceStatus(void) SetVendorId (CEC_VENDOR_UNKNOWN); SetMenuState (CEC_MENU_STATE_ACTIVATED); SetCecVersion (CEC_VERSION_UNKNOWN); - SetStreamPath (0xFFFF); + SetStreamPath (CEC_INVALID_PHYSICAL_ADDRESS); SetOSDName (ToString(m_iLogicalAddress)); SetInactiveSource(); m_iLastActive = 0; @@ -617,7 +617,7 @@ void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus) SetVendorId (CEC_VENDOR_UNKNOWN); SetMenuState (CEC_MENU_STATE_ACTIVATED); SetCecVersion (CEC_VERSION_1_3A); - SetStreamPath (0xFFFF); + SetStreamPath (CEC_INVALID_PHYSICAL_ADDRESS); SetInactiveSource(); m_iLastActive = 0; m_deviceStatus = newStatus; @@ -652,7 +652,7 @@ void CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress) } } -void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* = 0xFFFF */) +void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* = CEC_INVALID_PHYSICAL_ADDRESS */) { CLockObject lock(m_mutex); if (iNewAddress != m_iStreamPath) @@ -899,7 +899,7 @@ bool CCECBusDevice::TransmitPhysicalAddress(void) cec_device_type type; { CLockObject lock(m_mutex); - if (m_iPhysicalAddress == 0xffff) + if (m_iPhysicalAddress == CEC_INVALID_PHYSICAL_ADDRESS) return false; CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> broadcast (F): physical adddress %4x", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress); diff --git a/src/lib/devices/CECBusDevice.h b/src/lib/devices/CECBusDevice.h index f5868c1..687186f 100644 --- a/src/lib/devices/CECBusDevice.h +++ b/src/lib/devices/CECBusDevice.h @@ -85,7 +85,7 @@ namespace CEC virtual void SetDeviceStatus(const cec_bus_device_status newStatus); virtual void SetPhysicalAddress(uint16_t iNewAddress); - virtual void SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress = 0xFFFF); + virtual void SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress = CEC_INVALID_PHYSICAL_ADDRESS); virtual void SetCecVersion(const cec_version newVersion); virtual void SetMenuLanguage(const cec_menu_language &menuLanguage); virtual void SetOSDName(CStdString strName); diff --git a/src/testclient/main.cpp b/src/testclient/main.cpp index 5899453..65e99bc 100644 --- a/src/testclient/main.cpp +++ b/src/testclient/main.cpp @@ -322,7 +322,7 @@ bool ProcessCommandSP(ICECAdapter *parser, const string &command, string &argume if (GetWord(arguments, strAddress)) { sscanf(strAddress.c_str(), "%x", &iAddress); - if (iAddress >= 0 && iAddress <= 0xFFFF) + if (iAddress >= 0 && iAddress <= CEC_INVALID_PHYSICAL_ADDRESS) parser->SetStreamPath((uint16_t)iAddress); return true; } -- 2.34.1