cosmetics
[deb_libcec.git] / src / lib / CECProcessor.cpp
index 60a6d1921944c1bbb6be47cfb610867003b91e32..ec0eb554d62a3e23ab1723bc2604f8c93693f59a 100644 (file)
@@ -157,6 +157,10 @@ bool CCECProcessor::Start(const char *strPort, uint16_t iBaudRate /* = 38400 */,
 
     if (SetHDMIPort(m_iBaseDevice, m_iHDMIPort, true))
     {
+      /* init the default handler */
+      if (m_busDevices[CECDEVICE_TV]->GetHandler()->GetVendorId() == CEC_VENDOR_UNKNOWN)
+        m_busDevices[CECDEVICE_TV]->GetHandler()->InitHandler();
+
       m_controller->AddLog(CEC_LOG_DEBUG, "processor thread started");
       m_busScan = new CCECBusScan(this);
       m_busScan->CreateThread(true);
@@ -330,12 +334,15 @@ bool CCECProcessor::SetActiveSource(cec_device_type type /* = CEC_DEVICE_TYPE_RE
   }
 
   m_busDevices[addr]->SetActiveSource();
-  bReturn = m_busDevices[addr]->TransmitActiveSource();
-
-  if (bReturn && (m_busDevices[addr]->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE ||
-      m_busDevices[addr]->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE))
+  if (m_busDevices[addr]->GetPhysicalAddress(false) != 0xFFFF)
   {
-    bReturn = ((CCECPlaybackDevice *)m_busDevices[addr])->TransmitDeckStatus(CECDEVICE_TV);
+    bReturn = m_busDevices[addr]->TransmitActiveSource();
+
+    if (bReturn && (m_busDevices[addr]->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE ||
+        m_busDevices[addr]->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE))
+    {
+      bReturn = ((CCECPlaybackDevice *)m_busDevices[addr])->TransmitDeckStatus(CECDEVICE_TV);
+    }
   }
 
   return bReturn;
@@ -585,29 +592,29 @@ bool CCECProcessor::PollDevice(cec_logical_address iAddress)
   return false;
 }
 
-uint8_t CCECProcessor::VolumeUp(void)
+uint8_t CCECProcessor::VolumeUp(bool bSendRelease /* = true */)
 {
   uint8_t status = 0;
   if (IsPresentDevice(CECDEVICE_AUDIOSYSTEM))
-    status = ((CCECAudioSystem *)m_busDevices[CECDEVICE_AUDIOSYSTEM])->VolumeUp();
+    status = ((CCECAudioSystem *)m_busDevices[CECDEVICE_AUDIOSYSTEM])->VolumeUp(bSendRelease);
 
   return status;
 }
 
-uint8_t CCECProcessor::VolumeDown(void)
+uint8_t CCECProcessor::VolumeDown(bool bSendRelease /* = true */)
 {
   uint8_t status = 0;
   if (IsPresentDevice(CECDEVICE_AUDIOSYSTEM))
-    status = ((CCECAudioSystem *)m_busDevices[CECDEVICE_AUDIOSYSTEM])->VolumeDown();
+    status = ((CCECAudioSystem *)m_busDevices[CECDEVICE_AUDIOSYSTEM])->VolumeDown(bSendRelease);
 
   return status;
 }
 
-uint8_t CCECProcessor::MuteAudio(void)
+uint8_t CCECProcessor::MuteAudio(bool bSendRelease /* = true */)
 {
   uint8_t status = 0;
   if (IsPresentDevice(CECDEVICE_AUDIOSYSTEM))
-    status = ((CCECAudioSystem *)m_busDevices[CECDEVICE_AUDIOSYSTEM])->MuteAudio();
+    status = ((CCECAudioSystem *)m_busDevices[CECDEVICE_AUDIOSYSTEM])->MuteAudio(bSendRelease);
 
   return status;
 }
@@ -646,6 +653,15 @@ CCECBusDevice *CCECProcessor::GetDeviceByType(cec_device_type type) const
   return device;
 }
 
+CCECBusDevice *CCECProcessor::GetPrimaryDevice(void) const
+{
+  CCECBusDevice *device(NULL);
+  cec_logical_address primary = m_logicalAddresses.primary;
+  if (primary != CECDEVICE_UNKNOWN)
+    device = m_busDevices[primary];
+  return device;
+}
+
 cec_version CCECProcessor::GetDeviceCecVersion(cec_logical_address iAddress)
 {
   return m_busDevices[iAddress]->GetCecVersion();
@@ -1002,12 +1018,12 @@ bool CCECProcessor::SetAckMask(uint16_t iMask)
   return bReturn;
 }
 
-bool CCECProcessor::TransmitKeypress(cec_logical_address iDestination, cec_user_control_code key)
+bool CCECProcessor::TransmitKeypress(cec_logical_address iDestination, cec_user_control_code key, bool bWait /* = true */)
 {
   return m_busDevices[iDestination]->TransmitKeypress(key);
 }
 
-bool CCECProcessor::TransmitKeyRelease(cec_logical_address iDestination)
+bool CCECProcessor::TransmitKeyRelease(cec_logical_address iDestination, bool bWait /* = true */)
 {
   return m_busDevices[iDestination]->TransmitKeyRelease();
 }