cec: replaced a load of magic numbers
authorLars Op den Kamp <lars@opdenkamp.eu>
Thu, 26 Apr 2012 12:32:31 +0000 (14:32 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Thu, 26 Apr 2012 12:32:31 +0000 (14:32 +0200)
13 files changed:
include/cectypes.h
src/cec-config/cec-config.cpp
src/lib/CECProcessor.cpp
src/lib/CECProcessor.h
src/lib/LibCEC.cpp
src/lib/LibCEC.h
src/lib/adapter/AdapterCommunication.h
src/lib/adapter/USBCECAdapterCommunication.cpp
src/lib/adapter/USBCECAdapterCommunication.h
src/lib/adapter/USBCECAdapterMessageQueue.cpp
src/lib/devices/CECBusDevice.cpp
src/lib/devices/CECBusDevice.h
src/testclient/main.cpp

index 4775e74c558da593d5c83c9eb4065c5140ee20d8..6de565d2fb4c37e8402cf26a70d046f787c4200a 100644 (file)
@@ -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
index 5dbb9c8de19f6226ff26c8ee646cde7e48915bc7..c601afc3f9f573683e2dc2648ebac02dd55b998c 100644 (file)
@@ -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 <enter>.");
+    PrintToStdOut("Please enter the physical address (0001 - FFFE), followed by <enter>.");
     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;
     }
   }
index 2f7fcaceaa102dcedc39902e468b63cd7979adb2..8838df620a187b1d03fbf310503a97a5b8200ac4 100644 (file)
@@ -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();
index 9b7a6e3cd463c44a93e6822087b2ed824c5c44a4..c93d8fefff47c3f95417c83adb7c2b4f8a779e2c 100644 (file)
@@ -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);
 
index 4812e39007726489ef19cbf94c46c929536603e9..608375fe232954ffa61163a88f5bd43406040988 100644 (file)
@@ -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;
index b0853de56979dbd34672277b5fea717368a1085f..563cec1ca1c0a0d7db8561280e2247a2a05c055d 100644 (file)
@@ -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, ...);
index db0fbe6cc4e72f1cc3c4a915ddd3a37e111ee50e..48883bb2f3a07646d2b8894f0ad10c5493c67fe7 100644 (file)
@@ -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
index d1e3565610973ddcf4a81b3cdd3a12c79fee716a..df295e5033aa59e05bc09b7229ba50755c7884fa 100644 (file)
@@ -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
index b44a3ec9adb5300c9575d2aee1ce7c86bf2da2e7..a1171588bdd0777b9f1523b5acaf2f1c64c79178 100644 (file)
@@ -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).
index 64f9f00de0f6bf0dcd8bce9aa1c2166b9070f575..71289ce52687d7c5248a4aff0707dc219aa4682f 100644 (file)
@@ -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);
index 0cd28d56ae0aa47fe6bc0c7b0b5327d18f50dc16..8f02ac7e28bf9ad725cf5179a4ef43ec447e271e 100644 (file)
@@ -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);
index f5868c124ce651febc87dd6d3a537b864c919786..687186f50678eeba50d087b2e9489bc1430f1efa 100644 (file)
@@ -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);
index 58994531bf8d1f7d28708fd679f5f5d01b26cb76..65e99bcd95ee40927c195a491277bc8ca5c56005 100644 (file)
@@ -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;
     }