From: Lars Op den Kamp Date: Thu, 10 Nov 2011 17:30:00 +0000 (+0100) Subject: cec: added SetActiveSource()/cec_set_active_source() to the interface. deprecated... X-Git-Tag: upstream/2.2.0~1^2~71 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=18203d17e6894d33725dac7553d981aee735e6be;p=deb_libcec.git cec: added SetActiveSource()/cec_set_active_source() to the interface. deprecated SetActiveView()/cec_set_active_view() --- diff --git a/include/cec.h b/include/cec.h index 5c8ce12..84cd7e6 100644 --- a/include/cec.h +++ b/include/cec.h @@ -152,9 +152,15 @@ namespace CEC virtual bool StandbyDevices(cec_logical_address address = CECDEVICE_BROADCAST) = 0; /*! - * @brief Broadcast a message that notifies connected CEC capable devices that this device is the active source. + * @brief Change the active source. + * @param type The new active source. Leave empty to use the primary type * @return True when the command was sent succesfully, false otherwise. */ + virtual bool SetActiveSource(cec_device_type type = CEC_DEVICE_TYPE_RESERVED) = 0; + + /*! + * @deprecated Use SetActiveSource() instead + */ virtual bool SetActiveView(void) = 0; /*! diff --git a/include/cecc.h b/include/cecc.h index d8fef44..e4f5fd0 100644 --- a/include/cecc.h +++ b/include/cecc.h @@ -89,6 +89,12 @@ extern DECLSPEC int cec_standby_devices(cec_logical_address address = CECDEVICE_ extern DECLSPEC int cec_set_active_view(void); +#ifdef __cplusplus +extern DECLSPEC int cec_set_active_source(CEC::cec_device_type type = CEC::CEC_DEVICE_TYPE_RESERVED); +#else +extern DECLSPEC int cec_set_active_source(cec_device_type type = CEC_DEVICE_TYPE_RESERVED); +#endif + extern DECLSPEC int cec_set_inactive_view(void); #ifdef __cplusplus diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 6259dae..0759258 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -290,17 +290,33 @@ void *CCECProcessor::Process(void) return NULL; } -bool CCECProcessor::SetActiveView(void) +bool CCECProcessor::SetActiveSource(cec_device_type type /* = CEC_DEVICE_TYPE_RESERVED */) { bool bReturn(false); if (!IsRunning()) return bReturn; - if (!m_logicalAddresses.empty() && m_busDevices[m_logicalAddresses.primary]) - bReturn = SetStreamPath(m_busDevices[m_logicalAddresses.primary]->GetPhysicalAddress()); + cec_logical_address addr = m_logicalAddresses.primary; - return bReturn; + if (type != CEC_DEVICE_TYPE_RESERVED) + { + for (unsigned int iPtr = 0; iPtr < 16; iPtr++) + { + if (m_logicalAddresses[iPtr] && m_busDevices[iPtr]->m_type == type) + { + addr = (cec_logical_address) iPtr; + break; + } + } + } + + return SetStreamPath(m_busDevices[addr]->GetPhysicalAddress()); +} + +bool CCECProcessor::SetActiveView(void) +{ + return SetActiveSource(); } bool CCECProcessor::SetStreamPath(uint16_t iStreamPath) diff --git a/src/lib/CECProcessor.h b/src/lib/CECProcessor.h index 75651d7..b73b1bb 100644 --- a/src/lib/CECProcessor.h +++ b/src/lib/CECProcessor.h @@ -69,6 +69,7 @@ namespace CEC virtual uint16_t GetPhysicalAddress(void) const; virtual bool SetActiveView(void); + virtual bool SetActiveSource(cec_device_type type = CEC_DEVICE_TYPE_RESERVED); virtual bool SetInactiveView(void); virtual bool SetLogicalAddress(cec_logical_address iLogicalAddress); virtual bool SetPhysicalAddress(uint16_t iPhysicalAddress); diff --git a/src/lib/LibCEC.cpp b/src/lib/LibCEC.cpp index 7fd3e6c..0959beb 100644 --- a/src/lib/LibCEC.cpp +++ b/src/lib/LibCEC.cpp @@ -176,6 +176,11 @@ bool CLibCEC::StandbyDevices(cec_logical_address address /* = CECDEVICE_BROADCAS return m_cec && address >= CECDEVICE_TV && address <= CECDEVICE_BROADCAST ? m_cec->m_busDevices[(uint8_t)address]->Standby() : false; } +bool CLibCEC::SetActiveSource(cec_device_type type /* = CEC_DEVICE_TYPE_RESERVED */) +{ + return m_cec ? m_cec->SetActiveSource(type) : false; +} + bool CLibCEC::SetActiveView(void) { return m_cec ? m_cec->SetActiveView() : false; diff --git a/src/lib/LibCEC.h b/src/lib/LibCEC.h index 69c5b18..b3477e1 100644 --- a/src/lib/LibCEC.h +++ b/src/lib/LibCEC.h @@ -72,6 +72,7 @@ namespace CEC virtual bool PowerOnDevices(cec_logical_address address = CECDEVICE_TV); virtual bool StandbyDevices(cec_logical_address address = CECDEVICE_BROADCAST); virtual bool SetActiveView(void); + virtual bool SetActiveSource(cec_device_type type = CEC_DEVICE_TYPE_RESERVED); virtual bool SetInactiveView(void); virtual bool SetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage); virtual bool SwitchMonitoring(bool bEnable); diff --git a/src/lib/LibCECC.cpp b/src/lib/LibCECC.cpp index a2e58c5..c1250cb 100644 --- a/src/lib/LibCECC.cpp +++ b/src/lib/LibCECC.cpp @@ -179,6 +179,13 @@ int cec_set_active_view(void) return -1; } +int cec_set_active_source(cec_device_type type) +{ + if (cec_parser) + return cec_parser->SetActiveSource(type) ? 1 : 0; + return -1; +} + int cec_set_inactive_view(void) { if (cec_parser) diff --git a/src/testclient/main.cpp b/src/testclient/main.cpp index f16bcbf..3e67723 100644 --- a/src/testclient/main.cpp +++ b/src/testclient/main.cpp @@ -430,7 +430,7 @@ int main (int argc, char *argv[]) parser->PowerOnDevices(CECDEVICE_TV); flush_log(parser); - parser->SetActiveView(); + parser->SetActiveSource(); flush_log(parser); bool bContinue(true); @@ -666,8 +666,8 @@ int main (int argc, char *argv[]) parser->Open(g_strPort.c_str()); flush_log(parser); - cout << "setting active view" << endl; - parser->SetActiveView(); + cout << "setting active source" << endl; + parser->SetActiveSource(); } else if (command == "h" || command == "help") {