Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 137 additions & 24 deletions rpc/srv/dsAudio.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:

Check failure on line 3 in rpc/srv/dsAudio.c

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'rpc/srv/dsAudio.c' (Match: rdk/components/generic/devicesettings/rdk/components/generic/devicesettings/b34ed54, 7171 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/devicesettings/+archive/b34ed545b533a0cf4d29d221cc23daad47f32644.tar.gz, file: rpc/srv/dsAudio.c)

Check failure on line 3 in rpc/srv/dsAudio.c

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'rpc/srv/dsAudio.c' (Match: rdk/components/generic/devicesettings/rdk/components/generic/devicesettings/2003, 7171 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/devicesettings/+archive/rdk-dev-2003.tar.gz, file: rpc/srv/dsAudio.c)

Check failure on line 3 in rpc/srv/dsAudio.c

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'rpc/srv/dsAudio.c' (Match: rdk/components/generic/devicesettings/rdk/components/generic/devicesettings/2009, 7171 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/devicesettings/+archive/rdk-dev-2009.tar.gz, file: rpc/srv/dsAudio.c)

Check failure on line 3 in rpc/srv/dsAudio.c

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'rpc/srv/dsAudio.c' (Match: rdk/components/generic/devicesettings/rdk/components/generic/devicesettings/2102, 7171 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/devicesettings/+archive/rdk-dev-2102.tar.gz, file: rpc/srv/dsAudio.c)
*
* Copyright 2016 RDK Management
*
Expand Down Expand Up @@ -83,6 +83,8 @@
dsAudioStereoMode_t _srv_SPDIF_Audiomode = dsAUDIO_STEREO_STEREO;
dsAudioStereoMode_t _srv_HDMI_ARC_Audiomode = dsAUDIO_STEREO_STEREO;
#endif
int _srv_AudioSPEAKERAuto = 1;
dsAudioStereoMode_t _srv_SPEAKER_Audiomode = dsAUDIO_STEREO_SURROUND;

#ifdef DS_AUDIO_SETTINGS_PERSISTENCE
static std::atomic<bool> persist_audioLevel_timer_threadIsAlive = ATOMIC_VAR_INIT(false);
Expand Down Expand Up @@ -2209,6 +2211,22 @@
}
}

std::string _SPEAKERAudioModeAuto("TRUE");

try {
_SPEAKERAudioModeAuto = device::HostPersistence::getInstance().getProperty("SPEAKER0.AudioMode.AUTO");
}
catch(...) {
try {
INT_DEBUG("SPEAKER0.AudioMode.AUTO not found in persistence store. Try system default\n");
_SPEAKERAudioModeAuto = device::HostPersistence::getInstance().getDefaultProperty("SPEAKER0.AudioMode.AUTO");
}
catch(...) {
_SPEAKERAudioModeAuto = "TRUE";
}
}


if(_AudioModeAuto.compare("TRUE") == 0)
{
_srv_AudioHDMIAuto = 1;
Expand All @@ -2233,10 +2251,17 @@
{
_srv_AudioSPDIFAuto = 0;
}
if (_SPEAKERAudioModeAuto.compare("TRUE") == 0){
_srv_AudioSPEAKERAuto = 1;
}
else if (_SPEAKERAudioModeAuto.compare("FALSE") == 0){
_srv_AudioSPEAKERAuto = 0;
}

INT_DEBUG("The HDMI Audio Auto Setting on startup is %s \r\n",_AudioModeAuto.c_str());
INT_DEBUG("The HDMI ARC Audio Auto Setting on startup is %s \r\n",_ARCAudioModeAuto.c_str());
INT_DEBUG("The SPDIF Audio Auto Setting on startup is %s \r\n",_SPDIFAudioModeAuto.c_str());
INT_INFO("The HDMI Audio Auto Setting on startup is %s \r\n",_AudioModeAuto.c_str());
INT_INFO("The HDMI ARC Audio Auto Setting on startup is %s \r\n",_ARCAudioModeAuto.c_str());
INT_INFO("The SPDIF Audio Auto Setting on startup is %s \r\n",_SPDIFAudioModeAuto.c_str());
INT_INFO("The SPEAKER Audio Auto Setting on startup is %s \r\n",_SPEAKERAudioModeAuto.c_str());
/* Get the AudioModesettings for SPDIF from Persistence */
std::string _SPDIFModeSettings("STEREO");
_SPDIFModeSettings = device::HostPersistence::getInstance().getProperty("SPDIF0.AudioMode",_SPDIFModeSettings);
Expand All @@ -2253,23 +2278,50 @@
{
_srv_SPDIF_Audiomode = dsAUDIO_STEREO_STEREO;
}
/* Get the AudioModesettings for HDMI_ARC from Persistence */
std::string _ARCModeSettings("STEREO");
_ARCModeSettings = device::HostPersistence::getInstance().getProperty("HDMI_ARC0.AudioMode",_ARCModeSettings);
INT_DEBUG("The HDMI ARC Audio Mode Setting on startup is %s \r\n",_ARCModeSettings.c_str());
if (_ARCModeSettings.compare("SURROUND") == 0)
{
_srv_HDMI_ARC_Audiomode = dsAUDIO_STEREO_SURROUND;
}
else if (_ARCModeSettings.compare("PASSTHRU") == 0)
{
_srv_HDMI_ARC_Audiomode = dsAUDIO_STEREO_PASSTHRU;
}
else
{
_srv_HDMI_ARC_Audiomode = dsAUDIO_STEREO_STEREO;
}
}
/* Get the AudioModesettings for HDMI_ARC from Persistence */
std::string _ARCModeSettings("STEREO");
_ARCModeSettings = device::HostPersistence::getInstance().getProperty("HDMI_ARC0.AudioMode",_ARCModeSettings);
INT_DEBUG("The HDMI ARC Audio Mode Setting on startup is %s \r\n",_ARCModeSettings.c_str());
if (_ARCModeSettings.compare("SURROUND") == 0)
{
_srv_HDMI_ARC_Audiomode = dsAUDIO_STEREO_SURROUND;
}
else if (_ARCModeSettings.compare("PASSTHRU") == 0)
{
_srv_HDMI_ARC_Audiomode = dsAUDIO_STEREO_PASSTHRU;
}
else
{
_srv_HDMI_ARC_Audiomode = dsAUDIO_STEREO_STEREO;
}

std::string _SPEAKERModeSettings("SURROUND");

try{
_SPEAKERModeSettings = device::HostPersistence::getInstance().getProperty("SPEAKER0.AudioMode",_SPEAKERModeSettings);
INT_DEBUG("The SPEAKER Audio Mode Setting on startup is %s \r\n",_SPEAKERModeSettings.c_str());
}
catch(...){
_SPEAKERModeSettings = "SURROUND";
}

if (_SPEAKERModeSettings.compare("SURROUND") == 0)
{
_srv_SPEAKER_Audiomode = dsAUDIO_STEREO_SURROUND;
}
else if (_SPEAKERModeSettings.compare("PASSTHRU") == 0)
{
_srv_SPEAKER_Audiomode = dsAUDIO_STEREO_PASSTHRU;
}
else if (_SPEAKERModeSettings.compare("STEREO") == 0)
{
_srv_SPEAKER_Audiomode = dsAUDIO_STEREO_STEREO;
}
else
{
_srv_SPEAKER_Audiomode = dsAUDIO_STEREO_SURROUND;
}
}
catch(...)
{
INT_INFO("Exception in Getting the Audio settings on Startup..... \r\n");
Expand Down Expand Up @@ -2506,6 +2558,12 @@
}
param->mode = stereoMode;
}
else if (_APortType == dsAUDIOPORT_TYPE_SPEAKER) {
ret = dsGetStereoMode(param->handle, &param->mode);
if(ret == dsERR_NONE) {
result = IARM_RESULT_SUCCESS;
}
}
else {
if (_APortType == dsAUDIOPORT_TYPE_SPDIF)
{
Expand Down Expand Up @@ -2580,6 +2638,14 @@

_srv_HDMI_ARC_Audiomode = dsAUDIO_STEREO_STEREO;
}
else if (_APortType == dsAUDIOPORT_TYPE_SPEAKER)
{
if (param->toPersist){
device::HostPersistence::getInstance().persistHostProperty("SPEAKER0.AudioMode","STEREO");
}
_srv_SPEAKER_Audiomode = dsAUDIO_STEREO_STEREO;
}

eventData.data.Audioport.mode = dsAUDIO_STEREO_STEREO;
eventData.data.Audioport.type = _APortType;
IARM_Bus_BroadcastEvent(IARM_BUS_DSMGR_NAME,(IARM_EventId_t)IARM_BUS_DSMGR_EVENT_AUDIO_MODE,(void *)&eventData, sizeof(eventData));
Expand Down Expand Up @@ -2610,6 +2676,13 @@

_srv_HDMI_ARC_Audiomode = dsAUDIO_STEREO_SURROUND;
}
else if (_APortType == dsAUDIOPORT_TYPE_SPEAKER)
{
if (param->toPersist){
device::HostPersistence::getInstance().persistHostProperty("SPEAKER0.AudioMode","SURROUND");
}
_srv_SPEAKER_Audiomode = dsAUDIO_STEREO_SURROUND;
}

eventData.data.Audioport.mode = dsAUDIO_STEREO_SURROUND;
eventData.data.Audioport.type = _APortType;
Expand All @@ -2626,6 +2699,14 @@

_srv_HDMI_Audiomode = dsAUDIO_STEREO_DD;
}
else if (_APortType == dsAUDIOPORT_TYPE_SPEAKER)
{
if (param->toPersist){
device::HostPersistence::getInstance().persistHostProperty("SPEAKER0.AudioMode","DOLBYDIGITAL");
}
_srv_SPEAKER_Audiomode = dsAUDIO_STEREO_DD;
}

eventData.data.Audioport.mode = dsAUDIO_STEREO_DD;
eventData.data.Audioport.type = _APortType;
IARM_Bus_BroadcastEvent(IARM_BUS_DSMGR_NAME,(IARM_EventId_t)IARM_BUS_DSMGR_EVENT_AUDIO_MODE,(void *)&eventData, sizeof(eventData));
Expand All @@ -2641,6 +2722,14 @@

_srv_HDMI_Audiomode = dsAUDIO_STEREO_DDPLUS;
}
else if (_APortType == dsAUDIOPORT_TYPE_SPEAKER)
{
if (param->toPersist){
device::HostPersistence::getInstance().persistHostProperty("SPEAKER0.AudioMode","DOLBYDIGITALPLUS");
}
_srv_SPEAKER_Audiomode = dsAUDIO_STEREO_DDPLUS;
}

eventData.data.Audioport.mode = dsAUDIO_STEREO_DDPLUS;
eventData.data.Audioport.type = _APortType;
IARM_Bus_BroadcastEvent(IARM_BUS_DSMGR_NAME,(IARM_EventId_t)IARM_BUS_DSMGR_EVENT_AUDIO_MODE,(void *)&eventData, sizeof(eventData));
Expand Down Expand Up @@ -2668,6 +2757,13 @@

_srv_HDMI_ARC_Audiomode = dsAUDIO_STEREO_PASSTHRU;
}
else if (_APortType == dsAUDIOPORT_TYPE_SPEAKER)
{
if (param->toPersist){
device::HostPersistence::getInstance().persistHostProperty("SPEAKER0.AudioMode","PASSTHRU");
}
_srv_SPEAKER_Audiomode = dsAUDIO_STEREO_PASSTHRU;
}

eventData.data.Audioport.mode = dsAUDIO_STEREO_PASSTHRU;
eventData.data.Audioport.type = _APortType;
Expand Down Expand Up @@ -2712,6 +2808,9 @@
else if (_APortType == dsAUDIOPORT_TYPE_SPDIF) {
param->autoMode = _srv_AudioSPDIFAuto ? 1 : 0;
}
else if (_APortType == dsAUDIOPORT_TYPE_SPEAKER) {
param->autoMode = _srv_AudioSPEAKERAuto ? 1 : 0;
}
}

IARM_BUS_Unlock(lock);
Expand Down Expand Up @@ -2746,6 +2845,10 @@
_srv_AudioSPDIFAuto = param->autoMode;
break;

case dsAUDIOPORT_TYPE_SPEAKER:
device::HostPersistence::getInstance().persistHostProperty("SPEAKER0.AudioMode.AUTO", param->autoMode ? "TRUE" : "FALSE");
_srv_AudioSPEAKERAuto = param->autoMode;
break;
default:
break;
}
Expand Down Expand Up @@ -6230,10 +6333,20 @@
}
INT_INFO("The HDMI Audio Mode Setting From Persistent is %s \r\n",_AudioModeSettings.c_str());
}
else if (_APortType == dsAUDIOPORT_TYPE_HDMI_ARC){
_AudioModeSettings = device::HostPersistence::getInstance().getProperty("HDMI_ARC0.AudioMode",_AudioModeSettings);
INT_INFO("The HDMI_ARC Audio Mode Setting From Persistent is %s \r\n",_AudioModeSettings.c_str());
}
else if (_APortType == dsAUDIOPORT_TYPE_HDMI_ARC){
_AudioModeSettings = device::HostPersistence::getInstance().getProperty("HDMI_ARC0.AudioMode",_AudioModeSettings);
INT_INFO("The HDMI_ARC Audio Mode Setting From Persistent is %s \r\n",_AudioModeSettings.c_str());
}
else if(_APortType == dsAUDIOPORT_TYPE_SPEAKER){
try{
_AudioModeSettings = device::HostPersistence::getInstance().getProperty("SPEAKER0.AudioMode",_AudioModeSettings);
}
catch(...){
INT_INFO("SPEAKER0.AudioMode Not in persistent");
_AudioModeSettings = "SURROUND";
}
INT_INFO("The SPEAKER Audio Mode Setting From Persistent is %s \r\n",_AudioModeSettings.c_str());
}

if (_AudioModeSettings.compare("SURROUND") == 0)
{
Expand Down
Loading