From 41e3372ac4ad2de0d20e19e9dc9c8776220451b1 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Mon, 27 Feb 2012 21:25:46 +0100 Subject: [PATCH] cec: added an 'send inactive source' option to libcec_configuration, only supported by client/server 1.5.1 and up. bugzid: 439 --- include/cectypes.h | 15 +++++++++----- src/cec-config/cec-config.cpp | 38 ++++++++++++++++++++++++++--------- src/lib/CECProcessor.cpp | 16 +++++++++++++-- src/lib/LibCEC.cpp | 2 +- 4 files changed, 54 insertions(+), 17 deletions(-) diff --git a/include/cectypes.h b/include/cectypes.h index 91fd94d..76056cd 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -79,6 +79,7 @@ namespace CEC { #define CEC_DEFAULT_SETTING_POWER_OFF_SHUTDOWN 1 #define CEC_DEFAULT_SETTING_POWER_OFF_SCREENSAVER 1 #define CEC_DEFAULT_SETTING_POWER_OFF_ON_STANDBY 1 +#define CEC_DEFAULT_SETTING_SEND_INACTIVE_SOURCE 1 #define CEC_DEFAULT_TRANSMIT_RETRY_WAIT 500 #define CEC_DEFAULT_TRANSMIT_TIMEOUT 1000 @@ -946,13 +947,15 @@ typedef struct ICECCallbacks typedef enum cec_client_version { CEC_CLIENT_VERSION_PRE_1_5 = 0, - CEC_CLIENT_VERSION_1_5_0 = 0x1500 + CEC_CLIENT_VERSION_1_5_0 = 0x1500, + CEC_CLIENT_VERSION_1_5_1 = 0x1501 } cec_client_version; typedef enum cec_server_version { CEC_SERVER_VERSION_PRE_1_5 = 0, - CEC_SERVER_VERSION_1_5_0 = 0x1500 + CEC_SERVER_VERSION_1_5_0 = 0x1500, + CEC_SERVER_VERSION_1_5_1 = 0x1501 } cec_server_version; typedef struct libcec_configuration @@ -976,6 +979,7 @@ typedef struct libcec_configuration uint8_t bActivateSource; /*!< make libCEC the active source on the bus when starting the player application */ uint8_t bPowerOffScreensaver; /*!< put devices in standby mode when activating the screensaver */ uint8_t bPowerOffOnStandby; /*!< put this PC in standby mode when the TV is switched off */ + uint8_t bSendInactiveSource; /*!< send an 'inactive source' message when stopping the player. added in 1.5.1 */ void * callbackParam; /*!< the object to pass along with a call of the callback methods. NULL to ignore */ ICECCallbacks * callbacks; /*!< the callback methods to use. set this to NULL when not using callbacks */ @@ -1001,11 +1005,12 @@ typedef struct libcec_configuration #if CEC_DEFAULT_SETTING_POWER_OFF_SHUTDOWN == 1 powerOffDevices.Set(CECDEVICE_BROADCAST); #endif - #if CEC_DEFAULT_SETTING_ACTIVATE_SOURCE == 1 - wakeDevices.Set(CECDEVICE_TV); - #endif + #if CEC_DEFAULT_SETTING_ACTIVATE_SOURCE == 1 + wakeDevices.Set(CECDEVICE_TV); + #endif bPowerOffScreensaver = CEC_DEFAULT_SETTING_POWER_OFF_SCREENSAVER; bPowerOffOnStandby = CEC_DEFAULT_SETTING_POWER_OFF_ON_STANDBY; + bSendInactiveSource = CEC_DEFAULT_SETTING_SEND_INACTIVE_SOURCE; callbackParam = NULL; callbacks = NULL; diff --git a/src/cec-config/cec-config.cpp b/src/cec-config/cec-config.cpp index d0840ce..c46bbac 100644 --- a/src/cec-config/cec-config.cpp +++ b/src/cec-config/cec-config.cpp @@ -410,7 +410,15 @@ int main (int UNUSED(argc), char *UNUSED(argv[])) string input; getline(cin, input); cin.clear(); - g_config.bPowerOffOnStandby = (input == "y" || input == "Y"); + g_config.bPowerOffOnStandby = (input == "y" || input == "Y") ? 1 : 0; + } + + { + PrintToStdOut("Do you want to send an inactive source message when stopping the application (y/n)?"); + string input; + getline(cin, input); + cin.clear(); + g_config.bSendInactiveSource = (input == "y" || input == "Y") ? 1 : 0; } PrintToStdOut("\n\n=== USB-CEC Adapter Configuration Summary ==="); @@ -421,7 +429,8 @@ int main (int UNUSED(argc), char *UNUSED(argv[])) PrintToStdOut("Make the adapter the active source when starting XBMC: %s", g_config.bActivateSource ? "yes" : "no"); PrintToStdOut("Power off devices when stopping XBMC: %s", g_config.powerOffDevices.IsSet(CECDEVICE_BROADCAST) ? "yes" : "no"); PrintToStdOut("Put devices in standby mode when activating screensaver: %s", g_config.bPowerOffScreensaver ? "yes" : "no"); - PrintToStdOut("Put this PC in standby mode when the TV is switched off: %s\n\n", g_config.bPowerOffOnStandby ? "yes" : "no"); + PrintToStdOut("Put this PC in standby mode when the TV is switched off: %s", g_config.bPowerOffOnStandby ? "yes" : "no"); + PrintToStdOut("Seend an inactive source message when stopping XBMC: %s\n\n", g_config.bSendInactiveSource ? "yes" : "no"); if (g_parser->CanPersistConfiguration()) { @@ -446,18 +455,29 @@ int main (int UNUSED(argc), char *UNUSED(argv[])) configOutput.open("usb_2548_1001.xml"); if (configOutput.is_open()) { + CStdString strWakeDevices; + for (uint8_t iPtr = 0; iPtr < 16; iPtr++) + if (g_config.wakeDevices[iPtr]) + strWakeDevices.AppendFormat(" %d" + iPtr); + CStdString strStandbyDevices; + for (uint8_t iPtr = 0; iPtr < 16; iPtr++) + if (g_config.powerOffDevices[iPtr]) + strStandbyDevices.AppendFormat(" %d" + iPtr); + configOutput << "\n" << - "\t\n" << - "\t\n" << - "\t\n" << - "\t\n" << - "\t\n" << - "\t\n" << + "\t\n" << + "\t\n" << + "\t\n" << + "\t\n" << "\t\n" << "\t\n" << - "\t\n" << + "\t\n" << + "\t\n" << + "\t\n" << + "\t\n" << "\t\n" << + "\t\n" << ""; configOutput.close(); diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 5b6fb03..cf7b5b4 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -60,7 +60,7 @@ CCECProcessor::CCECProcessor(CLibCEC *controller, libcec_configuration *configur m_logicalAddresses.Clear(); CreateBusDevices(); m_configuration.Clear(); - m_configuration.serverVersion = CEC_SERVER_VERSION_1_5_0; + m_configuration.serverVersion = configuration->serverVersion; SetConfiguration(configuration); if (m_configuration.tvVendor != CEC_VENDOR_UNKNOWN) @@ -78,7 +78,7 @@ CCECProcessor::CCECProcessor(CLibCEC *controller, const char *strDeviceName, con m_iLastTransmission(0) { m_configuration.Clear(); - m_configuration.serverVersion = CEC_SERVER_VERSION_1_5_0; + m_configuration.serverVersion = CEC_SERVER_VERSION_1_5_1; // client version < 1.5.0 m_configuration.clientVersion = (uint32_t)CEC_CLIENT_VERSION_PRE_1_5; @@ -1372,6 +1372,8 @@ const char *CCECProcessor::ToString(const cec_client_version version) return "pre-1.5"; case CEC_CLIENT_VERSION_1_5_0: return "1.5.0"; + case CEC_CLIENT_VERSION_1_5_1: + return "1.5.1"; default: return "Unknown"; } @@ -1385,6 +1387,8 @@ const char *CCECProcessor::ToString(const cec_server_version version) return "pre-1.5"; case CEC_SERVER_VERSION_1_5_0: return "1.5.0"; + case CEC_SERVER_VERSION_1_5_1: + return "1.5.1"; default: return "Unknown"; } @@ -1560,6 +1564,10 @@ bool CCECProcessor::SetConfiguration(const libcec_configuration *configuration) m_configuration.bPowerOffScreensaver = configuration->bPowerOffScreensaver; m_configuration.bPowerOffOnStandby = configuration->bPowerOffOnStandby; + // client version 1.5.1 + if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_5_1) + m_configuration.bSendInactiveSource = configuration->bSendInactiveSource; + // ensure that there is at least 1 device type set if (m_configuration.deviceTypes.IsEmpty()) m_configuration.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE); @@ -1598,6 +1606,10 @@ bool CCECProcessor::GetCurrentConfiguration(libcec_configuration *configuration) configuration->bPowerOffScreensaver = m_configuration.bPowerOffScreensaver; configuration->bPowerOffOnStandby = m_configuration.bPowerOffOnStandby; + // client version 1.5.1 + if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_5_1) + configuration->bSendInactiveSource = m_configuration.bSendInactiveSource; + return true; } diff --git a/src/lib/LibCEC.cpp b/src/lib/LibCEC.cpp index a289b75..4f7fea2 100644 --- a/src/lib/LibCEC.cpp +++ b/src/lib/LibCEC.cpp @@ -59,8 +59,8 @@ CLibCEC::CLibCEC(libcec_configuration *configuration) : m_callbacks(configuration->callbacks), m_cbParam(configuration->callbackParam) { + configuration->serverVersion = CEC_SERVER_VERSION_1_5_1; m_cec = new CCECProcessor(this, configuration); - configuration->serverVersion = CEC_SERVER_VERSION_1_5_0; } CLibCEC::~CLibCEC(void) -- 2.34.1