Skip to content

Comments

RDKEMW-11232 getAudioFormatApi issue on Xione-UK#188

Merged
apatel859 merged 11 commits intodevelopfrom
topic/RDKEMW-11232-getAudioFormat-Issue
Jan 12, 2026
Merged

RDKEMW-11232 getAudioFormatApi issue on Xione-UK#188
apatel859 merged 11 commits intodevelopfrom
topic/RDKEMW-11232-getAudioFormat-Issue

Conversation

@kiruba115
Copy link
Contributor

RDKEMW-11232 getAudioFormatApi issue on Xione-UK

@kiruba115 kiruba115 requested a review from a team as a code owner December 17, 2025 17:06
Copy link
Contributor

Copilot AI left a 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 pull request fixes an issue with the getAudioFormat API on Xione-UK by ensuring a valid audio port handle is passed instead of NULL. The fix introduces a new method to select the appropriate audio port based on platform configuration and connection status.

Changes:

  • Enhanced error logging in dsGetAudioFormat RPC handler to track failure scenarios
  • Added new getAudioPortHandle() method to intelligently select audio ports based on platform type and port availability
  • Modified getCurrentAudioFormat() to use the new port selection method instead of passing NULL

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 10 comments.

File Description
rpc/srv/dsAudio.c Improved error handling by storing return value and adding logging for failure cases
ds/include/host.hpp Added declaration for new getAudioPortHandle() method
ds/include/audioOutputPort.hpp Added getter method to expose internal _handle member and minor formatting changes
ds/host.cpp Implemented getAudioPortHandle() with platform-specific port selection logic and updated getCurrentAudioFormat() to use it

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 388 to 445
intptr_t Host::getAudioPortHandle()
{
try
{
if (isHDMIOutPortPresent())
{
AudioOutputPort aPort = getAudioOutputPort("HDMI0");
return aPort.getOutputPortHandle();
}
else
{
//TV profiles with multiple audio output ports
try
{
// Define the priority order for audio ports
const std::string portPriority[] = {"HDMI_ARC0", "HEADPHONE0", "SPDIF0"};

// Try each port in priority order
for (const auto& portName : portPriority)
{
try
{
AudioOutputPort aPort = getAudioOutputPort(portName);
cout << "Checking audio port: " << portName << " isEnabled: " << aPort.isEnabled() << " isConnected: " << aPort.isConnected() << "\n";
// Check if port is enabled and connected
if (aPort.isEnabled() && aPort.isConnected())
{
cout << "Using audio port: " << portName << "\n";
return aPort.getOutputPortHandle();
}
}
catch(const std::exception& e)
{
// Port not found or error accessing it, continue to next port
continue;
}
}

// Fallback: use SPEAKER0 if no other port is suitable
AudioOutputPort fallback_aPort = getAudioOutputPort("SPEAKER0");
cout << "Using audio port: SPEAKER0" << "\n";
return fallback_aPort.getOutputPortHandle();
}
catch(const std::exception& e)
{
cout << " Exception Thrown in getAudioPortHandle().. returning NULL...!\n";
}

return NULL;
}
}
catch(const std::exception& e)
{
cout << " Exception Thrown in getAudioPortHandle().. returning NULL...!\n";
}

return NULL;
}
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new method getAudioPortHandle() lacks test coverage. Consider adding test cases in test/testHost.cpp to verify the port selection logic, including scenarios for HDMI out presence, priority-based port selection, enabled/connected state checks, and fallback behavior.

Copilot uses AI. Check for mistakes.
ds/host.cpp Outdated
try
{
AudioOutputPort aPort = getAudioOutputPort(portName);
cout << "Checking audio port: " << portName << " isEnabled: " << aPort.isEnabled() << " isConnected: " << aPort.isConnected() << "\n";
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation is inconsistent, using tabs instead of spaces like the surrounding code. Lines 411, 428 use tabs for indentation while the rest of the function uses spaces. This should be consistent with the file's indentation style.

Copilot uses AI. Check for mistakes.
ds/host.cpp Outdated

// Fallback: use SPEAKER0 if no other port is suitable
AudioOutputPort fallback_aPort = getAudioOutputPort("SPEAKER0");
cout << "Using audio port: SPEAKER0" << "\n";
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation is inconsistent, using tabs instead of spaces like the surrounding code. This should be consistent with the file's indentation style.

Copilot uses AI. Check for mistakes.
ds/host.cpp Outdated
Comment on lines 431 to 433
catch(const std::exception& e)
{
cout << " Exception Thrown in getAudioPortHandle().. returning NULL...!\n";
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exception variable 'e' is caught but never used. Consider logging the exception message using e.what() to provide better debugging information, similar to other exception handlers in this file (e.g., line 141 in manager.cpp).

Copilot uses AI. Check for mistakes.
ds/host.cpp Outdated
cout << " Exception Thrown in getAudioPortHandle().. returning NULL...!\n";
}

return NULL;
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return statement at line 436 is unreachable code. If getAudioOutputPort("SPEAKER0") at line 427 succeeds, the function returns at line 429. If it throws an exception, it's caught at line 431, which then falls through to the outer catch block at line 439 or returns NULL at line 444. This return statement can never be executed and should be removed.

Copilot uses AI. Check for mistakes.
ds/host.cpp Outdated
dsAudioFormat_t aFormat;

ret = dsGetAudioFormat(NULL, &aFormat);
intptr_t audioPortHandle = getAudioPortHandle();
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation is inconsistent, using tabs instead of spaces like the surrounding code. This should be consistent with the file's indentation style.

Suggested change
intptr_t audioPortHandle = getAudioPortHandle();
intptr_t audioPortHandle = getAudioPortHandle();

Copilot uses AI. Check for mistakes.
@@ -385,6 +385,65 @@ Host::~Host()
return std::string(socID);
}

Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new method getAudioPortHandle() is missing documentation. It should have a doxygen-style comment block describing its purpose, return value, and any exceptions it may throw, consistent with other methods in this file.

Suggested change
/**
* @fn Host::getAudioPortHandle()
* @brief Get the handle of the active audio output port.
*
* This API selects an appropriate audio output port and returns its
* underlying handle. On platforms with an HDMI output port, the handle
* for HDMI0 is returned. On TV profiles with multiple audio output ports,
* the ports are checked in the following priority order:
* HDMI_ARC0, HEADPHONE0, SPDIF0. The first port that is enabled and
* connected is used. If none of these ports are suitable, SPEAKER0 is
* used as a fallback.
*
* @return intptr_t Handle of the selected audio output port on success.
* @return NULL If no suitable audio port handle can be obtained or if
* an error occurs while resolving the port.
*
* @exception std::exception Exceptions from underlying audio port queries
* are caught and cause this method to return NULL.
*/

Copilot uses AI. Check for mistakes.
Comment on lines 439 to 442
catch(const std::exception& e)
{
cout << " Exception Thrown in getAudioPortHandle().. returning NULL...!\n";
}
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exception variable 'e' is caught but never used. Consider logging the exception message using e.what() to provide better debugging information, similar to other exception handlers in this file (e.g., line 141 in manager.cpp).

Copilot uses AI. Check for mistakes.
kiruba115 and others added 5 commits January 12, 2026 13:42
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@apatel859 apatel859 merged commit 5dd27d7 into develop Jan 12, 2026
8 of 9 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants