-
Notifications
You must be signed in to change notification settings - Fork 4
RDKEMW-9781: Video format issue on MTK #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RDKEMW-9781: Video format issue on MTK #199
Conversation
Enhance the retry mechanism for AudioPort and VideoDeviceInit as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR addresses RDKEMW-9781, a video format issue on MTK platforms by enhancing the initialization retry mechanism. The changes extract the existing retry logic into a reusable helper function and extend retry capabilities to AudioPort and VideoDevice initialization, which previously had no retry mechanism.
Changes:
- Introduced a new
retryInitializationhelper function with configurable retry logic - Extended retry mechanism to dsAudioPortInit, dsVideoPortInit, and dsVideoDeviceInit (previously only dsDisplayInit had retries)
- Refactored Manager::Initialize to use the new helper function for cleaner code
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ds/manager.cpp
Outdated
| * @param[in] maxRetries Maximum number of retry attempts. Defaults to 25. The function will | ||
| * retry up to this many times with a 100ms delay between attempts. |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation states that the function "retries up to this many times with a 100ms delay between attempts" for the maxRetries parameter. However, due to the loop logic issue, the actual behavior may differ. The delay happens after a failed attempt but before checking the retry count, and the post-increment in the condition means the number of executions may not match the documented behavior precisely. This documentation should be clarified once the loop logic is corrected.
ds/manager.cpp
Outdated
| err = retryInitialization("dsAudioPortInit", dsAudioPortInit); | ||
| CHECK_RET_VAL(err); | ||
| err = dsVideoPortInit(); | ||
|
|
||
| err = retryInitialization("dsVideoPortInit", dsVideoPortInit); |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The retry behavior has changed for dsAudioPortInit and dsVideoPortInit. Previously, these functions were called directly without retries. Now they use the retry mechanism with default parameters (maxRetries=25, checkInvalidState=false), meaning they will retry on ANY error up to 25 times. This is a significant behavioral change that could mask real errors and delay failure detection. Consider whether retrying on all errors is appropriate for these functions, or if they should only retry on specific errors like dsERR_INVALID_STATE similar to dsDisplayInit.
ds/manager.cpp
Outdated
| dsError_t retryInitialization(const char* functionName, | ||
| std::function<dsError_t()> initFunc, | ||
| unsigned int maxRetries = 25, | ||
| bool checkInvalidState = false) | ||
| { | ||
| dsError_t err = dsERR_GENERAL; | ||
| unsigned int retryCount = 0; | ||
|
|
||
| do { | ||
| err = initFunc(); | ||
| printf("Manager::Initialize:%s result :%d retryCount :%d\n", | ||
| functionName, err, retryCount); | ||
| if (dsERR_NONE == err) break; | ||
| usleep(100000); | ||
| } while ((checkInvalidState ? (dsERR_INVALID_STATE == err) : true) && | ||
| (retryCount++ < maxRetries)); | ||
|
|
||
| return err; | ||
| } |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new retryInitialization function and the modified retry behavior in Manager::Initialize lack test coverage. Given that the test directory contains tests for other device settings components, consider adding tests to verify the retry logic works correctly, including edge cases like maximum retries reached, successful retry after failures, and the checkInvalidState parameter behavior.
ds/manager.cpp
Outdated
| dsError_t retryInitialization(const char* functionName, | ||
| std::function<dsError_t()> initFunc, | ||
| unsigned int maxRetries = 25, | ||
| bool checkInvalidState = false) |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default parameter value for maxRetries (25) is specified in the function definition, but this is a static function with a forward declaration at line 66. Default parameter values should only be specified in the function declaration, not in the definition. The compiler may accept this, but it's not standard practice and could cause issues. Move the default parameter values to the declaration at line 66.
ds/manager.cpp
Outdated
| VideoDeviceConfig::getInstance().load(); | ||
| } | ||
|
|
||
| err = retryInitialization("dsVideoDeviceInit", dsVideoDeviceInit); |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The retry behavior has changed for dsVideoDeviceInit. Previously, this function was called directly without retries. Now it uses the retry mechanism with default parameters (maxRetries=25, checkInvalidState=false), meaning it will retry on ANY error up to 25 times. This is a significant behavioral change that could mask real errors and delay failure detection. Consider whether retrying on all errors is appropriate for this function, or if it should only retry on specific errors like dsERR_INVALID_STATE similar to dsDisplayInit.
| err = retryInitialization("dsVideoDeviceInit", dsVideoDeviceInit); | |
| err = retryInitialization("dsVideoDeviceInit", dsVideoDeviceInit, 25, true); |
apatel859
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 10 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (IsInitialized == 0) { | ||
| needInit = true; | ||
| } | ||
| IsInitialized++; |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential race condition: If an exception is thrown after IsInitialized is incremented (line 152) but before the initialization completes, the decrement in the catch block (line 179) may not fully restore the correct state. Consider moving the IsInitialized increment to after successful initialization to ensure accurate state tracking.
| {std::lock_guard<std::mutex> lock(gManagerInitMutex); | ||
| printf("Entering %s count %d with thread id %lu\n",__FUNCTION__,IsInitialized,pthread_self()); | ||
| if (IsInitialized == 0) { | ||
| needInit = true; | ||
| } | ||
| IsInitialized++; |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation: The opening brace on line 147 uses spaces instead of tabs, which is inconsistent with the rest of the file. This should use consistent indentation with the rest of the codebase.
| {std::lock_guard<std::mutex> lock(gManagerInitMutex); | |
| printf("Entering %s count %d with thread id %lu\n",__FUNCTION__,IsInitialized,pthread_self()); | |
| if (IsInitialized == 0) { | |
| needInit = true; | |
| } | |
| IsInitialized++; | |
| {std::lock_guard<std::mutex> lock(gManagerInitMutex); | |
| printf("Entering %s count %d with thread id %lu\n",__FUNCTION__,IsInitialized,pthread_self()); | |
| if (IsInitialized == 0) { | |
| needInit = true; | |
| } | |
| IsInitialized++; |
…MTK-Video-format-cb-issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
RDKEMW-9781: Video format issue on MTK
Enhance the retry mechanism for AudioPort and VideoDeviceInit as well