diff --git a/CHANGELOG.md b/CHANGELOG.md index c374a0ec..864cb2a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,18 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.0.28](https://github.com/rdkcentral/devicesettings/compare/1.0.27...1.0.28) + +- RDKEMW-9781: Video format issue on MTK [`#199`](https://github.com/rdkcentral/devicesettings/pull/199) +- RDKEMW-12054: Fix Coverity identified issues [`#190`](https://github.com/rdkcentral/devicesettings/pull/190) +- Merge tag '1.0.27' into develop [`56fabff`](https://github.com/rdkcentral/devicesettings/commit/56fabffd8576c37eedb03dac31c3238fa318977d) + #### [1.0.27](https://github.com/rdkcentral/devicesettings/compare/1.0.26...1.0.27) +> 12 January 2026 + - RDKEMW-11232 getAudioFormatApi issue on Xione-UK [`#188`](https://github.com/rdkcentral/devicesettings/pull/188) +- 1.0.27 release change log updates [`6594764`](https://github.com/rdkcentral/devicesettings/commit/6594764c3fde44fdb313576482cd7c2589fe1493) - Merge tag '1.0.26' into develop [`62858d9`](https://github.com/rdkcentral/devicesettings/commit/62858d954e5871070b4e0433c9e06abaf8ff97d1) #### [1.0.26](https://github.com/rdkcentral/devicesettings/compare/1.0.25...1.0.26) diff --git a/ds/audioOutputPort.cpp b/ds/audioOutputPort.cpp index e5c8fabc..2d5fde04 100644 --- a/ds/audioOutputPort.cpp +++ b/ds/audioOutputPort.cpp @@ -131,7 +131,7 @@ AudioOutputPort::AudioOutputPort(const int type, const int index, const int id) out << getType().getName() << _index; _name = out.str(); } - printf ("\nAudioOutputPort init: _type:%d _index:%d _handle:%d\n", _type, _index, _handle); + printf ("\nAudioOutputPort init: _type:%d _index:%d _handle:%ld\n", _type, _index, (long)_handle); if (dsERR_NONE == ret) { //dsGetAudioCompression (_handle, (dsAudioCompression_t *)&_compression); dsGetAudioEncoding (_handle, (dsAudioEncoding_t *)&_encoding); @@ -184,7 +184,7 @@ dsError_t AudioOutputPort::reInitializeAudioOutputPort() _name = out.str(); } - printf ("\nAudioOutputPort init: _type:%d _index:%d _handle:%d\n", _type, _index, _handle); + printf ("\nAudioOutputPort init: _type:%d _index:%d _handle:%ld\n", _type, _index,(long)_handle); if (dsERR_NONE == ret) { //dsGetAudioCompression>(_handle, (dsAudioCompression_t *)&_compression); dsGetAudioEncoding(_handle, (dsAudioEncoding_t *)&_encoding); @@ -1422,11 +1422,11 @@ void AudioOutputPort::setAudioDelay(const uint32_t audioDelayMs) dsError_t ret = dsERR_NONE; uint32_t ms = audioDelayMs; - INT_INFO("AudioOutputPort [%s], setting delay to [%lu] ms\n", _name.c_str(), audioDelayMs); + INT_INFO("AudioOutputPort [%s], setting delay to [%u] ms\n", _name.c_str(), audioDelayMs); if (ms > audioDelayMsMax) { - INT_ERROR("AudioOutputPort [%s], delay [%lu] ms, exceeds max [%lu]. Setting Max \n", + INT_ERROR("AudioOutputPort [%s], delay [%u] ms, exceeds max [%u]. Setting Max \n", _name.c_str(), audioDelayMs, audioDelayMsMax); diff --git a/ds/edid-parser.cpp b/ds/edid-parser.cpp index 728a735c..9d51077c 100644 --- a/ds/edid-parser.cpp +++ b/ds/edid-parser.cpp @@ -55,7 +55,6 @@ static void parse_std_timing(unsigned char* bytes, edid_data_t* data_ptr) { case 1: v = (h * 3) / 4; break; case 2: v = (h * 4) / 5; break; case 3: v = (h * 9) / 16; break; - default: return; } int r = (bytes[idx + 1] & 0x3F) + 60; INT_DEBUG("STD %dx%d@%d\n", h, v, r); @@ -381,8 +380,6 @@ static void parse_ext_timing(unsigned char* bytes, edid_data_t* data_ptr) { case 6: break; // 'Use Extended Tag' case 7: parse_extended_db(&bytes[idx], data_ptr); break; - // default - unsupported - default: INT_DEBUG("Unsupported extension tag: 0x%X\n", tag); } idx += len + 1; } diff --git a/ds/hdmiIn.cpp b/ds/hdmiIn.cpp index 514cff14..f107bba0 100755 --- a/ds/hdmiIn.cpp +++ b/ds/hdmiIn.cpp @@ -528,7 +528,7 @@ void HdmiInput::getHDMISPDInfo (int iHdmiPort, std::vector &data) { data.clear(); if (ret == dsERR_NONE) { if (sizeof(spdinfo) <= sizeof(struct dsSpd_infoframe_st)) { - printf("HdmiInput::getHDMISPDInfo has %d bytes\r\n", sizeof(spdinfo)); + printf("HdmiInput::getHDMISPDInfo has %zu bytes\r\n", sizeof(spdinfo)); data.insert(data.begin(), spdinfo, spdinfo + sizeof(struct dsSpd_infoframe_st)); } else { ret = dsERR_OPERATION_NOT_SUPPORTED; diff --git a/ds/include/exception.hpp b/ds/include/exception.hpp index 463435c7..bbb9836e 100644 --- a/ds/include/exception.hpp +++ b/ds/include/exception.hpp @@ -64,7 +64,7 @@ class Exception : public std::exception { * * @return None */ - Exception(const char *msg = "No Message for this exception") throw() : _msg(msg) { + Exception(const char *msg = "No Message for this exception") throw() : _err(0), _msg(msg) { } diff --git a/ds/manager.cpp b/ds/manager.cpp index eedcd8b2..f94b9da1 100644 --- a/ds/manager.cpp +++ b/ds/manager.cpp @@ -43,6 +43,7 @@ #include "exception.hpp" #include #include +#include /** * @file manager.cpp @@ -62,6 +63,7 @@ namespace device { int Manager::IsInitialized = 0; //!< Indicates the application has initialized with devicettings modules. static std::mutex gManagerInitMutex; +static dsError_t initializeFunctionWithRetry(const char* functionName, std::function initFunc); Manager::Manager() { // TODO Auto-generated constructor stub @@ -79,6 +81,41 @@ Manager::~Manager() { }\ } +/** + * @brief Retry initialization function with configurable retry logic. + * + * This helper function attempts to initialize a device settings component by calling + * the provided initialization function. It retries the operation with a delay between + * attempts until either the operation succeeds, the maximum retry count is reached, + * or (optionally) a specific error state is encountered. + * + * @param[in] functionName Name of the initialization function being called. Used for logging + * purposes to identify which component is being initialized. + * @param[in] initFunc Lambda or function object that performs the actual initialization. + * Should return dsError_t indicating success (dsERR_NONE) or an error code. + * + * @return dsERR_NONE on successful initialization, or the last error code encountered after + * all retry attempts are exhausted. When checkInvalidState is true, also returns + * immediately with the error code if a non-dsERR_INVALID_STATE error occurs. + */ +dsError_t initializeFunctionWithRetry(const char* functionName, + std::function initFunc) +{ + dsError_t err = dsERR_GENERAL; + unsigned int retryCount = 0; + unsigned int maxRetries = 25; + + do { + err = initFunc(); + printf("Manager::Initialize:%s result :%d retryCount :%d\n", + functionName, err, retryCount); + if (dsERR_NONE == err) break; + usleep(100000); + } while (retryCount++ < maxRetries); + + return err; +} + /** * @addtogroup dssettingsmanagerapi * @{ @@ -105,44 +142,45 @@ Manager::~Manager() { */ void Manager::Initialize() { - {std::lock_guard lock(gManagerInitMutex); - printf("Entering %s count %d with thread id %lu\n",__FUNCTION__,IsInitialized,pthread_self()); + bool needInit = false; + + {std::lock_guard lock(gManagerInitMutex); + printf("Entering %s count %d with thread id %lu\n",__FUNCTION__,IsInitialized,pthread_self()); + if (IsInitialized == 0) { + needInit = true; + } + IsInitialized++; + } - try { - if (0 == IsInitialized) { - - dsError_t err = dsERR_GENERAL; - unsigned int retryCount = 0; - // This retry logic will wait for the device manager initialization from the client side - // until the device manager service initialization is completed. The retry mechanism checks - // only for dsERR_INVALID_STATE, which is reported if the underlying service is not ready. - // Once the service is ready, other port initializations can be called directly without any delay. - // That's why the retry logic is applied only for dsDisplayInit. - do { - err = dsDisplayInit(); - printf ("Manager::Initialize: result :%d retryCount :%d\n", err, retryCount); - if (dsERR_NONE == err) break; - usleep(100000); - } while(( dsERR_INVALID_STATE == err) && (retryCount++ < 25)); + try { + if (needInit) { + dsError_t err = dsERR_GENERAL; + + err = initializeFunctionWithRetry("dsDisplayInit", dsDisplayInit); CHECK_RET_VAL(err); - err = dsAudioPortInit(); + + err = initializeFunctionWithRetry("dsAudioPortInit", dsAudioPortInit); CHECK_RET_VAL(err); - err = dsVideoPortInit(); + + err = initializeFunctionWithRetry("dsVideoPortInit", dsVideoPortInit); CHECK_RET_VAL(err); - err = dsVideoDeviceInit(); - CHECK_RET_VAL(err); - AudioOutputPortConfig::getInstance().load(); - VideoOutputPortConfig::getInstance().load(); - VideoDeviceConfig::getInstance().load(); - } - IsInitialized++; + + err = initializeFunctionWithRetry("dsVideoDeviceInit", dsVideoDeviceInit); + CHECK_RET_VAL(err); + + AudioOutputPortConfig::getInstance().load(); + VideoOutputPortConfig::getInstance().load(); + VideoDeviceConfig::getInstance().load(); + } } catch(const Exception &e) { - cout << "Caught exception during Initialization" << e.what() << endl; - throw e; - } - } - printf("Exiting %s with thread %lu\n",__FUNCTION__,pthread_self()); + cout << "Caught exception during Initialization" << e.what() << endl; + std::lock_guard lock(gManagerInitMutex); + IsInitialized--; + throw e; + } + + printf("Exiting %s with thread %lu\n",__FUNCTION__,pthread_self()); } void Manager::load() diff --git a/ds/videoDevice.cpp b/ds/videoDevice.cpp index 37452a0c..88726d9d 100644 --- a/ds/videoDevice.cpp +++ b/ds/videoDevice.cpp @@ -101,7 +101,7 @@ VideoDevice & VideoDevice::getInstance(int id) * @param[in] id Port id. * @return None. */ -VideoDevice::VideoDevice(int id) +VideoDevice::VideoDevice(int id): _dfc(0) { dsError_t ret = dsGetVideoDevice(id, &_handle); diff --git a/rpc/cli/dsVideoPort.c b/rpc/cli/dsVideoPort.c index 5ff4c9e4..d8e15541 100644 --- a/rpc/cli/dsVideoPort.c +++ b/rpc/cli/dsVideoPort.c @@ -82,7 +82,7 @@ dsError_t dsGetVideoPort(dsVideoPortType_t type, int index, intptr_t *handle) ¶m, sizeof(param)); - printf("%s..%d-%d\n",__func__,param.type,param.handle); + printf("%s..%d-%ld\n",__func__,param.type,(long)param.handle); if (IARM_RESULT_SUCCESS == rpcRet) { @@ -530,7 +530,7 @@ dsError_t dsEnableHDCP(intptr_t handle, bool contentProtect, char *hdcpKey, siz } } - printf("IARM:CLI:dsEnableHDCP %d, %p, %d\r\n", contentProtect, hdcpKey, keySize); + printf("IARM:CLI:dsEnableHDCP %d, %p, %zu\r\n", contentProtect, hdcpKey, keySize); IARM_Result_t rpcRet = IARM_RESULT_SUCCESS; rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME, diff --git a/rpc/srv/dsAudio.c b/rpc/srv/dsAudio.c index e08428a5..40d696f7 100755 --- a/rpc/srv/dsAudio.c +++ b/rpc/srv/dsAudio.c @@ -1624,7 +1624,7 @@ void AudioConfigInit() m_volumeLeveller.level = atoi(_volLevellerLevel.c_str()); //SPEAKER init handle = 0; - INT_DEBUG("bDolbyVolumeOverrideCheck value: %d\n", bDolbyVolumeOverrideCheck); + INT_DEBUG("bDolbyVolumeOverrideCheck value: %d\n", (int)bDolbyVolumeOverrideCheck); if(bDolbyVolumeOverrideCheck && dsGetAudioPort(dsAUDIOPORT_TYPE_SPEAKER,0,&handle) == dsERR_NONE) { if (dsSetVolumeLevellerFunc(handle, m_volumeLeveller) == dsERR_NONE) { INT_INFO("Port %s: Initialized Volume Leveller : Mode: %d, Level: %d\n","SPEAKER0", m_volumeLeveller.mode, m_volumeLeveller.level); @@ -2357,10 +2357,18 @@ IARM_Result_t dsAudioMgr_init() IARM_Result_t dsAudioMgr_term() { #ifdef DS_AUDIO_SETTINGS_PERSISTENCE - if(persist_audioLevel_timer_threadIsAlive){ + bool shouldJoin = false; + pthread_t threadId; + IARM_BUS_Lock(lock); + shouldJoin = persist_audioLevel_timer_threadIsAlive; + if(shouldJoin){ persist_audioLevel_timer_threadIsAlive=false; + threadId = persist_audioLevel_timer_threadId; pthread_cond_signal(&audioLevelTimerCV); - pthread_join(persist_audioLevel_timer_threadId,NULL); + } + IARM_BUS_Unlock(lock); + if(shouldJoin){ + pthread_join(threadId,NULL); } #endif return IARM_RESULT_SUCCESS; @@ -7227,6 +7235,7 @@ static void* persist_audioLevel_timer_threadFunc(void* arg) { break; } // wait for 3 sec, then update the latest audio level from cache variable + /* coverity[sleep : FALSE] */ if(audioLevel_timer_set){ sleep(3); diff --git a/sample/testFrontPanel.cpp b/sample/testFrontPanel.cpp old mode 100755 new mode 100644 index b1bddee4..fec714bf --- a/sample/testFrontPanel.cpp +++ b/sample/testFrontPanel.cpp @@ -118,7 +118,12 @@ int main(int argc, char *argv[]) printf("Exception Caught during [%s]\r\n", argv[0]); } - device::Manager::DeInitialize(); + try { + device::Manager::DeInitialize(); + } + catch (...) { + printf("Unknown exception during DeInitialize\n"); + } IARM_Bus_Disconnect();