RDK Documentation (Open Sourced RDK Components)
dsAudio.c
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 
21 
22 /**
23 * @defgroup devicesettings
24 * @{
25 * @defgroup rpc
26 * @{
27 **/
28 
29 
30 #include "dsAudio.h"
31 
32 #include <sys/types.h>
33 #include <stdint.h>
34 #include <stdlib.h>
35 #include <iostream>
36 #include <string.h>
37 #include <pthread.h>
38 #include <dlfcn.h>
39 #include "dsError.h"
40 #include "dsUtl.h"
41 #include "dsTypes.h"
42 #include "pthread.h"
43 #include "libIARM.h"
44 #include "libIBus.h"
45 #include "iarmUtil.h"
46 #include "dsRpc.h"
47 #include "dsMgr.h"
48 #include "hostPersistence.hpp"
49 #include "dsserverlogger.h"
50 #include "dsAudioSettings.h"
51 
52 #include "safec_lib.h"
53 
54 static int m_isInitialized = 0;
55 static int m_isPlatInitialized = 0;
56 
57 static bool m_MS12DAPV2Enabled = 0;
58 static bool m_MS12DEEnabled = 0;
59 static bool m_LEEnabled = 0;
60 static int m_volumeDuckingLevel = 0;
61 static float m_volumeLevel = 0;
62 static int m_MuteStatus = false;
63 static int m_isDuckingInProgress = false;
64 
65 static pthread_mutex_t dsLock = PTHREAD_MUTEX_INITIALIZER;
66 int _srv_AudioAuto = 0;
67 dsAudioStereoMode_t _srv_HDMI_Audiomode = dsAUDIO_STEREO_STEREO;
68 dsAudioStereoMode_t _srv_SPDIF_Audiomode = dsAUDIO_STEREO_STEREO;
69 dsAudioStereoMode_t _srv_HDMI_ARC_Audiomode = dsAUDIO_STEREO_STEREO;
70 
71 #define IARM_BUS_Lock(lock) pthread_mutex_lock(&dsLock)
72 #define IARM_BUS_Unlock(lock) pthread_mutex_unlock(&dsLock)
73 
74 IARM_Result_t _dsAudioPortInit(void *arg);
75 IARM_Result_t _dsGetAudioPort(void *arg);
76 IARM_Result_t _dsGetSupportedARCTypes(void *arg);
77 IARM_Result_t _dsAudioSetSAD(void *arg);
78 IARM_Result_t _dsAudioEnableARC(void *arg);
79 IARM_Result_t _dsSetStereoMode(void *arg);
80 IARM_Result_t _dsSetStereoAuto(void *arg);
81 IARM_Result_t _dsGetStereoAuto(void *arg);
82 IARM_Result_t _dsSetAudioMute(void *arg);
83 IARM_Result_t _dsIsAudioMute(void *arg);
84 IARM_Result_t _dsAudioPortTerm(void *arg);
85 IARM_Result_t _dsGetStereoMode(void *arg);
86 IARM_Result_t _dsGetAudioFormat(void *arg);
87 IARM_Result_t _dsGetEncoding(void *arg);
88 IARM_Result_t _dsIsAudioMSDecode(void *arg);
89 IARM_Result_t _dsIsAudioMS12Decode(void *arg);
90 IARM_Result_t _dsIsAudioPortEnabled(void *arg);
91 
92 
93 IARM_Result_t _dsGetEnablePersist(void *arg);
94 IARM_Result_t _dsSetEnablePersist(void *arg);
95 
96 IARM_Result_t _dsEnableAudioPort(void *arg);
97 IARM_Result_t _dsSetAudioDucking(void *arg);
98 IARM_Result_t _dsGetAudioLevel(void *arg);
99 IARM_Result_t _dsSetAudioLevel(void *arg);
100 IARM_Result_t _dsGetAudioGain(void *arg);
101 IARM_Result_t _dsSetAudioGain(void *arg);
102 IARM_Result_t _dsEnableLEConfig(void *arg);
103 IARM_Result_t _dsGetLEConfig(void *arg);
104 IARM_Result_t _dsSetAudioDelay(void *arg);
105 IARM_Result_t _dsGetAudioDelay(void *arg);
106 IARM_Result_t _dsSetAudioDelayOffset(void *arg);
107 IARM_Result_t _dsGetAudioDelayOffset(void *arg);
108 IARM_Result_t _dsGetSinkDeviceAtmosCapability(void *arg);
109 IARM_Result_t _dsSetAudioAtmosOutputMode(void *arg);
110 
111 IARM_Result_t _dsSetAudioCompression(void *arg);
112 IARM_Result_t _dsGetAudioCompression(void *arg);
113 IARM_Result_t _dsSetDialogEnhancement(void *arg);
114 IARM_Result_t _dsGetDialogEnhancement(void *arg);
115 IARM_Result_t _dsSetDolbyVolumeMode(void *arg);
116 IARM_Result_t _dsGetDolbyVolumeMode(void *arg);
117 IARM_Result_t _dsSetIntelligentEqualizerMode(void *arg);
118 IARM_Result_t _dsGetIntelligentEqualizerMode(void *arg);
119 IARM_Result_t _dsSetGraphicEqualizerMode(void *arg);
120 IARM_Result_t _dsGetGraphicEqualizerMode(void *arg);
121 
122 IARM_Result_t _dsGetVolumeLeveller(void *arg);
123 IARM_Result_t _dsSetVolumeLeveller(void *arg);
124 IARM_Result_t _dsGetBassEnhancer(void *arg);
125 IARM_Result_t _dsSetBassEnhancer(void *arg);
126 IARM_Result_t _dsIsSurroundDecoderEnabled(void *arg);
127 IARM_Result_t _dsEnableSurroundDecoder(void *arg);
128 IARM_Result_t _dsGetDRCMode(void *arg);
129 IARM_Result_t _dsSetDRCMode(void *arg);
130 IARM_Result_t _dsGetSurroundVirtualizer(void *arg);
131 IARM_Result_t _dsSetSurroundVirtualizer(void *arg);
132 IARM_Result_t _dsGetMISteering(void *arg);
133 IARM_Result_t _dsSetMISteering(void *arg);
134 IARM_Result_t _dsGetMS12AudioProfileList(void *arg);
135 IARM_Result_t _dsGetMS12AudioProfile(void *arg);
136 IARM_Result_t _dsSetMS12AudioProfile(void *arg);
137 
138 IARM_Result_t _dsGetAssociatedAudioMixing(void *arg);
139 IARM_Result_t _dsSetAssociatedAudioMixing(void *arg);
140 IARM_Result_t _dsGetFaderControl(void *arg);
141 IARM_Result_t _dsSetFaderControl(void *arg);
142 IARM_Result_t _dsGetPrimaryLanguage(void *arg);
143 IARM_Result_t _dsSetPrimaryLanguage(void *arg);
144 IARM_Result_t _dsGetSecondaryLanguage(void *arg);
145 IARM_Result_t _dsSetSecondaryLanguage(void *arg);
146 
147 IARM_Result_t _dsGetAudioCapabilities(void *arg);
148 IARM_Result_t _dsGetMS12Capabilities(void *arg);
149 IARM_Result_t _dsAudioOutIsConnected(void *arg);
150 IARM_Result_t _dsResetBassEnhancer(void *arg);
151 IARM_Result_t _dsResetSurroundVirtualizer(void *arg);
152 IARM_Result_t _dsResetVolumeLeveller(void *arg);
153 IARM_Result_t _dsResetDialogEnhancement(void *arg);
154 IARM_Result_t _dsSetMS12SetttingsOverride(void *arg);
155 IARM_Result_t _dsGetHDMIARCPortId(void *arg);
156 
157 static void _GetAudioModeFromPersistent(void *arg);
158 static dsAudioPortType_t _GetAudioPortType(intptr_t handle);
159 void _dsAudioOutPortConnectCB(dsAudioPortType_t portType, unsigned int uiPortNo, bool isPortConnected);
160 static dsError_t _dsAudioOutRegisterConnectCB (dsAudioOutPortConnectCB_t cbFun);
161 void _dsAudioFormatUpdateCB(dsAudioFormat_t audioFormat);
162 static dsError_t _dsAudioFormatUpdateRegisterCB (dsAudioFormatUpdateCB_t cbFun);
163 static std::string _dsGetCurrentProfileProperty(std::string property);
164 static void _dsMS12ProfileSettingOverride(intptr_t handle);
165 static std::string _dsGenerateProfileProperty(std::string profile,std::string property);
166 static bool _dsMs12ProfileSupported(intptr_t handle,std::string profile);
167 static IARM_Result_t _resetDialogEnhancerLevel(intptr_t handle);
168 static IARM_Result_t _resetBassEnhancer(intptr_t handle);
169 static IARM_Result_t _resetVolumeLeveller(intptr_t handle);
170 static IARM_Result_t _resetSurroundVirtualizer(intptr_t handle);
171 static IARM_Result_t _setDialogEnhancement(intptr_t handle, int enhancerLevel);
172 static IARM_Result_t _setBassEnhancer(intptr_t handle ,int boost);
173 static IARM_Result_t _setVolumeLeveller(intptr_t handle, int volLevellerMode, int volLevellerLevel);
174 static IARM_Result_t _setSurroundVirtualizer(intptr_t handle , int virtualizerMode , int virtualizerBoost);
175 
176 void AudioConfigInit()
177 {
178  typedef dsError_t (*dsEnableLEConfig_t)(intptr_t handle, const bool enable);
179  intptr_t handle = 0;
180  void *dllib = NULL;
181  static dsEnableLEConfig_t func = NULL;
182  if (dsGetAudioPort(dsAUDIOPORT_TYPE_HDMI,0,&handle) == dsERR_NONE) {
183  if (func == NULL) {
184  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
185  if (dllib) {
186  func = (dsEnableLEConfig_t) dlsym(dllib, "dsEnableLEConfig");
187  if (func) {
188  __TIMESTAMP();printf("dsEnableLEConfig(int, bool) is defined and loaded\r\n");
189  std::string _LEEnable("FALSE");
190  try
191  {
192  _LEEnable = device::HostPersistence::getInstance().getProperty("audio.LEEnable");
193  }
194  catch(...)
195  {
196 #ifndef DS_LE_DEFAULT_DISABLED
197  _LEEnable = "TRUE";
198 #endif
199  __TIMESTAMP();printf("LE : Persisting default LE status: %s \r\n",_LEEnable.c_str());
200  device::HostPersistence::getInstance().persistHostProperty("audio.LEEnable",_LEEnable);
201  }
202  if(_LEEnable == "TRUE")
203  {
204  m_LEEnabled = 1;
205  func(handle,m_LEEnabled);
206  }
207  else
208  {
209  m_LEEnabled = 0;
210  func(handle,m_LEEnabled);
211  }
212  }
213  else {
214  __TIMESTAMP();printf("dsEnableLEConfig(int, bool) is not defined\r\n");
215  }
216  dlclose(dllib);
217  }
218  else {
219  __TIMESTAMP();printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
220  }
221  }
222  }
223  else {
224  __TIMESTAMP();printf("dsEnableLEConfig(int, bool) is failed. since dsAUDIOPORT_TYPE_HDMI 0 port not available\r\n");
225  }
226 
227 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
228  typedef dsError_t (*dsSetAudioGain_t)(intptr_t handle, float gain);
229  static dsSetAudioGain_t dsSetAudioGainFunc = 0;
230  if (dsSetAudioGainFunc == 0) {
231  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
232  if (dllib) {
233  dsSetAudioGainFunc = (dsSetAudioGain_t) dlsym(dllib, "dsSetAudioGain");
234  if (dsSetAudioGainFunc) {
235  printf("dsSetAudioGain_t(int, float ) is defined and loaded\r\n");
236  std::string _AudioGain("0");
237  float m_audioGain = 0;
238 //SPEAKER init
239  handle = 0;
241  try {
242  _AudioGain = device::HostPersistence::getInstance().getProperty("SPEAKER0.audio.Gain");
243  }
244  catch(...) {
245  try {
246  printf("SPEAKER0.audio.Gain not found in persistence store. Try system default\n");
247  _AudioGain = device::HostPersistence::getInstance().getDefaultProperty("SPEAKER0.audio.Gain");
248  }
249  catch(...) {
250  _AudioGain = "0";
251  }
252  }
253  m_audioGain = atof(_AudioGain.c_str());
254  if (dsSetAudioGainFunc(handle, m_audioGain) == dsERR_NONE) {
255  printf("Port %s: Initialized audio gain : %f\n","SPEAKER0", m_audioGain);
256  }
257  }
258 //HDMI init
259  handle = 0;
260  if (dsGetAudioPort(dsAUDIOPORT_TYPE_HDMI,0,&handle) == dsERR_NONE) {
261  try {
262  _AudioGain = device::HostPersistence::getInstance().getProperty("HDMI0.audio.Gain");
263  }
264  catch(...) {
265  try {
266  printf("HDMI0.audio.Gain not found in persistence store. Try system default\n");
267  _AudioGain = device::HostPersistence::getInstance().getDefaultProperty("HDMI0.audio.Gain");
268  }
269  catch(...) {
270  _AudioGain = "0";
271  }
272  }
273  m_audioGain = atof(_AudioGain.c_str());
274  if (dsSetAudioGainFunc(handle, m_audioGain) == dsERR_NONE) {
275  printf("Port %s: Initialized audio gain : %f\n","HDMI0", m_audioGain);
276  }
277  }
278 
279  }
280  else {
281  printf("dsSetAudioGain_t(int, float ) is not defined\r\n");
282  }
283  dlclose(dllib);
284  }
285  else {
286  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
287  }
288  }
289 
290 
291  typedef dsError_t (*dsSetAudioLevel_t)(intptr_t handle, float level);
292  static dsSetAudioLevel_t dsSetAudioLevelFunc = 0;
293  if (dsSetAudioLevelFunc == 0) {
294  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
295  if (dllib) {
296  dsSetAudioLevelFunc = (dsSetAudioLevel_t) dlsym(dllib, "dsSetAudioLevel");
297  if (dsSetAudioGainFunc) {
298  printf("dsSetAudioLevel_t(int, float ) is defined and loaded\r\n");
299  std::string _AudioLevel("0");
300  float m_audioLevel = 0;
301 //SPEAKER init
302  handle = 0;
304  try {
305  _AudioLevel = device::HostPersistence::getInstance().getProperty("SPEAKER0.audio.Level");
306  }
307  catch(...) {
308  try {
309  printf("SPEAKER0.audio.Level not found in persistence store. Try system default\n");
310  _AudioLevel = device::HostPersistence::getInstance().getDefaultProperty("SPEAKER0.audio.Level");
311  }
312  catch(...) {
313  _AudioLevel = "40";
314  }
315  }
316  m_audioLevel = atof(_AudioLevel.c_str());
317  if (dsSetAudioLevelFunc(handle, m_audioLevel) == dsERR_NONE) {
318  m_volumeLevel = m_audioLevel;
319  printf("Port %s: Initialized audio level : %f\n","SPEAKER0", m_audioLevel);
320  }
321  }
322 //HEADPHONE init
323  handle = 0;
325  try {
326  _AudioLevel = device::HostPersistence::getInstance().getProperty("HEADPHONE0.audio.Level");
327  }
328  catch(...) {
329  try {
330  printf("HEADPHONE0.audio.Level not found in persistence store. Try system default\n");
331  _AudioLevel = device::HostPersistence::getInstance().getDefaultProperty("HEADPHONE0.audio.Level");
332  }
333  catch(...) {
334  _AudioLevel = "40";
335  }
336  }
337  m_audioLevel = atof(_AudioLevel.c_str());
338  if (dsSetAudioLevelFunc(handle, m_audioLevel) == dsERR_NONE) {
339  printf("Port %s: Initialized audio level : %f\n","HEADPHONE0", m_audioLevel);
340  }
341  }
342 //HDMI init
343  handle = 0;
345  try {
346  _AudioLevel = device::HostPersistence::getInstance().getProperty("HDMI0.audio.Level");
347  }
348  catch(...) {
349  try {
350  printf("HDMI0.audio.Level not found in persistence store. Try system default\n");
351  _AudioLevel = device::HostPersistence::getInstance().getDefaultProperty("HDMI0.audio.Level");
352  }
353  catch(...) {
354  _AudioLevel = "40";
355  }
356  }
357  m_audioLevel = atof(_AudioLevel.c_str());
358  if (dsSetAudioLevelFunc(handle, m_audioLevel) == dsERR_NONE) {
359  printf("Port %s: Initialized audio level : %f\n","HDMI0", m_audioLevel);
360  m_volumeLevel = m_audioLevel;
361  }
362  }
363  }
364  else {
365  printf("dsSetAudioLevel_t(int, float ) is not defined\r\n");
366  }
367  dlclose(dllib);
368  }
369  else {
370  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
371  }
372  }
373 
374 
375  typedef dsError_t (*dsSetAudioDelay_t)(intptr_t handle, uint32_t audioDelayMs);
376  static dsSetAudioDelay_t dsSetAudioDelayFunc = 0;
377  if (dsSetAudioDelayFunc == 0) {
378  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
379  if (dllib) {
380  dsSetAudioDelayFunc = (dsSetAudioDelay_t) dlsym(dllib, "dsSetAudioDelay");
381  if (dsSetAudioDelayFunc) {
382  printf("dsSetAudioDelay_t(int, uint32_t) is defined and loaded\r\n");
383  std::string _AudioDelay("0");
384  int m_audioDelay = 0;
385 //SPEAKER init
386  handle = 0;
388  try {
389  _AudioDelay = device::HostPersistence::getInstance().getProperty("SPEAKER0.audio.Delay");
390  }
391  catch(...) {
392  try {
393  printf("SPEAKER0.audio.Delay not found in persistence store. Try system default\n");
394  _AudioDelay = device::HostPersistence::getInstance().getDefaultProperty("SPEAKER0.audio.Delay");
395  }
396  catch(...) {
397  _AudioDelay = "0";
398  }
399  }
400  m_audioDelay = atoi(_AudioDelay.c_str());
401  if (dsSetAudioDelayFunc(handle, m_audioDelay) == dsERR_NONE) {
402  printf("Port %s: Initialized audio delay : %d\n","SPEAKER0", m_audioDelay);
403  }
404  }
405 //HDMI init
406  handle = 0;
408  try {
409  _AudioDelay = device::HostPersistence::getInstance().getProperty("HDMI0.audio.Delay");
410  }
411  catch(...) {
412  try {
413  printf("HDMI0.audio.Delay not found in persistence store. Try system default\n");
414  _AudioDelay = device::HostPersistence::getInstance().getDefaultProperty("HDMI0.audio.Delay");
415  }
416  catch(...) {
417  _AudioDelay = "0";
418  }
419  }
420  m_audioDelay = atoi(_AudioDelay.c_str());
421  if (dsSetAudioDelayFunc(handle, m_audioDelay) == dsERR_NONE) {
422  printf("Port %s: Initialized audio delay : %d\n","HDMI0", m_audioDelay);
423  }
424  }
425 //HDMI ARC init
426  handle = 0;
427  if(dsGetAudioPort(dsAUDIOPORT_TYPE_HDMI_ARC,0,&handle) == dsERR_NONE) {
428  try {
429  _AudioDelay = device::HostPersistence::getInstance().getProperty("HDMI_ARC0.audio.Delay");
430  }
431  catch(...) {
432  try {
433  printf("HDMI_ARC0.audio.Delay not found in persistence store. Try system default\n");
434  _AudioDelay = device::HostPersistence::getInstance().getDefaultProperty("HDMI_ARC0.audio.Delay");
435  }
436  catch(...) {
437  _AudioDelay = "0";
438  }
439  }
440  m_audioDelay = atoi(_AudioDelay.c_str());
441  if (dsSetAudioDelayFunc(handle, m_audioDelay) == dsERR_NONE) {
442  printf("Port %s: Initialized audio delay : %d\n","HDMI_ARC0", m_audioDelay);
443  }
444  }
445 
446 
447  }
448  else {
449  printf("dsSetAudioDelay_t(int, uint32_t) is not defined\r\n");
450  }
451  dlclose(dllib);
452  }
453  else {
454  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
455  }
456  }
457 
458 
459  typedef dsError_t (*dsSetAudioDelayOffset_t)(intptr_t handle, uint32_t audioDelayOffsetMs);
460  static dsSetAudioDelayOffset_t dsSetAudioDelayOffsetFunc = 0;
461  if (dsSetAudioDelayOffsetFunc == 0) {
462  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
463  if (dllib) {
464  dsSetAudioDelayOffsetFunc = (dsSetAudioDelayOffset_t) dlsym(dllib, "dsSetAudioDelayOffset");
465  if (dsSetAudioDelayOffsetFunc) {
466  printf("dsSetAudioDelayOffset_t(int, uint32_t) is defined and loaded\r\n");
467  std::string _AudioDelayOffset("0");
468  int m_audioDelayOffset = 0;
469 //SPEAKER init
470  handle = 0;
472  try {
473  _AudioDelayOffset = device::HostPersistence::getInstance().getProperty("SPEAKER0.audio.DelayOffset");
474  }
475  catch(...) {
476  try {
477  printf("SPEAKER0.audio.DelayOffset not found in persistence store. Try system default\n");
478  _AudioDelayOffset = device::HostPersistence::getInstance().getDefaultProperty("SPEAKER0.audio.DelayOffset");
479  }
480  catch(...) {
481  _AudioDelayOffset = "0";
482  }
483  }
484  m_audioDelayOffset = atoi(_AudioDelayOffset.c_str());
485  if (dsSetAudioDelayOffsetFunc(handle, m_audioDelayOffset) == dsERR_NONE) {
486  printf("Port %s: Initialized audio delay offset : %d\n","SPEAKER0", m_audioDelayOffset);
487  }
488  }
489 //HDMI init
490  handle = 0;
492  try {
493  _AudioDelayOffset = device::HostPersistence::getInstance().getProperty("HDMI0.audio.DelayOffset");
494  }
495  catch(...) {
496  try {
497  printf("HDMI0.audio.DelayOffset not found in persistence store. Try system default\n");
498  _AudioDelayOffset = device::HostPersistence::getInstance().getDefaultProperty("HDMI0.audio.DelayOffset");
499  }
500  catch(...) {
501  _AudioDelayOffset = "0";
502  }
503  }
504  m_audioDelayOffset = atoi(_AudioDelayOffset.c_str());
505  if (dsSetAudioDelayOffsetFunc(handle, m_audioDelayOffset) == dsERR_NONE) {
506  printf("Port %s: Initialized audio delay offset : %d\n","HDMI0", m_audioDelayOffset);
507  }
508  }
509 //HDMI ARC init
510  handle = 0;
511  if(dsGetAudioPort(dsAUDIOPORT_TYPE_HDMI_ARC,0,&handle) == dsERR_NONE) {
512  try {
513  _AudioDelayOffset = device::HostPersistence::getInstance().getProperty("HDMI_ARC0.audio.DelayOffset");
514  }
515  catch(...) {
516  try {
517  printf("HDMI_ARC0.audio.DelayOffset not found in persistence store. Try system default\n");
518  _AudioDelayOffset = device::HostPersistence::getInstance().getDefaultProperty("HDMI_ARC0.audio.DelayOffset");
519  }
520  catch(...) {
521  _AudioDelayOffset = "0";
522  }
523  }
524  m_audioDelayOffset = atoi(_AudioDelayOffset.c_str());
525  if (dsSetAudioDelayOffsetFunc(handle, m_audioDelayOffset) == dsERR_NONE) {
526  printf("Port %s: Initialized audio delay offset : %d\n","HDMI_ARC0", m_audioDelayOffset);
527  }
528  }
529  }
530  else {
531  printf("dsSetAudioDelayOffset_t(int, uint32_t) is not defined\r\n");
532  }
533  dlclose(dllib);
534  }
535  else {
536  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
537  }
538  }
539 
540 
541  typedef dsError_t (*dsSetPrimaryLanguage_t)(intptr_t handle, const char* pLang);;
542  static dsSetPrimaryLanguage_t dsSetPrimaryLanguageFunc = 0;
543  if (dsSetPrimaryLanguageFunc == 0) {
544  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
545  if (dllib) {
546  dsSetPrimaryLanguageFunc = (dsSetPrimaryLanguage_t) dlsym(dllib, "dsSetPrimaryLanguage");
547  if (dsSetPrimaryLanguageFunc) {
548  printf("dsSetPrimaryLanguage_t(int, char* ) is defined and loaded\r\n");
549  std::string _PrimaryLanguage("eng");
550  handle = 0;
551  try {
552  _PrimaryLanguage = device::HostPersistence::getInstance().getProperty("audio.PrimaryLanguage");
553  }
554  catch(...) {
555  try {
556  printf("audio.PrimaryLanguage not found in persistence store. Try system default\n");
557  _PrimaryLanguage = device::HostPersistence::getInstance().getDefaultProperty("audio.PrimaryLanguage");
558  }
559  catch(...) {
560  _PrimaryLanguage = "eng";
561  }
562  }
563  if (dsSetPrimaryLanguageFunc(handle, _PrimaryLanguage.c_str()) == dsERR_NONE) {
564  printf("Initialized Primary Language : %s\n", _PrimaryLanguage.c_str());
565  }
566  }
567  else {
568  printf("dsSetPrimaryLanguage_t(int, char* ) is not defined\r\n");
569  }
570  dlclose(dllib);
571  }
572  else {
573  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
574  }
575  }
576 
577 
578  typedef dsError_t (*dsSetSecondaryLanguage_t)(intptr_t handle, const char* sLang);;
579  static dsSetSecondaryLanguage_t dsSetSecondaryLanguageFunc = 0;
580  if (dsSetSecondaryLanguageFunc == 0) {
581  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
582  if (dllib) {
583  dsSetSecondaryLanguageFunc = (dsSetSecondaryLanguage_t) dlsym(dllib, "dsSetSecondaryLanguage");
584  if (dsSetSecondaryLanguageFunc) {
585  printf("dsSetSecondaryLanguage_t(int, char* ) is defined and loaded\r\n");
586  std::string _SecondaryLanguage("eng");
587  handle = 0;
588  try {
589  _SecondaryLanguage = device::HostPersistence::getInstance().getProperty("audio.SecondaryLanguage");
590  }
591  catch(...) {
592  try {
593  printf("audio.SecondaryLanguage not found in persistence store. Try system default\n");
594  _SecondaryLanguage = device::HostPersistence::getInstance().getDefaultProperty("audio.SecondaryLanguage");
595  }
596  catch(...) {
597  _SecondaryLanguage = "eng";
598  }
599  }
600  if (dsSetSecondaryLanguageFunc(handle, _SecondaryLanguage.c_str()) == dsERR_NONE) {
601  printf("Initialized Secondary Language : %s\n", _SecondaryLanguage.c_str());
602  }
603  }
604  else {
605  printf("dsSetSecondaryLanguage_t(int, char* ) is not defined\r\n");
606  }
607  dlclose(dllib);
608  }
609  else {
610  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
611  }
612  }
613 
614 
615  typedef dsError_t (*dsSetFaderControl_t)(intptr_t handle, int mixerbalance);
616  static dsSetFaderControl_t dsSetFaderControlFunc = 0;
617  if (dsSetFaderControlFunc == 0) {
618  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
619  if (dllib) {
620  dsSetFaderControlFunc = (dsSetFaderControl_t) dlsym(dllib, "dsSetFaderControl");
621  if (dsSetFaderControlFunc) {
622  printf("dsSetFaderControl_t(int, int) is defined and loaded\r\n");
623  std::string _FaderControl("0");
624  int m_faderControl = 0;
625 
626  handle = 0;
627  try {
628  _FaderControl = device::HostPersistence::getInstance().getProperty("audio.FaderControl");
629  }
630  catch(...) {
631  try {
632  printf("audio.FaderControl not found in persistence store. Try system default\n");
633  _FaderControl = device::HostPersistence::getInstance().getDefaultProperty("audio.FaderControl");
634  }
635  catch(...) {
636  _FaderControl = "0";
637  }
638  }
639  m_faderControl = atoi(_FaderControl.c_str());
640  if (dsSetFaderControlFunc(handle, m_faderControl) == dsERR_NONE) {
641  printf("Initialized Fader Control, mixing : %d\n", m_faderControl);
642  }
643 
644  }
645  else {
646  printf("dsSetFaderControl_t(int, int) is not defined\r\n");
647  }
648  dlclose(dllib);
649  }
650  else {
651  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
652  }
653  }
654 
655 
656  typedef dsError_t (*dsSetAssociatedAudioMixing_t)(intptr_t handle, bool mixing);
657  static dsSetAssociatedAudioMixing_t dsSetAssociatedAudioMixingFunc = 0;
658  if (dsSetAssociatedAudioMixingFunc == 0) {
659  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
660  if (dllib) {
661  dsSetAssociatedAudioMixingFunc = (dsSetAssociatedAudioMixing_t) dlsym(dllib, "dsSetAssociatedAudioMixing");
662  if (dsSetAssociatedAudioMixingFunc) {
663  printf("dsSetAssociatedAudioMixing_t (intptr_t handle, bool mixing ) is defined and loaded\r\n");
664  std::string _AssociatedAudioMixing("Disabled");
665  bool m_AssociatedAudioMixing = false;
666  try {
667  _AssociatedAudioMixing = device::HostPersistence::getInstance().getProperty("audio.AssociatedAudioMixing");
668  }
669  catch(...) {
670  try {
671  printf("audio.AssociatedAudioMixing not found in persistence store. Try system default\n");
672  _AssociatedAudioMixing = device::HostPersistence::getInstance().getDefaultProperty("audio.AssociatedAudioMixing");
673  }
674  catch(...) {
675  _AssociatedAudioMixing = "Disabled";
676  }
677  }
678  if (_AssociatedAudioMixing == "Enabled") {
679  m_AssociatedAudioMixing = true;
680  }
681  else {
682  m_AssociatedAudioMixing = false;
683  }
684  handle = 0;
685  if (dsSetAssociatedAudioMixingFunc(handle, m_AssociatedAudioMixing) == dsERR_NONE) {
686  printf("Initialized AssociatedAudioMixingFunc : %d\n", m_AssociatedAudioMixing);
687  }
688  }
689  else {
690  printf("dsSetAssociatedAudioMixing_t (intptr_t handle, bool enable) is not defined\r\n");
691  }
692  dlclose(dllib);
693  }
694  else {
695  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
696  }
697  }
698 
699  std::string _AProfileSupport("FALSE");
700  std::string _AProfile("Off");
701  try {
702  _AProfileSupport = device::HostPersistence::getInstance().getDefaultProperty("audio.MS12Profile.supported");
703  }
704  catch(...) {
705  _AProfileSupport = "FALSE";
706  printf("audio.MS12Profile.supported setting not found in hostDataDeafult \r\n");
707  }
708  printf(" audio.MS12Profile.supported = %s ..... \r\n",_AProfileSupport.c_str());
709 
710 
711  if(_AProfileSupport == "TRUE") {
712  typedef dsError_t (*dsSetMS12AudioProfile_t)(intptr_t handle, const char* profile);
713  static dsSetMS12AudioProfile_t dsSetMS12AudioProfileFunc = 0;
714  if (dsSetMS12AudioProfileFunc == 0) {
715  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
716  if (dllib) {
717  dsSetMS12AudioProfileFunc = (dsSetMS12AudioProfile_t) dlsym(dllib, "dsSetMS12AudioProfile");
718  if (dsSetMS12AudioProfileFunc) {
719  printf("dsSetMS12AudioProfile_t(int, const char*) is defined and loaded\r\n");
720  handle = 0;
722 
723  try {
724  _AProfile = device::HostPersistence::getInstance().getProperty("audio.MS12Profile");
725  }
726  catch(...) {
727  try {
728  printf("audio.MS12Profile not found in persistence store. Try system default\n");
729  _AProfile = device::HostPersistence::getInstance().getDefaultProperty("audio.MS12Profile");
730  }
731  catch(...) {
732  _AProfile = "Off";
733  }
734  }
735  //SPEAKER init
736  handle = 0;
738  if (dsSetMS12AudioProfileFunc(handle, _AProfile.c_str()) == dsERR_NONE) {
739  printf("Port %s: Initialized MS12 Audio Profile : %s\n","SPEAKER0", _AProfile.c_str());
740  device::HostPersistence::getInstance().persistHostProperty("audio.MS12Profile",_AProfile.c_str());
741  }
742  else {
743  printf("Port %s: Initialization failed !!! MS12 Audio Profile : %s\n","SPEAKER0", _AProfile.c_str());
744  }
745  }
746  #if 0 // No Audio Profile support for STB devices
747  //HDMI init
748  handle = 0;
750  if (dsSetMS12AudioProfileFunc(handle, _AProfile.c_str()) == dsERR_NONE) {
751  printf("Port %s: Initialized MS12 Audio Profile : %d\n","HDMI0", _AProfile.c_str());
752  }
753  }
754  #endif
755  }
756  else {
757  printf("dsSetMS12AudioProfile_t(int, const char*) is not defined\r\n");
758  }
759  dlclose(dllib);
760  }
761  else {
762  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
763  }
764  }
765  }
766 //All MS12 Settings can be initialised through MS12 audio profiles
767 //User setting persistence override available for any individual setting on top of profiles
768 //All MS12 settings can be turned off (DAP Off Mode) by configuring Audio Profile to Off
769  if((_AProfileSupport == "TRUE") && (_AProfile != "Off")) {
770  std::string _profileOverride = "FALSE";
771  try {
772  _profileOverride = device::HostPersistence::getInstance().getDefaultProperty("audio.Compression.ms12ProfileOverride");
773  }
774  catch(...) {
775  _profileOverride = "FALSE";
776  printf(" audio.Compression.ms12ProfileOverride settings not found in system default ..... \r\n");
777  }
778  printf(" audio.Compression.ms12ProfileOverride = %s ..... \r\n",_profileOverride.c_str());
779 
780  if(_profileOverride == "TRUE") {
781  typedef dsError_t (*dsSetAudioCompression_t)(intptr_t handle, int compressionLevel);
782  static dsSetAudioCompression_t dsSetAudioCompressionFunc = 0;
783  if (dsSetAudioCompressionFunc == 0) {
784  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
785  if (dllib) {
786  dsSetAudioCompressionFunc = (dsSetAudioCompression_t) dlsym(dllib, "dsSetAudioCompression");
787  if (dsSetAudioCompressionFunc) {
788  printf("dsSetAudioCompression_t(int, int ) is defined and loaded\r\n");
789  std::string _AudioCompression("0");
790  int m_audioCompression = 0;
791  try {
792  _AudioCompression = device::HostPersistence::getInstance().getProperty("audio.Compression");
793  m_audioCompression = atoi(_AudioCompression.c_str());
794  //SPEAKER init
795  handle = 0;
797  if (dsSetAudioCompressionFunc(handle, m_audioCompression) == dsERR_NONE) {
798  printf("Port %s: Initialized audio compression : %d\n","SPEAKER0", m_audioCompression);
799  }
800  }
801  //HDMI init
802  handle = 0;
804  if (dsSetAudioCompressionFunc(handle, m_audioCompression) == dsERR_NONE) {
805  printf("Port %s: Initialized audio compression : %d\n","HDMI0", m_audioCompression);
806  }
807  }
808 
809  }
810  catch(...) {
811  printf("audio.Compression not found in persistence store. System Default configured through profiles\n");
812  }
813  }
814  else {
815  printf("dsSetAudioCompression_t(int, int) is not defined\r\n");
816  }
817  dlclose(dllib);
818  }
819  else {
820  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
821  }
822  }
823  }
824 
825  _profileOverride = "FALSE";
826  try {
827  _profileOverride = device::HostPersistence::getInstance().getDefaultProperty("audio.DialogEnhancer.ms12ProfileOverride");
828  }
829  catch(...) {
830  _profileOverride = "FALSE";
831  printf(" audio.DialogEnhancer.ms12ProfileOverride settings not found in system default ..... \r\n");
832  }
833  printf(" audio.DialogEnhancer.ms12ProfileOverride = %s ..... \r\n",_profileOverride.c_str());
834 
835  if(_profileOverride == "TRUE") {
836  typedef dsError_t (*dsSetDialogEnhancement_t)(intptr_t handle, int enhancerLevel);
837  static dsSetDialogEnhancement_t dsSetDialogEnhancementFunc = 0;
838  if (dsSetDialogEnhancementFunc == 0) {
839  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
840  if (dllib) {
841  dsSetDialogEnhancementFunc = (dsSetDialogEnhancement_t) dlsym(dllib, "dsSetDialogEnhancement");
842  if (dsSetDialogEnhancementFunc) {
843  printf("dsSetDialogEnhancement_t(int, int) is defined and loaded\r\n");
844  std::string _EnhancerLevel("0");
845  int m_enhancerLevel = 0;
846  std::string _Property = _dsGetCurrentProfileProperty("EnhancerLevel");
847  try {
848  _EnhancerLevel = device::HostPersistence::getInstance().getProperty(_Property);
849  m_enhancerLevel = atoi(_EnhancerLevel.c_str());
850  //SPEAKER init
851  handle = 0;
853  if (dsSetDialogEnhancementFunc(handle, m_enhancerLevel) == dsERR_NONE) {
854  printf("Port %s: Initialized dialog enhancement level : %d\n","SPEAKER0", m_enhancerLevel);
855  }
856  }
857  //HDMI init
858  handle = 0;
860  if (dsSetDialogEnhancementFunc(handle, m_enhancerLevel) == dsERR_NONE) {
861  printf("Port %s: Initialized dialog enhancement level : %d\n","HDMI0", m_enhancerLevel);
862  }
863  }
864  }
865  catch(...) {
866  printf("audio.EnhancerLevel not found in persistence store. System Default configured through profiles\n");
867  }
868  }
869  else {
870  printf("dsSetDialogEnhancement_t(int, int ) is not defined\r\n");
871  }
872  dlclose(dllib);
873  }
874  else {
875  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
876  }
877  }
878  }
879 
880  _profileOverride = "FALSE";
881  try {
882  _profileOverride = device::HostPersistence::getInstance().getDefaultProperty("audio.DolbyVolumeMode.ms12ProfileOverride");
883  }
884  catch(...) {
885  _profileOverride = "FALSE";
886  printf(" audio.DolbyVolumeMode.ms12ProfileOverride settings not found in system default ..... \r\n");
887  }
888  printf(" audio.DolbyVolumeMode.ms12ProfileOverride = %s ..... \r\n",_profileOverride.c_str());
889 
890  if(_profileOverride == "TRUE") {
891  typedef dsError_t (*dsSetDolbyVolumeMode_t)(intptr_t handle, bool enable);
892  static dsSetDolbyVolumeMode_t dsSetDolbyVolumeModeFunc = 0;
893  if (dsSetDolbyVolumeModeFunc == 0) {
894  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
895  if (dllib) {
896  dsSetDolbyVolumeModeFunc = (dsSetDolbyVolumeMode_t) dlsym(dllib, "dsSetDolbyVolumeMode");
897  if (dsSetDolbyVolumeModeFunc) {
898  printf("dsSetDolbyVolumeMode_t(int, bool) is defined and loaded\r\n");
899  std::string _DolbyVolumeMode("FALSE");
900  bool m_dolbyVolumeMode = false;
901  try {
902  _DolbyVolumeMode = device::HostPersistence::getInstance().getProperty("audio.DolbyVolumeMode");
903  if (_DolbyVolumeMode == "TRUE") {
904  m_dolbyVolumeMode = true;
905  }
906  else {
907  m_dolbyVolumeMode = false;
908  }
909  //SPEAKER init
910  handle = 0;
912  if (dsSetDolbyVolumeModeFunc(handle, m_dolbyVolumeMode) == dsERR_NONE) {
913  printf("Port %s: Initialized Dolby Volume Mode : %d\n","SPEAKER0", m_dolbyVolumeMode);
914  }
915  }
916  //HDMI init
917  handle = 0;
919  if (dsSetDolbyVolumeModeFunc(handle, m_dolbyVolumeMode) == dsERR_NONE) {
920  printf("Port %s: Initialized Dolby Volume Mode : %d\n","HDMI0", m_dolbyVolumeMode);
921  }
922  }
923  }
924  catch(...) {
925  printf("audio.DolbyVolumeMode not found in persistence store. System Default configured through profiles\n");
926  }
927  }
928  else {
929  printf("dsSetDolbyVolumeMode_t(int, bool) is not defined\r\n");
930  }
931  dlclose(dllib);
932  }
933  else {
934  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
935  }
936  }
937  }
938 
939  _profileOverride = "FALSE";
940  try {
941  _profileOverride = device::HostPersistence::getInstance().getDefaultProperty("audio.IntelligentEQ.ms12ProfileOverride");
942  }
943  catch(...) {
944  _profileOverride = "FALSE";
945  printf(" audio.IntelligentEQ.ms12ProfileOverride settings not found in system default ..... \r\n");
946  }
947  printf(" audio.IntelligentEQ.ms12ProfileOverride = %s ..... \r\n",_profileOverride.c_str());
948 
949  if(_profileOverride == "TRUE") {
950  typedef dsError_t (*dsSetIntelligentEqualizerMode_t)(intptr_t handle, int mode);
951  static dsSetIntelligentEqualizerMode_t dsSetIntelligentEqualizerModeFunc = 0;
952  if (dsSetIntelligentEqualizerModeFunc == 0) {
953  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
954  if (dllib) {
955  dsSetIntelligentEqualizerModeFunc = (dsSetIntelligentEqualizerMode_t) dlsym(dllib, "dsSetIntelligentEqualizerMode");
956  if (dsSetIntelligentEqualizerModeFunc) {
957  printf("dsSetIntelligentEqualizerMode_t(int, int) is defined and loaded\r\n");
958  std::string _IEQMode("0");
959  int m_IEQMode = 0;
960  handle = 0;
962  try {
963  _IEQMode = device::HostPersistence::getInstance().getProperty("audio.IntelligentEQ");
964  m_IEQMode = atoi(_IEQMode.c_str());
965  //SPEAKER init
966  handle = 0;
968  if (dsSetIntelligentEqualizerModeFunc(handle, m_IEQMode) == dsERR_NONE) {
969  printf("Port %s: Initialized Intelligent Equalizer mode : %d\n","SPEAKER0", m_IEQMode);
970  }
971  }
972  //HDMI init
973  handle = 0;
975  if (dsSetIntelligentEqualizerModeFunc(handle, m_IEQMode) == dsERR_NONE) {
976  printf("Port %s: Initialized Intelligent Equalizer mode : %d\n","HDMI0", m_IEQMode);
977  }
978  }
979  }
980  catch(...) {
981  printf("audio.IntelligentEQ not found in persistence store. System Default configured through profiles\n");
982  }
983  }
984  else {
985  printf("dsSetIntelligentEqualizerMode_t(int, int) is not defined\r\n");
986  }
987  dlclose(dllib);
988  }
989  else {
990  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
991  }
992  }
993  }
994 
995  _profileOverride = "FALSE";
996  try {
997  _profileOverride = device::HostPersistence::getInstance().getDefaultProperty("audio.VolumeLeveller.ms12ProfileOverride");
998  }
999  catch(...) {
1000  _profileOverride = "FALSE";
1001  printf(" audio.VolumeLeveller.ms12ProfileOverride settings not found in system default ..... \r\n");
1002  }
1003  printf(" audio.VolumeLeveller.ms12ProfileOverride = %s ..... \r\n",_profileOverride.c_str());
1004 
1005  if(_profileOverride == "TRUE") {
1006  typedef dsError_t (*dsSetVolumeLeveller_t)(intptr_t handle, dsVolumeLeveller_t volLeveller);
1007  static dsSetVolumeLeveller_t dsSetVolumeLevellerFunc = 0;
1008  if (dsSetVolumeLevellerFunc == 0) {
1009  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
1010  if (dllib) {
1011  dsSetVolumeLevellerFunc = (dsSetVolumeLeveller_t) dlsym(dllib, "dsSetVolumeLeveller");
1012  if (dsSetVolumeLevellerFunc) {
1013  printf("dsSetVolumeLeveller_t(int, dsVolumeLeveller_t) is defined and loaded\r\n");
1014  std::string _volLevellerMode("0");
1015  std::string _volLevellerLevel("0");
1016  dsVolumeLeveller_t m_volumeLeveller;
1017  std::string _PropertyMode = _dsGetCurrentProfileProperty("VolumeLeveller.mode");
1018  std::string _Propertylevel = _dsGetCurrentProfileProperty("VolumeLeveller.level");
1019  try {
1020  _volLevellerMode = device::HostPersistence::getInstance().getProperty(_PropertyMode);
1021  _volLevellerLevel = device::HostPersistence::getInstance().getProperty(_Propertylevel);
1022  m_volumeLeveller.mode = atoi(_volLevellerMode.c_str());
1023  m_volumeLeveller.level = atoi(_volLevellerLevel.c_str());
1024  //SPEAKER init
1025  handle = 0;
1027  if (dsSetVolumeLevellerFunc(handle, m_volumeLeveller) == dsERR_NONE) {
1028  printf("Port %s: Initialized Volume Leveller : Mode: %d, Level: %d\n","SPEAKER0", m_volumeLeveller.mode, m_volumeLeveller.level);
1029  }
1030  }
1031  //HDMI init
1032  handle = 0;
1033  if(dsGetAudioPort(dsAUDIOPORT_TYPE_HDMI,0,&handle) == dsERR_NONE) {
1034  if (dsSetVolumeLevellerFunc(handle, m_volumeLeveller) == dsERR_NONE) {
1035  printf("Port %s: Initialized Volume Leveller : Mode: %d, Level: %d\n","HDMI0", m_volumeLeveller.mode, m_volumeLeveller.level);
1036  }
1037  }
1038  }
1039  catch(...) {
1040  printf("audio.VolumeLeveller not found in persistence store. System Default configured through profiles\n");
1041  }
1042  }
1043  else {
1044  printf("dsSetVolumeLeveller_t(int, dsVolumeLeveller_t) is not defined\r\n");
1045  }
1046  dlclose(dllib);
1047  }
1048  else {
1049  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
1050  }
1051  }
1052  }
1053 
1054  _profileOverride = "FALSE";
1055  try {
1056  _profileOverride = device::HostPersistence::getInstance().getDefaultProperty("audio.BassBoost.ms12ProfileOverride");
1057  }
1058  catch(...) {
1059  _profileOverride = "FALSE";
1060  printf(" audio.BassBoost.ms12ProfileOverride settings not found in system default ..... \r\n");
1061  }
1062  printf(" audio.BassBoost.ms12ProfileOverride = %s ..... \r\n",_profileOverride.c_str());
1063 
1064  if(_profileOverride == "TRUE") {
1065  typedef dsError_t (*dsSetBassEnhancer_t)(intptr_t handle, int boost);
1066  static dsSetBassEnhancer_t dsSetBassEnhancerFunc = 0;
1067  if (dsSetBassEnhancerFunc == 0) {
1068  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
1069  if (dllib) {
1070  dsSetBassEnhancerFunc = (dsSetBassEnhancer_t) dlsym(dllib, "dsSetBassEnhancer");
1071  if (dsSetBassEnhancerFunc) {
1072  printf("dsSetBassEnhancer_t(int, int) is defined and loaded\r\n");
1073  std::string _BassBoost("0");
1074  int m_bassBoost = 0;
1075  try {
1076  _BassBoost = device::HostPersistence::getInstance().getProperty("audio.BassBoost");
1077  m_bassBoost = atoi(_BassBoost.c_str());
1078  //SPEAKER init
1079  handle = 0;
1081  if (dsSetBassEnhancerFunc(handle, m_bassBoost) == dsERR_NONE) {
1082  printf("Port %s: Initialized Bass Boost : %d\n","SPEAKER0", m_bassBoost);
1083  }
1084  }
1085  //HDMI init
1086  handle = 0;
1087  if(dsGetAudioPort(dsAUDIOPORT_TYPE_HDMI,0,&handle) == dsERR_NONE) {
1088  if (dsSetBassEnhancerFunc(handle, m_bassBoost) == dsERR_NONE) {
1089  printf("Port %s: Initialized Bass Boost : %d\n","HDMI0", m_bassBoost);
1090  }
1091  }
1092  }
1093  catch(...) {
1094  printf("audio.BassBoost not found in persistence store. System Default configured through profiles\n");
1095  }
1096  }
1097  else {
1098  printf("dsSetBassEnhancer_t(int, int) is not defined\r\n");
1099  }
1100  dlclose(dllib);
1101  }
1102  else {
1103  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
1104  }
1105  }
1106  }
1107 
1108  _profileOverride = "FALSE";
1109  try {
1110  _profileOverride = device::HostPersistence::getInstance().getDefaultProperty("audio.SurroundDecoder.ms12ProfileOverride");
1111  }
1112  catch(...) {
1113  _profileOverride = "FALSE";
1114  printf(" audio.SurroundDecoder.ms12ProfileOverride settings not found in system default ..... \r\n");
1115  }
1116  printf(" audio.SurroundDecoder.ms12ProfileOverride = %s ..... \r\n",_profileOverride.c_str());
1117 
1118  if(_profileOverride == "TRUE") {
1119  typedef dsError_t (*dsEnableSurroundDecoder_t)(intptr_t handle, bool enabled);
1120  static dsEnableSurroundDecoder_t dsEnableSurroundDecoderFunc = 0;
1121  if (dsEnableSurroundDecoderFunc == 0) {
1122  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
1123  if (dllib) {
1124  dsEnableSurroundDecoderFunc = (dsEnableSurroundDecoder_t) dlsym(dllib, "dsEnableSurroundDecoder");
1125  if (dsEnableSurroundDecoderFunc) {
1126  printf("dsEnableSurroundDecoder_t(int, bool) is defined and loaded\r\n");
1127  std::string _SurroundDecoder("FALSE");
1128  bool m_surroundDecoder = false;
1129  try {
1130  _SurroundDecoder = device::HostPersistence::getInstance().getProperty("audio.SurroundDecoderEnabled");
1131  if (_SurroundDecoder == "TRUE") {
1132  m_surroundDecoder = true;
1133  }
1134  else {
1135  m_surroundDecoder = false;
1136  }
1137  //SPEAKER init
1138  handle = 0;
1140  if (dsEnableSurroundDecoderFunc(handle, m_surroundDecoder) == dsERR_NONE) {
1141  printf("Port %s: Initialized Surroudn Decoder : %d\n","SPEAKER0", m_surroundDecoder);
1142  }
1143  }
1144  //HDMI init
1145  handle = 0;
1146  if(dsGetAudioPort(dsAUDIOPORT_TYPE_HDMI,0,&handle) == dsERR_NONE) {
1147  if (dsEnableSurroundDecoderFunc(handle, m_surroundDecoder) == dsERR_NONE) {
1148  printf("Port %s: Initialized Surroudn Decoder : %d\n","HDMI0", m_surroundDecoder);
1149  }
1150  }
1151  }
1152  catch(...) {
1153  printf("audio.SurroundDecoderEnabled not found in persistence store. System Default configured through profiles\n");
1154  }
1155  }
1156  else {
1157  printf("dsEnableSurroundDecoder_t(int, bool) is not defined\r\n");
1158  }
1159  dlclose(dllib);
1160  }
1161  else {
1162  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
1163  }
1164  }
1165  }
1166 
1167  _profileOverride = "FALSE";
1168  try {
1169  _profileOverride = device::HostPersistence::getInstance().getDefaultProperty("audio.DRCMode.ms12ProfileOverride");
1170  }
1171  catch(...) {
1172  _profileOverride = "FALSE";
1173  printf(" audio.DRCMode.ms12ProfileOverride settings not found in system default ..... \r\n");
1174  }
1175  printf(" audio.DRCMode.ms12ProfileOverride = %s ..... \r\n",_profileOverride.c_str());
1176 
1177  if(_profileOverride == "TRUE") {
1178  typedef dsError_t (*dsSetDRCMode_t)(intptr_t handle, int mode);
1179  static dsSetDRCMode_t dsSetDRCModeFunc = 0;
1180  if (dsSetDRCModeFunc == 0) {
1181  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
1182  if (dllib) {
1183  dsSetDRCModeFunc = (dsSetDRCMode_t) dlsym(dllib, "dsSetDRCMode");
1184  if (dsSetDRCModeFunc) {
1185  printf("dsSetDRCMode_t(int, int) is defined and loaded\r\n");
1186  std::string _DRCMode("Line");
1187  int m_DRCMode = 0;
1188  try {
1189  _DRCMode = device::HostPersistence::getInstance().getProperty("audio.DRCMode");
1190  if (_DRCMode == "RF") {
1191  m_DRCMode = 1;
1192  }
1193  else {
1194  m_DRCMode = 0;
1195  }
1196  //SPEAKER init
1197  handle = 0;
1199  if (dsSetDRCModeFunc(handle, m_DRCMode) == dsERR_NONE) {
1200  printf("Port %s: Initialized DRCMode : %d\n","SPEAKER0", m_DRCMode);
1201  }
1202  }
1203  //HDMI init
1204  handle = 0;
1205  if(dsGetAudioPort(dsAUDIOPORT_TYPE_HDMI,0,&handle) == dsERR_NONE) {
1206  if (dsSetDRCModeFunc(handle, m_DRCMode) == dsERR_NONE) {
1207  printf("Port %s: Initialized DRCMode : %d\n","HDMI0", m_DRCMode);
1208  }
1209  }
1210  }
1211  catch(...) {
1212  printf("audio.DRCMode not found in persistence store. System Default configured through profiles\n");
1213  }
1214  }
1215  else {
1216  printf("dsSetDRCMode_t(int, int) is not defined\r\n");
1217  }
1218  dlclose(dllib);
1219  }
1220  else {
1221  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
1222  }
1223  }
1224  }
1225 
1226  _profileOverride = "FALSE";
1227  try {
1228  _profileOverride = device::HostPersistence::getInstance().getDefaultProperty("audio.SurroundVirtualizer.ms12ProfileOverride");
1229  }
1230  catch(...) {
1231  _profileOverride = "FALSE";
1232  printf(" audio.SurroundVirtualizer.ms12ProfileOverride settings not found in system default ..... \r\n");
1233  }
1234  printf(" audio.SurroundVirtualizer.ms12ProfileOverride = %s ..... \r\n",_profileOverride.c_str());
1235 
1236  if(_profileOverride == "TRUE") {
1237  typedef dsError_t (*dsSetSurroundVirtualizer_t)(intptr_t handle, dsSurroundVirtualizer_t virtualizer);
1238  static dsSetSurroundVirtualizer_t dsSetSurroundVirtualizerFunc = 0;
1239  if (dsSetSurroundVirtualizerFunc == 0) {
1240  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
1241  if (dllib) {
1242  dsSetSurroundVirtualizerFunc = (dsSetSurroundVirtualizer_t) dlsym(dllib, "dsSetSurroundVirtualizer");
1243  if (dsSetSurroundVirtualizerFunc) {
1244  printf("dsSetSurroundVirtualizer_t(int, dsSurroundVirtualizer_t virtualizer) is defined and loaded\r\n");
1245  std::string _SVMode("0");
1246  std::string _SVBoost("0");
1247  dsSurroundVirtualizer_t m_virtualizer;
1248  std::string _PropertyMode = _dsGetCurrentProfileProperty("SurroundVirtualizer.mode");
1249  std::string _PropertyBoost = _dsGetCurrentProfileProperty("SurroundVirtualizer.boost");
1250  try {
1251  _SVMode = device::HostPersistence::getInstance().getProperty(_PropertyMode);
1252  _SVBoost = device::HostPersistence::getInstance().getProperty(_PropertyBoost);
1253  m_virtualizer.mode = atoi(_SVMode.c_str());
1254  m_virtualizer.boost = atoi(_SVBoost.c_str());
1255  //SPEAKER init
1256  handle = 0;
1258  if (dsSetSurroundVirtualizerFunc(handle, m_virtualizer) == dsERR_NONE) {
1259  printf("Port %s: Initialized Surround Virtualizer : Mode: %d, Boost : %d\n","SPEAKER0", m_virtualizer.mode, m_virtualizer.boost);
1260  }
1261  }
1262  //HDMI init
1263  handle = 0;
1264  if(dsGetAudioPort(dsAUDIOPORT_TYPE_HDMI,0,&handle) == dsERR_NONE) {
1265  if (dsSetSurroundVirtualizerFunc(handle, m_virtualizer) == dsERR_NONE){
1266  printf("Port %s: Initialized Surround Virtualizer : Mode: %d, Boost : %d\\n","HDMI0", m_virtualizer.mode, m_virtualizer.boost);
1267  }
1268  }
1269  }
1270  catch(...) {
1271  printf("audio.SurroundVirtualizer not found in persistence store. System Default configured through profiles \n");
1272  }
1273  }
1274  else {
1275  printf("dsSetSurroundVirtualizer_t(int, dsSurroundVirtualizer_t) is not defined\r\n");
1276  }
1277  dlclose(dllib);
1278  }
1279  else {
1280  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
1281  }
1282  }
1283  }
1284 
1285  _profileOverride = "FALSE";
1286  try {
1287  _profileOverride = device::HostPersistence::getInstance().getDefaultProperty("audio.MISteering.ms12ProfileOverride");
1288  }
1289  catch(...) {
1290  _profileOverride = "FALSE";
1291  printf(" audio.MISteering.ms12ProfileOverride settings not found in system default ..... \r\n");
1292  }
1293  printf(" audio.MISteering.ms12ProfileOverride = %s ..... \r\n",_profileOverride.c_str());
1294 
1295  if(_profileOverride == "TRUE") {
1296  typedef dsError_t (*dsSetMISteering_t)(intptr_t handle, bool enabled);
1297  static dsSetMISteering_t dsSetMISteeringFunc = 0;
1298  if (dsSetMISteeringFunc == 0) {
1299  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
1300  if (dllib) {
1301  dsSetMISteeringFunc = (dsSetMISteering_t) dlsym(dllib, "dsSetMISteering");
1302  if (dsSetMISteeringFunc) {
1303  printf("dsSetMISteering_t(int, bool) is defined and loaded\r\n");
1304  std::string _MISteering("Disabled");
1305  bool m_MISteering = false;
1306  try {
1307  _MISteering = device::HostPersistence::getInstance().getProperty("audio.MISteering");
1308  if (_MISteering == "Enabled") {
1309  m_MISteering = true;
1310  }
1311  else {
1312  m_MISteering = false;
1313  }
1314  //SPEAKER init
1315  handle = 0;
1317  if (dsSetMISteeringFunc(handle, m_MISteering) == dsERR_NONE) {
1318  printf("Port %s: Initialized MI Steering : %d\n","SPEAKER0", m_MISteering);
1319  }
1320  //HDMI init
1321  handle = 0;
1322  if (dsGetAudioPort(dsAUDIOPORT_TYPE_HDMI,0,&handle) == dsERR_NONE) {
1323  if (dsSetMISteeringFunc(handle, m_MISteering) == dsERR_NONE) {
1324  printf("Port %s: Initialized MI Steering : %d\n","HDMI0", m_MISteering);
1325  }
1326  }
1327  else {
1328  printf("Port %s: Initialization MI Steering : %d failed. Port not available\n","HDMI0", m_MISteering);
1329  }
1330  }
1331  catch(...) {
1332  printf("audio.MISteering not found in persistence store. System Default configured through profiles\n");
1333  }
1334  }
1335  else {
1336  printf("dsSetMISteering_t(int, bool) is not defined\r\n");
1337  }
1338  dlclose(dllib);
1339  }
1340  else {
1341  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
1342  }
1343  }
1344  }
1345 
1346  _profileOverride = "FALSE";
1347  try {
1348  _profileOverride = device::HostPersistence::getInstance().getDefaultProperty("audio.GraphicEQ.ms12ProfileOverride");
1349  }
1350  catch(...) {
1351  _profileOverride = "FALSE";
1352  printf(" audio.GraphicEQ.ms12ProfileOverride settings not found in system default ..... \r\n");
1353  }
1354  printf(" audio.GraphicEQ.ms12ProfileOverride = %s ..... \r\n",_profileOverride.c_str());
1355 
1356  if(_profileOverride == "TRUE") {
1357  typedef dsError_t (*dsSetGraphicEqualizerMode_t)(intptr_t handle, int mode);
1358  static dsSetGraphicEqualizerMode_t dsSetGraphicEqualizerModeFunc = 0;
1359  if (dsSetGraphicEqualizerModeFunc == 0) {
1360  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
1361  if (dllib) {
1362  dsSetGraphicEqualizerModeFunc = (dsSetGraphicEqualizerMode_t) dlsym(dllib, "dsSetGraphicEqualizerMode");
1363  if (dsSetGraphicEqualizerModeFunc) {
1364  printf("dsSetGraphicEqualizerMode_t(int, int) is defined and loaded\r\n");
1365  std::string _GEQMode("0");
1366  int m_GEQMode = 0;
1367  handle = 0;
1369  try {
1370  _GEQMode = device::HostPersistence::getInstance().getProperty("audio.GraphicEQ");
1371  m_GEQMode = atoi(_GEQMode.c_str());
1372  //SPEAKER init
1373  handle = 0;
1375  if (dsSetGraphicEqualizerModeFunc(handle, m_GEQMode) == dsERR_NONE) {
1376  printf("Port %s: Initialized Graphic Equalizer mode : %d\n","SPEAKER0", m_GEQMode);
1377  }
1378  }
1379  //HDMI init
1380  handle = 0;
1381  if(dsGetAudioPort(dsAUDIOPORT_TYPE_HDMI,0,&handle) == dsERR_NONE) {
1382  if (dsSetGraphicEqualizerModeFunc(handle, m_GEQMode) == dsERR_NONE) {
1383  printf("Port %s: Initialized Graphic Equalizer mode : %d\n","HDMI0", m_GEQMode);
1384  }
1385  }
1386  }
1387  catch(...) {
1388  printf("audio.GraphicEQ not found in persistence store. System Default configured through profiles\n");
1389  }
1390  }
1391  else {
1392  printf("dsSetGraphicEqualizerMode_t(int, int) is not defined\r\n");
1393  }
1394  dlclose(dllib);
1395  }
1396  else {
1397  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
1398  }
1399  }
1400  }
1401  }
1402 //MS12 Audio Profile not there
1403 //Initialize individual settings from persistence store / system default if persistence store empty
1404  else if(_AProfileSupport == "FALSE") {
1405  typedef dsError_t (*dsSetAudioCompression_t)(intptr_t handle, int compressionLevel);
1406  static dsSetAudioCompression_t dsSetAudioCompressionFunc = 0;
1407  if (dsSetAudioCompressionFunc == 0) {
1408  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
1409  if (dllib) {
1410  dsSetAudioCompressionFunc = (dsSetAudioCompression_t) dlsym(dllib, "dsSetAudioCompression");
1411  if (dsSetAudioCompressionFunc) {
1412  printf("dsSetAudioCompression_t(int, int ) is defined and loaded\r\n");
1413  std::string _AudioCompression("0");
1414  int m_audioCompression = 0;
1415  try {
1416  _AudioCompression = device::HostPersistence::getInstance().getProperty("audio.Compression");
1417  }
1418  catch(...) {
1419  try {
1420  printf("audio.Compression not found in persistence store. Try system default\n");
1421  _AudioCompression = device::HostPersistence::getInstance().getDefaultProperty("audio.Compression");
1422  }
1423  catch(...) {
1424  _AudioCompression = "0";
1425  }
1426  }
1427  m_audioCompression = atoi(_AudioCompression.c_str());
1428  //SPEAKER init
1429  handle = 0;
1431  if (dsSetAudioCompressionFunc(handle, m_audioCompression) == dsERR_NONE) {
1432  printf("Port %s: Initialized audio compression : %d\n","SPEAKER0", m_audioCompression);
1433  }
1434  }
1435  //HDMI init
1436  handle = 0;
1437  if(dsGetAudioPort(dsAUDIOPORT_TYPE_HDMI,0,&handle) == dsERR_NONE) {
1438  if (dsSetAudioCompressionFunc(handle, m_audioCompression) == dsERR_NONE) {
1439  printf("Port %s: Initialized audio compression : %d\n","HDMI0", m_audioCompression);
1440  }
1441  }
1442  }
1443  else {
1444  printf("dsSetAudioCompression_t(int, int) is not defined\r\n");
1445  }
1446  dlclose(dllib);
1447  }
1448  else {
1449  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
1450  }
1451  }
1452 
1453 
1454  typedef dsError_t (*dsSetDialogEnhancement_t)(intptr_t handle, int enhancerLevel);
1455  static dsSetDialogEnhancement_t dsSetDialogEnhancementFunc = 0;
1456  if (dsSetDialogEnhancementFunc == 0) {
1457  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
1458  if (dllib) {
1459  dsSetDialogEnhancementFunc = (dsSetDialogEnhancement_t) dlsym(dllib, "dsSetDialogEnhancement");
1460  if (dsSetDialogEnhancementFunc) {
1461  printf("dsSetDialogEnhancement_t(int, int) is defined and loaded\r\n");
1462  std::string _EnhancerLevel("0");
1463  int m_enhancerLevel = 0;
1464  try {
1465  _EnhancerLevel = device::HostPersistence::getInstance().getProperty("audio.EnhancerLevel");
1466  }
1467  catch(...) {
1468  try {
1469  printf("audio.EnhancerLevel not found in persistence store. Try system default\n");
1470  _EnhancerLevel = device::HostPersistence::getInstance().getDefaultProperty("audio.EnhancerLevel");
1471  }
1472  catch(...) {
1473  _EnhancerLevel = "0";
1474  }
1475  }
1476  m_enhancerLevel = atoi(_EnhancerLevel.c_str());
1477  //SPEAKER init
1478  handle = 0;
1480  if (dsSetDialogEnhancementFunc(handle, m_enhancerLevel) == dsERR_NONE) {
1481  printf("Port %s: Initialized dialog enhancement level : %d\n","SPEAKER0", m_enhancerLevel);
1482  }
1483  }
1484  //HDMI init
1485  handle = 0;
1486  if(dsGetAudioPort(dsAUDIOPORT_TYPE_HDMI,0,&handle) == dsERR_NONE) {
1487  if (dsSetDialogEnhancementFunc(handle, m_enhancerLevel) == dsERR_NONE) {
1488  printf("Port %s: Initialized dialog enhancement level : %d\n","HDMI0", m_enhancerLevel);
1489  }
1490  }
1491  }
1492  else {
1493  printf("dsSetDialogEnhancement_t(int, int ) is not defined\r\n");
1494  }
1495  dlclose(dllib);
1496  }
1497  else {
1498  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
1499  }
1500  }
1501 
1502 
1503  typedef dsError_t (*dsSetDolbyVolumeMode_t)(intptr_t handle, bool enable);
1504  static dsSetDolbyVolumeMode_t dsSetDolbyVolumeModeFunc = 0;
1505  bool bDolbyVolumeOverrideCheck = true; //DolbyVolume setting only overrides when DolbyVolume is present and VolumeLeveller is not present in persistence.
1506  if (dsSetDolbyVolumeModeFunc == 0) {
1507  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
1508  if (dllib) {
1509  dsSetDolbyVolumeModeFunc = (dsSetDolbyVolumeMode_t) dlsym(dllib, "dsSetDolbyVolumeMode");
1510  if (dsSetDolbyVolumeModeFunc) {
1511  printf("dsSetDolbyVolumeMode_t(int, bool) is defined and loaded\r\n");
1512  std::string _DolbyVolumeMode("FALSE");
1513  bool m_dolbyVolumeMode = false;
1514  try {
1515  _DolbyVolumeMode = device::HostPersistence::getInstance().getProperty("audio.DolbyVolumeMode");
1516  bDolbyVolumeOverrideCheck = false;
1517  }
1518  catch(...) {
1519  try {
1520  printf("audio.DolbyVolumeMode not found in persistence store. Try system default\n");
1521  _DolbyVolumeMode = device::HostPersistence::getInstance().getDefaultProperty("audio.DolbyVolumeMode");
1522  }
1523  catch(...) {
1524  _DolbyVolumeMode = "FALSE";
1525  }
1526  }
1527  if (_DolbyVolumeMode == "TRUE") {
1528  m_dolbyVolumeMode = true;
1529  }
1530  else {
1531  m_dolbyVolumeMode = false;
1532  }
1533  //SPEAKER init
1534  handle = 0;
1536  if (dsSetDolbyVolumeModeFunc(handle, m_dolbyVolumeMode) == dsERR_NONE) {
1537  printf("Port %s: Initialized Dolby Volume Mode : %d\n","SPEAKER0", m_dolbyVolumeMode);
1538  }
1539  }
1540  //HDMI init
1541  handle = 0;
1542  if(dsGetAudioPort(dsAUDIOPORT_TYPE_HDMI,0,&handle) == dsERR_NONE) {
1543  if (dsSetDolbyVolumeModeFunc(handle, m_dolbyVolumeMode) == dsERR_NONE) {
1544  printf("Port %s: Initialized Dolby Volume Mode : %d\n","HDMI0", m_dolbyVolumeMode);
1545  }
1546  }
1547  }
1548  else {
1549  printf("dsSetDolbyVolumeMode_t(int, bool) is not defined\r\n");
1550  }
1551  dlclose(dllib);
1552  }
1553  else {
1554  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
1555  }
1556  }
1557 
1558  typedef dsError_t (*dsSetIntelligentEqualizerMode_t)(intptr_t handle, int mode);
1559  static dsSetIntelligentEqualizerMode_t dsSetIntelligentEqualizerModeFunc = 0;
1560  if (dsSetIntelligentEqualizerModeFunc == 0) {
1561  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
1562  if (dllib) {
1563  dsSetIntelligentEqualizerModeFunc = (dsSetIntelligentEqualizerMode_t) dlsym(dllib, "dsSetIntelligentEqualizerMode");
1564  if (dsSetIntelligentEqualizerModeFunc) {
1565  printf("dsSetIntelligentEqualizerMode_t(int, int) is defined and loaded\r\n");
1566  std::string _IEQMode("0");
1567  int m_IEQMode = 0;
1568  handle = 0;
1570  try {
1571  _IEQMode = device::HostPersistence::getInstance().getProperty("audio.IntelligentEQ");
1572  }
1573  catch(...) {
1574  try {
1575  printf("audio.IntelligentEQ not found in persistence store. Try system default\n");
1576  _IEQMode = device::HostPersistence::getInstance().getDefaultProperty("audio.IntelligentEQ");
1577  }
1578  catch(...) {
1579  _IEQMode = "0";
1580  }
1581  }
1582  m_IEQMode = atoi(_IEQMode.c_str());
1583 
1584  //SPEAKER init
1585  handle = 0;
1587  if (dsSetIntelligentEqualizerModeFunc(handle, m_IEQMode) == dsERR_NONE) {
1588  printf("Port %s: Initialized Intelligent Equalizer mode : %d\n","SPEAKER0", m_IEQMode);
1589  }
1590  }
1591  //HDMI init
1592  handle = 0;
1593  if(dsGetAudioPort(dsAUDIOPORT_TYPE_HDMI,0,&handle) == dsERR_NONE) {
1594  if (dsSetIntelligentEqualizerModeFunc(handle, m_IEQMode) == dsERR_NONE) {
1595  printf("Port %s: Initialized Intelligent Equalizer mode : %d\n","HDMI0", m_IEQMode);
1596  }
1597  }
1598  }
1599  else {
1600  printf("dsSetIntelligentEqualizerMode_t(int, int) is not defined\r\n");
1601  }
1602  dlclose(dllib);
1603  }
1604  else {
1605  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
1606  }
1607  }
1608 
1609  typedef dsError_t (*dsSetVolumeLeveller_t)(intptr_t handle, dsVolumeLeveller_t volLeveller);
1610  static dsSetVolumeLeveller_t dsSetVolumeLevellerFunc = 0;
1611  if (dsSetVolumeLevellerFunc == 0) {
1612  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
1613  if (dllib) {
1614  dsSetVolumeLevellerFunc = (dsSetVolumeLeveller_t) dlsym(dllib, "dsSetVolumeLeveller");
1615  if (dsSetVolumeLevellerFunc) {
1616  printf("dsSetVolumeLeveller_t(int, dsVolumeLeveller_t) is defined and loaded\r\n");
1617  std::string _volLevellerMode("0");
1618  std::string _volLevellerLevel("0");
1619  dsVolumeLeveller_t m_volumeLeveller;
1620  try {
1621  _volLevellerMode = device::HostPersistence::getInstance().getProperty("audio.VolumeLeveller.mode");
1622  _volLevellerLevel = device::HostPersistence::getInstance().getProperty("audio.VolumeLeveller.level");
1623  bDolbyVolumeOverrideCheck = true;
1624  }
1625  catch(...) {
1626  try {
1627  printf("audio.VolumeLeveller not found in persistence store. Try system default\n");
1628  _volLevellerMode = device::HostPersistence::getInstance().getDefaultProperty("audio.VolumeLeveller.mode");
1629  _volLevellerLevel = device::HostPersistence::getInstance().getDefaultProperty("audio.VolumeLeveller.level");
1630  }
1631  catch(...) {
1632  _volLevellerMode = "0";
1633  _volLevellerLevel = "0";
1634  }
1635  }
1636  m_volumeLeveller.mode = atoi(_volLevellerMode.c_str());
1637  m_volumeLeveller.level = atoi(_volLevellerLevel.c_str());
1638  //SPEAKER init
1639  handle = 0;
1640  printf("bDolbyVolumeOverrideCheck value: %d\n", bDolbyVolumeOverrideCheck);
1641  if(bDolbyVolumeOverrideCheck && dsGetAudioPort(dsAUDIOPORT_TYPE_SPEAKER,0,&handle) == dsERR_NONE) {
1642  if (dsSetVolumeLevellerFunc(handle, m_volumeLeveller) == dsERR_NONE) {
1643  printf("Port %s: Initialized Volume Leveller : Mode: %d, Level: %d\n","SPEAKER0", m_volumeLeveller.mode, m_volumeLeveller.level);
1644  }
1645  }
1646  //HDMI init
1647  handle = 0;
1648  if(bDolbyVolumeOverrideCheck && dsGetAudioPort(dsAUDIOPORT_TYPE_HDMI,0,&handle) == dsERR_NONE) {
1649  if (dsSetVolumeLevellerFunc(handle, m_volumeLeveller) == dsERR_NONE) {
1650  printf("Port %s: Initialized Volume Leveller : Mode: %d, Level: %d\n","HDMI0", m_volumeLeveller.mode, m_volumeLeveller.level);
1651  }
1652  }
1653  }
1654  else {
1655  printf("dsSetVolumeLeveller_t(int, dsVolumeLeveller_t) is not defined\r\n");
1656  }
1657  dlclose(dllib);
1658  }
1659  else {
1660  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
1661  }
1662  }
1663 
1664 
1665  typedef dsError_t (*dsSetBassEnhancer_t)(intptr_t handle, int boost);
1666  static dsSetBassEnhancer_t dsSetBassEnhancerFunc = 0;
1667  if (dsSetBassEnhancerFunc == 0) {
1668  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
1669  if (dllib) {
1670  dsSetBassEnhancerFunc = (dsSetBassEnhancer_t) dlsym(dllib, "dsSetBassEnhancer");
1671  if (dsSetBassEnhancerFunc) {
1672  printf("dsSetBassEnhancer_t(int, int) is defined and loaded\r\n");
1673  std::string _BassBoost("0");
1674  int m_bassBoost = 0;
1675  try {
1676  _BassBoost = device::HostPersistence::getInstance().getProperty("audio.BassBoost");
1677  }
1678  catch(...) {
1679  try {
1680  printf("audio.BassBoost not found in persistence store. Try system default\n");
1681  std::string _Property = _dsGetCurrentProfileProperty("BassBoost");
1682  _BassBoost = device::HostPersistence::getInstance().getDefaultProperty(_Property);
1683  }
1684  catch(...) {
1685  _BassBoost = "0";
1686  }
1687  }
1688  m_bassBoost = atoi(_BassBoost.c_str());
1689  //SPEAKER init
1690  handle = 0;
1692  if (dsSetBassEnhancerFunc(handle, m_bassBoost) == dsERR_NONE) {
1693  printf("Port %s: Initialized Bass Boost : %d\n","SPEAKER0", m_bassBoost);
1694  }
1695  }
1696  //HDMI init
1697  handle = 0;
1698  if(dsGetAudioPort(dsAUDIOPORT_TYPE_HDMI,0,&handle) == dsERR_NONE) {
1699  if (dsSetBassEnhancerFunc(handle, m_bassBoost) == dsERR_NONE) {
1700  printf("Port %s: Initialized Bass Boost : %d\n","HDMI0", m_bassBoost);
1701  }
1702  }
1703  }
1704  else {
1705  printf("dsSetBassEnhancer_t(int, int) is not defined\r\n");
1706  }
1707  dlclose(dllib);
1708  }
1709  else {
1710  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
1711  }
1712  }
1713 
1714 
1715  typedef dsError_t (*dsEnableSurroundDecoder_t)(intptr_t handle, bool enabled);
1716  static dsEnableSurroundDecoder_t dsEnableSurroundDecoderFunc = 0;
1717  if (dsEnableSurroundDecoderFunc == 0) {
1718  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
1719  if (dllib) {
1720  dsEnableSurroundDecoderFunc = (dsEnableSurroundDecoder_t) dlsym(dllib, "dsEnableSurroundDecoder");
1721  if (dsEnableSurroundDecoderFunc) {
1722  printf("dsEnableSurroundDecoder_t(int, bool) is defined and loaded\r\n");
1723  std::string _SurroundDecoder("FALSE");
1724  bool m_surroundDecoder = false;
1725  try {
1726  _SurroundDecoder = device::HostPersistence::getInstance().getProperty("audio.SurroundDecoderEnabled");
1727  }
1728  catch(...) {
1729  try {
1730  printf("audio.SurroundDecoderEnabled not found in persistence store. Try system default\n");
1731  _SurroundDecoder = device::HostPersistence::getInstance().getDefaultProperty("audio.SurroundDecoderEnabled");
1732  }
1733  catch(...) {
1734  _SurroundDecoder = "FALSE";
1735  }
1736  }
1737  if (_SurroundDecoder == "TRUE") {
1738  m_surroundDecoder = true;
1739  }
1740  else {
1741  m_surroundDecoder = false;
1742  }
1743  //SPEAKER init
1744  handle = 0;
1746  if (dsEnableSurroundDecoderFunc(handle, m_surroundDecoder) == dsERR_NONE) {
1747  printf("Port %s: Initialized Surroudn Decoder : %d\n","SPEAKER0", m_surroundDecoder);
1748  }
1749  }
1750  //HDMI init
1751  handle = 0;
1752  if(dsGetAudioPort(dsAUDIOPORT_TYPE_HDMI,0,&handle) == dsERR_NONE) {
1753  if (dsEnableSurroundDecoderFunc(handle, m_surroundDecoder) == dsERR_NONE) {
1754  printf("Port %s: Initialized Surroudn Decoder : %d\n","HDMI0", m_surroundDecoder);
1755  }
1756  }
1757  }
1758  else {
1759  printf("dsEnableSurroundDecoder_t(int, bool) is not defined\r\n");
1760  }
1761  dlclose(dllib);
1762  }
1763  else {
1764  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
1765  }
1766  }
1767 
1768 
1769  typedef dsError_t (*dsSetDRCMode_t)(intptr_t handle, int mode);
1770  static dsSetDRCMode_t dsSetDRCModeFunc = 0;
1771  if (dsSetDRCModeFunc == 0) {
1772  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
1773  if (dllib) {
1774  dsSetDRCModeFunc = (dsSetDRCMode_t) dlsym(dllib, "dsSetDRCMode");
1775  if (dsSetDRCModeFunc) {
1776  printf("dsSetDRCMode_t(int, int) is defined and loaded\r\n");
1777  std::string _DRCMode("Line");
1778  int m_DRCMode = 0;
1779  try {
1780  _DRCMode = device::HostPersistence::getInstance().getProperty("audio.DRCMode");
1781  }
1782  catch(...) {
1783  try {
1784  printf("audio.DRCMode not found in persistence store. Try system default\n");
1785  _DRCMode = device::HostPersistence::getInstance().getDefaultProperty("audio.DRCMode");
1786  }
1787  catch(...) {
1788  _DRCMode = "Line";
1789  }
1790  }
1791  if (_DRCMode == "RF") {
1792  m_DRCMode = 1;
1793  }
1794  else {
1795  m_DRCMode = 0;
1796  }
1797  //SPEAKER init
1798  handle = 0;
1800  if (dsSetDRCModeFunc(handle, m_DRCMode) == dsERR_NONE) {
1801  printf("Port %s: Initialized DRCMode : %d\n","SPEAKER0", m_DRCMode);
1802  }
1803  }
1804  //HDMI init
1805  handle = 0;
1806  if(dsGetAudioPort(dsAUDIOPORT_TYPE_HDMI,0,&handle) == dsERR_NONE) {
1807  if (dsSetDRCModeFunc(handle, m_DRCMode) == dsERR_NONE) {
1808  printf("Port %s: Initialized DRCMode : %d\n","HDMI0", m_DRCMode);
1809  }
1810  }
1811  }
1812  else {
1813  printf("dsSetDRCMode_t(int, int) is not defined\r\n");
1814  }
1815  dlclose(dllib);
1816  }
1817  else {
1818  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
1819  }
1820  }
1821 
1822 
1823  typedef dsError_t (*dsSetSurroundVirtualizer_t)(intptr_t handle, dsSurroundVirtualizer_t virtualizer);
1824  static dsSetSurroundVirtualizer_t dsSetSurroundVirtualizerFunc = 0;
1825  if (dsSetSurroundVirtualizerFunc == 0) {
1826  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
1827  if (dllib) {
1828  dsSetSurroundVirtualizerFunc = (dsSetSurroundVirtualizer_t) dlsym(dllib, "dsSetSurroundVirtualizer");
1829  if (dsSetSurroundVirtualizerFunc) {
1830  printf("dsSetSurroundVirtualizer_t(int, dsSurroundVirtualizer_t) is defined and loaded\r\n");
1831  std::string _SVMode("0");
1832  std::string _SVBoost("0");
1833  dsSurroundVirtualizer_t m_virtualizer;
1834 
1835  try {
1836  _SVMode = device::HostPersistence::getInstance().getProperty("audio.SurroundVirtualizer.mode");
1837  _SVBoost = device::HostPersistence::getInstance().getProperty("audio.SurroundVirtualizer.boost");
1838  m_virtualizer.mode = atoi(_SVMode.c_str());
1839  m_virtualizer.boost = atoi(_SVBoost.c_str());
1840  }
1841  catch(...) {
1842  try {
1843  printf("audio.SurroundVirtualizer.mode/audio.SurroundVirtualizer.boost not found in persistence store. Try system default\n");
1844  _SVMode = device::HostPersistence::getInstance().getProperty("audio.SurroundVirtualizer.mode");
1845  _SVBoost = device::HostPersistence::getInstance().getProperty("audio.SurroundVirtualizer.boost");
1846  }
1847  catch(...) {
1848  _SVMode = "0";
1849  _SVBoost = "0";
1850  }
1851  }
1852  m_virtualizer.mode = atoi(_SVMode.c_str());
1853  m_virtualizer.boost = atoi(_SVBoost.c_str());
1854  //SPEAKER init
1855  handle = 0;
1857  if (dsSetSurroundVirtualizerFunc(handle, m_virtualizer) == dsERR_NONE) {
1858  printf("Port %s: Initialized Surround Virtualizer : Mode: %d, Boost : %d\n","SPEAKER0", m_virtualizer.mode, m_virtualizer.boost);
1859  }
1860  }
1861  //HDMI init
1862  handle = 0;
1863  if(dsGetAudioPort(dsAUDIOPORT_TYPE_HDMI,0,&handle) == dsERR_NONE) {
1864  if (dsSetSurroundVirtualizerFunc(handle, m_virtualizer) == dsERR_NONE) {
1865  printf("Port %s: Initialized Surround Virtualizer : Mode: %d, Boost : %d\\n","HDMI0", m_virtualizer.mode, m_virtualizer.boost);
1866  }
1867  }
1868  }
1869  else {
1870  printf("dsSetSurroundVirtualizer_t(int, dsSurroundVirtualizer_t) is not defined\r\n");
1871  }
1872  dlclose(dllib);
1873  }
1874  else {
1875  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
1876  }
1877  }
1878 
1879 
1880  typedef dsError_t (*dsSetMISteering_t)(intptr_t handle, bool enabled);
1881  static dsSetMISteering_t dsSetMISteeringFunc = 0;
1882  if (dsSetMISteeringFunc == 0) {
1883  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
1884  if (dllib) {
1885  dsSetMISteeringFunc = (dsSetMISteering_t) dlsym(dllib, "dsSetMISteering");
1886  if (dsSetMISteeringFunc) {
1887  printf("dsSetMISteering_t(int, bool) is defined and loaded\r\n");
1888  std::string _MISteering("Disabled");
1889  bool m_MISteering = false;
1890  try {
1891  _MISteering = device::HostPersistence::getInstance().getProperty("audio.MISteering");
1892  }
1893  catch(...) {
1894  try {
1895  printf("audio.MISteering not found in persistence store. Try system default\n");
1896  _MISteering = device::HostPersistence::getInstance().getDefaultProperty("audio.MISteering");
1897  }
1898  catch(...) {
1899  _MISteering = "Disabled";
1900  }
1901  }
1902  if (_MISteering == "Enabled") {
1903  m_MISteering = true;
1904  }
1905  else {
1906  m_MISteering = false;
1907  }
1908 
1909  //SPEAKER init
1910  handle = 0;
1912  if (dsSetMISteeringFunc(handle, m_MISteering) == dsERR_NONE) {
1913  printf("Port %s: Initialized MI Steering : %d\n","SPEAKER0", m_MISteering);
1914  }
1915  //HDMI init
1916  handle = 0;
1917  if (dsGetAudioPort(dsAUDIOPORT_TYPE_HDMI,0,&handle) == dsERR_NONE) {
1918  if (dsSetMISteeringFunc(handle, m_MISteering) == dsERR_NONE) {
1919  printf("Port %s: Initialized MI Steering : %d\n","HDMI0", m_MISteering);
1920  }
1921  }
1922  else {
1923  printf("Port %s: Initialization MI Steering : %d failed. Port not available\n","HDMI0", m_MISteering);
1924  }
1925  }
1926  else {
1927  printf("dsSetMISteering_t(int, bool) is not defined\r\n");
1928  }
1929  dlclose(dllib);
1930  }
1931  else {
1932  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
1933  }
1934  }
1935 
1936 
1937  typedef dsError_t (*dsSetGraphicEqualizerMode_t)(intptr_t handle, int mode);
1938  static dsSetGraphicEqualizerMode_t dsSetGraphicEqualizerModeFunc = 0;
1939  if (dsSetGraphicEqualizerModeFunc == 0) {
1940  dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
1941  if (dllib) {
1942  dsSetGraphicEqualizerModeFunc = (dsSetGraphicEqualizerMode_t) dlsym(dllib, "dsSetGraphicEqualizerMode");
1943  if (dsSetGraphicEqualizerModeFunc) {
1944  printf("dsSetGraphicEqualizerMode_t(int, int) is defined and loaded\r\n");
1945  std::string _GEQMode("0");
1946  int m_GEQMode = 0;
1947  handle = 0;
1949  try {
1950  _GEQMode = device::HostPersistence::getInstance().getProperty("audio.GraphicEQ");
1951  }
1952  catch(...) {
1953  try {
1954  printf("audio.GraphicEQ not found in persistence store. Try system default\n");
1955  _GEQMode = device::HostPersistence::getInstance().getDefaultProperty("audio.GraphicEQ");
1956  }
1957  catch(...) {
1958  _GEQMode = "0";
1959  }
1960  }
1961  m_GEQMode = atoi(_GEQMode.c_str());
1962 
1963  //SPEAKER init
1964  handle = 0;
1966  if (dsSetGraphicEqualizerModeFunc(handle, m_GEQMode) == dsERR_NONE) {
1967  printf("Port %s: Initialized Graphic Equalizer mode : %d\n","SPEAKER0", m_GEQMode);
1968  }
1969  }
1970  //HDMI init
1971  handle = 0;
1972  if(dsGetAudioPort(dsAUDIOPORT_TYPE_HDMI,0,&handle) == dsERR_NONE) {
1973  if (dsSetGraphicEqualizerModeFunc(handle, m_GEQMode) == dsERR_NONE) {
1974  printf("Port %s: Initialized Graphic Equalizer mode : %d\n","HDMI0", m_GEQMode);
1975  }
1976  }
1977  }
1978  else {
1979  printf("dsSetGraphicEqualizerMode_t(int, int) is not defined\r\n");
1980  }
1981  dlclose(dllib);
1982  }
1983  else {
1984  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
1985  }
1986  }
1987  }
1988  /* HDMI ARC digital audio mode settings */
1989  handle = 0;
1990  if(dsGetAudioPort(dsAUDIOPORT_TYPE_HDMI_ARC,0,&handle) == dsERR_NONE) {
1991  std::string _ARCAudioModeAuto("FALSE");
1992  try {
1993  _ARCAudioModeAuto = device::HostPersistence::getInstance().getProperty("HDMI_ARC0.AudioMode.AUTO");
1994  }
1995  catch(...) {
1996  try {
1997  printf("HDMI_ARC0.AudioMode.AUTO not found in persistence store. Try system default\n");
1998  _ARCAudioModeAuto = device::HostPersistence::getInstance().getDefaultProperty("HDMI_ARC0.AudioMode.AUTO");
1999  }
2000  catch(...) {
2001  _ARCAudioModeAuto = "FALSE";
2002  }
2003  }
2004  if (_ARCAudioModeAuto.compare("TRUE") == 0)
2005  {
2006  typedef dsError_t (*dsSetStereoAuto_t)(intptr_t handle, int autoMode);
2007  static dsSetStereoAuto_t func = 0;
2008  if (func == 0) {
2009  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
2010  if (dllib) {
2011  func = (dsSetStereoAuto_t) dlsym(dllib, "dsSetStereoAuto");
2012  if (func) {
2013  printf("dsSetStereoAuto_t(int, int *) is defined and loaded\r\n");
2014  }
2015  else {
2016  printf("dsSetStereoAuto_t(int, int *) is not defined\r\n");
2017  }
2018  dlclose(dllib);
2019  }
2020  else {
2021  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
2022  }
2023  }
2024 
2025  if (func != 0 && handle != NULL)
2026  {
2027  if (func(handle, 1) == dsERR_NONE)
2028  {
2029  printf("dsSetStereoAuto Port HDMI_0ARC Audio Mode is set to Auto \n");
2030  }
2031  }
2032 
2033  }
2034  else if (_ARCAudioModeAuto.compare("FALSE") == 0)
2035  {
2036  if (NULL != handle) {
2037  if (dsSetStereoMode(handle, _srv_HDMI_ARC_Audiomode) == dsERR_NONE)
2038  {
2039  printf("dsSetStereoMode The HDMI ARC Port Audio Settings Mode is %d \r\n",_srv_HDMI_ARC_Audiomode);
2040  }
2041  }
2042  }
2043  }
2044 
2045 
2046 #endif //DS_AUDIO_SETTINGS_PERSISTENCE
2047 }
2048 
2049 IARM_Result_t dsAudioMgr_init()
2050 {
2051  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsAudioPortInit, _dsAudioPortInit);
2052  IARM_BUS_Lock(lock);
2053  try
2054  {
2055  /* Get the AudioModesettings FOR HDMI from Persistence */
2056  std::string _AudioModeSettings("STEREO");
2057  _AudioModeSettings = device::HostPersistence::getInstance().getProperty("HDMI0.AudioMode",_AudioModeSettings);
2058  __TIMESTAMP();printf("The HDMI Audio Mode Setting on startup is %s \r\n",_AudioModeSettings.c_str());
2059  if (_AudioModeSettings.compare("SURROUND") == 0)
2060  {
2061  _srv_HDMI_Audiomode = dsAUDIO_STEREO_SURROUND;
2062  }
2063  else if (_AudioModeSettings.compare("PASSTHRU") == 0)
2064  {
2065  _srv_HDMI_Audiomode = dsAUDIO_STEREO_PASSTHRU;
2066  }
2067  else if (_AudioModeSettings.compare("DOLBYDIGITAL") == 0)
2068  {
2069  _srv_HDMI_Audiomode = dsAUDIO_STEREO_DD;
2070  }
2071  else if (_AudioModeSettings.compare("DOLBYDIGITALPLUS") == 0)
2072  {
2073  _srv_HDMI_Audiomode = dsAUDIO_STEREO_DDPLUS;
2074  }
2075  else
2076  {
2077  _srv_HDMI_Audiomode = dsAUDIO_STEREO_STEREO;
2078  }
2079 
2080  /* Get the AutoModesettings FOR HDMI from Persistence */
2081  /* If HDMI persistence is surround, Auto defaults to true */
2082  std::string _AudioModeAuto("FALSE");
2083 
2084  #if 0
2085  /*
2086  Commenting this to fix the persistent settings
2087  Audio mode should not be forced to Auto
2088  To enabale this we need to change the DS Mgr implementation
2089  which reads the _dsGetStereoMode to know the persistent value...*/
2090  if (_srv_HDMI_Audiomode == dsAUDIO_STEREO_SURROUND)
2091  {
2092  _AudioModeAuto = "TRUE";
2093  }
2094  #endif
2095 
2096  try {
2097  _AudioModeAuto = device::HostPersistence::getInstance().getProperty("HDMI0.AudioMode.AUTO",_AudioModeAuto);
2098  }
2099  catch(...) {
2100  _AudioModeAuto = false;
2101  }
2102  std::string _ARCAudioModeAuto("FALSE");
2103  std::string _SPDIFAudioModeAuto("FALSE");
2104  try {
2105  _ARCAudioModeAuto = device::HostPersistence::getInstance().getProperty("HDMI_ARC0.AudioMode.AUTO");
2106  }
2107  catch(...) {
2108  try {
2109  printf("HDMI_ARC0.AudioMode.AUTO not found in persistence store. Try system default\n");
2110  _ARCAudioModeAuto = device::HostPersistence::getInstance().getDefaultProperty("HDMI_ARC0.AudioMode.AUTO");
2111  }
2112  catch(...) {
2113  _ARCAudioModeAuto = "FALSE";
2114  }
2115 
2116  }
2117 
2118  try {
2119  _SPDIFAudioModeAuto = device::HostPersistence::getInstance().getProperty("SPDIF0.AudioMode.AUTO");
2120  }
2121  catch(...) {
2122  try {
2123  printf("SPDIF0.AudioMode.AUTO not found in persistence store. Try system default\n");
2124  _SPDIFAudioModeAuto = device::HostPersistence::getInstance().getDefaultProperty("SPDIF0.AudioMode.AUTO");
2125  }
2126  catch(...) {
2127  _SPDIFAudioModeAuto = "FALSE";
2128  }
2129  }
2130 
2131  if ((_AudioModeAuto.compare("TRUE") == 0) || (_ARCAudioModeAuto.compare("TRUE") == 0) || (_SPDIFAudioModeAuto.compare("TRUE") == 0))
2132  {
2133  _srv_AudioAuto = 1;
2134  }
2135  else
2136  {
2137  _srv_AudioAuto = 0;
2138  }
2139  __TIMESTAMP();printf("The HDMI Audio Auto Setting on startup is %s \r\n",_AudioModeAuto.c_str());
2140  __TIMESTAMP();printf("The HDMI ARC Audio Auto Setting on startup is %s \r\n",_ARCAudioModeAuto.c_str());
2141  __TIMESTAMP();printf("The SPDIF Audio Auto Setting on startup is %s \r\n",_SPDIFAudioModeAuto.c_str());
2142 
2143  /* Get the AudioModesettings for SPDIF from Persistence */
2144  std::string _SPDIFModeSettings("STEREO");
2145  _SPDIFModeSettings = device::HostPersistence::getInstance().getProperty("SPDIF0.AudioMode",_SPDIFModeSettings);
2146  __TIMESTAMP();printf("The SPDIF Audio Mode Setting on startup is %s \r\n",_SPDIFModeSettings.c_str());
2147  if (_SPDIFModeSettings.compare("SURROUND") == 0)
2148  {
2149  _srv_SPDIF_Audiomode = dsAUDIO_STEREO_SURROUND;
2150  }
2151  else if (_SPDIFModeSettings.compare("PASSTHRU") == 0)
2152  {
2153  _srv_SPDIF_Audiomode = dsAUDIO_STEREO_PASSTHRU;
2154  }
2155  else
2156  {
2157  _srv_SPDIF_Audiomode = dsAUDIO_STEREO_STEREO;
2158  }
2159  /* Get the AudioModesettings for HDMI_ARC from Persistence */
2160  std::string _ARCModeSettings("STEREO");
2161  _ARCModeSettings = device::HostPersistence::getInstance().getProperty("HDMI_ARC0.AudioMode",_ARCModeSettings);
2162  __TIMESTAMP();printf("The HDMI ARC Audio Mode Setting on startup is %s \r\n",_ARCModeSettings.c_str());
2163  if (_ARCModeSettings.compare("SURROUND") == 0)
2164  {
2165  _srv_HDMI_ARC_Audiomode = dsAUDIO_STEREO_SURROUND;
2166  }
2167  else if (_ARCModeSettings.compare("PASSTHRU") == 0)
2168  {
2169  _srv_HDMI_ARC_Audiomode = dsAUDIO_STEREO_PASSTHRU;
2170  }
2171  else
2172  {
2173  _srv_HDMI_ARC_Audiomode = dsAUDIO_STEREO_STEREO;
2174  }
2175  }
2176  catch(...)
2177  {
2178  printf("Exception in Getting the Audio settings on Startup..... \r\n");
2179  }
2180  if (!m_isPlatInitialized) {
2181  dsAudioPortInit();
2182  AudioConfigInit();
2183  }
2184  /*coverity[missing_lock] CID-19380 using Coverity Annotation to ignore error*/
2185  m_isPlatInitialized ++;
2186  {
2187  IARM_Bus_DSMgr_EventData_t audio_portstate_event_data;
2188  audio_portstate_event_data.data.AudioPortStateInfo.audioPortState = dsAUDIOPORT_STATE_INITIALIZED;
2189  printf("%s: AudioOutPort PortInitState:%d \r\n", __FUNCTION__, audio_portstate_event_data.data.AudioPortStateInfo.audioPortState);
2190  IARM_Bus_BroadcastEvent(IARM_BUS_DSMGR_NAME,
2191  (IARM_EventId_t)IARM_BUS_DSMGR_EVENT_AUDIO_PORT_STATE,
2192  (void *)&audio_portstate_event_data,
2193  sizeof(audio_portstate_event_data));
2194 
2195  }
2196 
2197  IARM_BUS_Unlock(lock); //CID:136568 - Data race condition
2198  return IARM_RESULT_SUCCESS;
2199 }
2200 
2201 
2202 
2203 IARM_Result_t dsAudioMgr_term()
2204 {
2205  return IARM_RESULT_SUCCESS;
2206 }
2207 
2208 IARM_Result_t _dsAudioPortInit(void *arg)
2209 {
2210  IARM_BUS_Lock(lock);
2211 
2212  if (!m_isInitialized) {
2213 
2214  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetAudioPort,_dsGetAudioPort);
2215  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetSupportedARCTypes,_dsGetSupportedARCTypes);
2216  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsAudioSetSAD,_dsAudioSetSAD);
2217  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsAudioEnableARC,_dsAudioEnableARC);
2218  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetStereoMode,_dsSetStereoMode);
2219  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetStereoMode,_dsGetStereoMode);
2220  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetStereoAuto,_dsSetStereoAuto);
2221  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetStereoAuto,_dsGetStereoAuto);
2222  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetAudioMute,_dsSetAudioMute);
2223  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsIsAudioMute,_dsIsAudioMute);
2224  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetAudioDucking,_dsSetAudioDucking);
2225  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetAudioLevel,_dsSetAudioLevel);
2226  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetAudioLevel,_dsGetAudioLevel);
2227  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetAudioGain,_dsSetAudioGain);
2228  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetAudioGain,_dsGetAudioGain);
2229  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetAudioFormat,_dsGetAudioFormat);
2230  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetEncoding,_dsGetEncoding);
2231  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsIsAudioMSDecode,_dsIsAudioMSDecode);
2232  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsIsAudioMS12Decode,_dsIsAudioMS12Decode);
2233 
2234  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsIsAudioPortEnabled,_dsIsAudioPortEnabled);
2235  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsEnableAudioPort,_dsEnableAudioPort);
2236 
2237  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetEnablePersist, _dsGetEnablePersist);
2238  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetEnablePersist, _dsSetEnablePersist);
2239 
2240  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsAudioPortTerm,_dsAudioPortTerm);
2241  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsEnableLEConfig,_dsEnableLEConfig);
2242  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetLEConfig,_dsGetLEConfig);
2243  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetAudioDelay, _dsSetAudioDelay);
2244  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetAudioDelay, _dsGetAudioDelay);
2245  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetAudioDelayOffset, _dsSetAudioDelayOffset);
2246  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetAudioDelayOffset, _dsGetAudioDelayOffset);
2247  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetSinkDeviceAtmosCapability, _dsGetSinkDeviceAtmosCapability);
2248  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetAudioAtmosOutputMode, _dsSetAudioAtmosOutputMode);
2249  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetAudioAtmosOutputMode, _dsSetAudioAtmosOutputMode);
2250  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetAudioCompression, _dsSetAudioCompression);
2251  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetAudioCompression, _dsGetAudioCompression);
2252  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetDialogEnhancement, _dsSetDialogEnhancement);
2253  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetDialogEnhancement, _dsGetDialogEnhancement);
2254  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetDolbyVolumeMode, _dsSetDolbyVolumeMode);
2255  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetDolbyVolumeMode , _dsGetDolbyVolumeMode);
2256  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetIntelligentEqualizerMode, _dsSetIntelligentEqualizerMode);
2257  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetIntelligentEqualizerMode, _dsGetIntelligentEqualizerMode);
2258  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetVolumeLeveller, _dsGetVolumeLeveller);
2259  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetVolumeLeveller, _dsSetVolumeLeveller);
2260  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetBassEnhancer, _dsGetBassEnhancer);
2261  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetBassEnhancer, _dsSetBassEnhancer);
2262  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsIsSurroundDecoderEnabled, _dsIsSurroundDecoderEnabled);
2263  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsEnableSurroundDecoder, _dsEnableSurroundDecoder);
2264  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetDRCMode, _dsGetDRCMode);
2265  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetDRCMode, _dsSetDRCMode);
2266  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetSurroundVirtualizer, _dsGetSurroundVirtualizer);
2267  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetSurroundVirtualizer, _dsSetSurroundVirtualizer);
2268  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetMISteering, _dsGetMISteering);
2269  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetMISteering, _dsSetMISteering);
2270  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetGraphicEqualizerMode, _dsGetGraphicEqualizerMode);
2271  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetGraphicEqualizerMode, _dsSetGraphicEqualizerMode);
2272  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetMS12AudioProfileList, _dsGetMS12AudioProfileList);
2273  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetMS12AudioProfile, _dsGetMS12AudioProfile);
2274  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetMS12AudioProfile, _dsSetMS12AudioProfile);
2275 
2276  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetAssociatedAudioMixing, _dsSetAssociatedAudioMixing);
2277  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetAssociatedAudioMixing, _dsGetAssociatedAudioMixing);
2278  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetFaderControl, _dsSetFaderControl);
2279  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetFaderControl, _dsGetFaderControl);
2280  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetPrimaryLanguage, _dsSetPrimaryLanguage);
2281  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetPrimaryLanguage, _dsGetPrimaryLanguage);
2282  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetSecondaryLanguage, _dsSetSecondaryLanguage);
2283  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetSecondaryLanguage, _dsGetSecondaryLanguage);
2284 
2285  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetAudioCapabilities,_dsGetAudioCapabilities);
2286  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetMS12Capabilities,_dsGetMS12Capabilities);
2287  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsAudioOutIsConnected, _dsAudioOutIsConnected);
2288  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetMS12SetttingsOverride, _dsSetMS12SetttingsOverride);
2289 
2290  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsResetDialogEnhancement,_dsResetDialogEnhancement);
2291  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsResetBassEnhancer,_dsResetBassEnhancer);
2292  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsResetSurroundVirtualizer,_dsResetSurroundVirtualizer);
2293  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsResetVolumeLeveller,_dsResetVolumeLeveller);
2294  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetHDMIARCPortId, _dsGetHDMIARCPortId);
2295 
2296  dsError_t eRet = _dsAudioOutRegisterConnectCB (_dsAudioOutPortConnectCB);
2297  if (dsERR_NONE != eRet) {
2298  printf ("%s: _dsAudioOutRegisterConnectCB eRet:%04x", __FUNCTION__, eRet);
2299  }
2300 
2301  eRet = _dsAudioFormatUpdateRegisterCB (_dsAudioFormatUpdateCB) ;
2302  if (dsERR_NONE != eRet) {
2303  printf ("%s: _dsAudioFormatUpdateRegisterCB eRet:%04x", __FUNCTION__, eRet);
2304  }
2305 
2306  m_isInitialized = 1;
2307  }
2308 
2309  if (!m_isPlatInitialized) {
2310  /* Nexus init, if any here */
2311  dsAudioPortInit();
2312  AudioConfigInit();
2313  }
2314  m_isPlatInitialized++;
2315 
2316 
2317  IARM_BUS_Unlock(lock);
2318 
2319  return IARM_RESULT_SUCCESS;
2320 
2321 }
2322 
2323 IARM_Result_t _dsGetAudioPort(void *arg)
2324 {
2325  _DEBUG_ENTER();
2326 
2327  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
2328  dsError_t ret = dsERR_NONE;
2329 
2330  IARM_BUS_Lock(lock);
2331 
2333 
2334  if (param != NULL)
2335  {
2336  printf("%s..%d-%d \r\n",__func__,param->type,param->index);
2337  ret = dsGetAudioPort(param->type, param->index, &param->handle);
2338  if(ret == dsERR_NONE) {
2339  result = IARM_RESULT_SUCCESS;
2340  }
2341  }
2342 
2343  IARM_BUS_Unlock(lock);
2344 
2345  return result;
2346 }
2347 
2348 
2349 
2350 IARM_Result_t _dsGetStereoMode(void *arg)
2351 {
2352  _DEBUG_ENTER();
2353 
2354  IARM_BUS_Lock(lock);
2355 
2356  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
2357  dsError_t ret = dsERR_NONE;
2359 
2360  if (param != NULL && param->toPersist && NULL != param->handle) {
2361  _GetAudioModeFromPersistent(arg);
2362  result = IARM_RESULT_SUCCESS;
2363  }
2364  else if (param != NULL && NULL != param->handle)
2365  {
2366  /* In Auto Mode, get the effective mode */
2367  if (_srv_AudioAuto) {
2369  ret = dsGetStereoMode(param->handle, &stereoMode);
2370  if(ret == dsERR_NONE) {
2371  result = IARM_RESULT_SUCCESS;
2372  }
2373  param->mode = stereoMode;
2374  }
2375  else {
2376  dsAudioPortType_t _APortType = _GetAudioPortType(param->handle);
2377  if (_APortType == dsAUDIOPORT_TYPE_SPDIF)
2378  {
2379  param->mode = _srv_SPDIF_Audiomode;
2380  printf("The SPDIF Port Audio Settings Mode is %d \r\n",param->mode);
2381  }
2382  else if (_APortType == dsAUDIOPORT_TYPE_HDMI) {
2383  param->mode = _srv_HDMI_Audiomode;
2384  printf("The HDMI Port Audio Settings Mode is %d \r\n",param->mode);
2385  }
2386  else if (_APortType == dsAUDIOPORT_TYPE_HDMI_ARC) {
2387  param->mode = _srv_HDMI_ARC_Audiomode;
2388  printf("The HDMI ARC Port Audio Settings Mode is %d \r\n",param->mode);
2389  }
2390 
2391  result = IARM_RESULT_SUCCESS;
2392  }
2393  }
2394 
2395  IARM_BUS_Unlock(lock);
2396 
2397  return result;
2398 }
2399 
2400 
2401 IARM_Result_t _dsSetStereoMode(void *arg)
2402 {
2403  _DEBUG_ENTER();
2404  IARM_Bus_DSMgr_EventData_t eventData;
2405 
2406  IARM_BUS_Lock(lock);
2407 
2408  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
2409  dsError_t ret = dsERR_NONE;
2411  if (NULL != param->handle) {
2412  ret = dsSetStereoMode(param->handle, param->mode);
2413  param->rpcResult = ret;
2414  }
2415  else {
2416  ret = dsERR_INVALID_PARAM;
2417  param->rpcResult = dsERR_INVALID_PARAM;
2418  }
2419 
2420  if (ret == dsERR_NONE)
2421  {
2422  dsAudioPortType_t _APortType = _GetAudioPortType(param->handle);
2423  try
2424  {
2425  if(param->mode == dsAUDIO_STEREO_STEREO)
2426  {
2427  __TIMESTAMP();printf("Setting Audio Mode STEREO with persistent value : %d \r\n",param->toPersist);
2428 
2429  if (_APortType == dsAUDIOPORT_TYPE_HDMI)
2430  {
2431  if (param->toPersist)
2432  device::HostPersistence::getInstance().persistHostProperty("HDMI0.AudioMode","STEREO");
2433 
2434  _srv_HDMI_Audiomode = dsAUDIO_STEREO_STEREO;
2435  }
2436  else if (_APortType == dsAUDIOPORT_TYPE_SPDIF)
2437  {
2438  if (param->toPersist)
2439  device::HostPersistence::getInstance().persistHostProperty("SPDIF0.AudioMode","STEREO");
2440 
2441  _srv_SPDIF_Audiomode = dsAUDIO_STEREO_STEREO;
2442  }
2443  else if (_APortType == dsAUDIOPORT_TYPE_HDMI_ARC)
2444  {
2445  if (param->toPersist)
2446  device::HostPersistence::getInstance().persistHostProperty("HDMI_ARC0.AudioMode","STEREO");
2447 
2448  _srv_HDMI_ARC_Audiomode = dsAUDIO_STEREO_STEREO;
2449  }
2450  eventData.data.Audioport.mode = dsAUDIO_STEREO_STEREO;
2451  eventData.data.Audioport.type = _APortType;
2452  IARM_Bus_BroadcastEvent(IARM_BUS_DSMGR_NAME,(IARM_EventId_t)IARM_BUS_DSMGR_EVENT_AUDIO_MODE,(void *)&eventData, sizeof(eventData));
2453 
2454  }
2455  else if(param->mode == dsAUDIO_STEREO_SURROUND)
2456  {
2457  __TIMESTAMP();printf("Setting Audio Mode SURROUND with persistent value %d \r\n",param->toPersist);
2458 
2459  if (_APortType == dsAUDIOPORT_TYPE_HDMI)
2460  {
2461  if (param->toPersist)
2462  device::HostPersistence::getInstance().persistHostProperty("HDMI0.AudioMode","SURROUND");
2463 
2464  _srv_HDMI_Audiomode = dsAUDIO_STEREO_SURROUND;
2465  }
2466  else if (_APortType == dsAUDIOPORT_TYPE_SPDIF)
2467  {
2468  if (param->toPersist)
2469  device::HostPersistence::getInstance().persistHostProperty("SPDIF0.AudioMode","SURROUND");
2470 
2471  _srv_SPDIF_Audiomode = dsAUDIO_STEREO_SURROUND;
2472  }
2473  else if (_APortType == dsAUDIOPORT_TYPE_HDMI_ARC)
2474  {
2475  if (param->toPersist)
2476  device::HostPersistence::getInstance().persistHostProperty("HDMI_ARC0.AudioMode","SURROUND");
2477 
2478  _srv_HDMI_ARC_Audiomode = dsAUDIO_STEREO_SURROUND;
2479  }
2480 
2481  eventData.data.Audioport.mode = dsAUDIO_STEREO_SURROUND;
2482  eventData.data.Audioport.type = _APortType;
2483  IARM_Bus_BroadcastEvent(IARM_BUS_DSMGR_NAME,(IARM_EventId_t)IARM_BUS_DSMGR_EVENT_AUDIO_MODE,(void *)&eventData, sizeof(eventData));
2484  }
2485  else if(param->mode == dsAUDIO_STEREO_DD)
2486  {
2487  __TIMESTAMP();printf("Setting Audio Mode Dolby Digital with persistent value %d \r\n",param->toPersist);
2488 
2489  if (_APortType == dsAUDIOPORT_TYPE_HDMI)
2490  {
2491  if (param->toPersist)
2492  device::HostPersistence::getInstance().persistHostProperty("HDMI0.AudioMode","DOLBYDIGITAL");
2493 
2494  _srv_HDMI_Audiomode = dsAUDIO_STEREO_DD;
2495  }
2496  eventData.data.Audioport.mode = dsAUDIO_STEREO_DD;
2497  eventData.data.Audioport.type = _APortType;
2498  IARM_Bus_BroadcastEvent(IARM_BUS_DSMGR_NAME,(IARM_EventId_t)IARM_BUS_DSMGR_EVENT_AUDIO_MODE,(void *)&eventData, sizeof(eventData));
2499  }
2500  else if(param->mode == dsAUDIO_STEREO_DDPLUS)
2501  {
2502  __TIMESTAMP();printf("Setting Audio Mode Dolby Digital Plus with persistent value %d \r\n",param->toPersist);
2503 
2504  if (_APortType == dsAUDIOPORT_TYPE_HDMI)
2505  {
2506  if (param->toPersist)
2507  device::HostPersistence::getInstance().persistHostProperty("HDMI0.AudioMode","DOLBYDIGITALPLUS");
2508 
2509  _srv_HDMI_Audiomode = dsAUDIO_STEREO_DDPLUS;
2510  }
2511  eventData.data.Audioport.mode = dsAUDIO_STEREO_DDPLUS;
2512  eventData.data.Audioport.type = _APortType;
2513  IARM_Bus_BroadcastEvent(IARM_BUS_DSMGR_NAME,(IARM_EventId_t)IARM_BUS_DSMGR_EVENT_AUDIO_MODE,(void *)&eventData, sizeof(eventData));
2514  }
2515  else if(param->mode == dsAUDIO_STEREO_PASSTHRU)
2516  {
2517  __TIMESTAMP();printf("Setting Audio Mode PASSTHRU with persistent value %d \r\n",param->toPersist);
2518 
2519  if (_APortType == dsAUDIOPORT_TYPE_HDMI)
2520  {
2521  if (param->toPersist)
2522  device::HostPersistence::getInstance().persistHostProperty("HDMI0.AudioMode","PASSTHRU");
2523  _srv_HDMI_Audiomode = dsAUDIO_STEREO_PASSTHRU;
2524  }
2525  else if (_APortType == dsAUDIOPORT_TYPE_SPDIF)
2526  {
2527  if (param->toPersist)
2528  device::HostPersistence::getInstance().persistHostProperty("SPDIF0.AudioMode","PASSTHRU");
2529  _srv_SPDIF_Audiomode = dsAUDIO_STEREO_PASSTHRU;
2530  }
2531  else if (_APortType == dsAUDIOPORT_TYPE_HDMI_ARC)
2532  {
2533  if (param->toPersist)
2534  device::HostPersistence::getInstance().persistHostProperty("HDMI_ARC0.AudioMode","PASSTHRU");
2535 
2536  _srv_HDMI_ARC_Audiomode = dsAUDIO_STEREO_PASSTHRU;
2537  }
2538 
2539  eventData.data.Audioport.mode = dsAUDIO_STEREO_PASSTHRU;
2540  eventData.data.Audioport.type = _APortType;
2541  IARM_Bus_BroadcastEvent(IARM_BUS_DSMGR_NAME,(IARM_EventId_t)IARM_BUS_DSMGR_EVENT_AUDIO_MODE,(void *)&eventData, sizeof(eventData));
2542 
2543  }
2544 
2545  result = IARM_RESULT_SUCCESS;
2546  }
2547  catch(...)
2548  {
2549  printf("Error in Setting audio mode... \r\n");
2550  }
2551 
2552  }
2553 
2554  IARM_BUS_Unlock(lock);
2555 
2556  return result;
2557 }
2558 
2559 IARM_Result_t _dsGetStereoAuto(void *arg)
2560 {
2561  _DEBUG_ENTER();
2562 
2563  IARM_BUS_Lock(lock);
2564 
2566 
2567  if (param != NULL)
2568  {
2569  param->autoMode = (_srv_AudioAuto ? 1 : 0);
2570  }
2571 
2572  IARM_BUS_Unlock(lock);
2573 
2574  return IARM_RESULT_SUCCESS;
2575 }
2576 
2577 IARM_Result_t _dsSetStereoAuto(void *arg)
2578 {
2579  _DEBUG_ENTER();
2580  IARM_BUS_Lock(lock);
2581 
2582  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
2584 
2585  if(param == NULL)
2586  {
2587  printf("Param is null\r\n");
2588  }
2589 
2590  dsAudioPortType_t _APortType = _GetAudioPortType(param->handle);
2591 
2592  if (param->toPersist) {
2593  switch(_APortType) {
2594  case dsAUDIOPORT_TYPE_HDMI:
2595  device::HostPersistence::getInstance().persistHostProperty("HDMI0.AudioMode.AUTO", param->autoMode ? "TRUE" : "FALSE");
2596  break;
2597 
2598  case dsAUDIOPORT_TYPE_HDMI_ARC:
2599  device::HostPersistence::getInstance().persistHostProperty("HDMI_ARC0.AudioMode.AUTO", param->autoMode ? "TRUE" : "FALSE");
2600  break;
2601 
2603  device::HostPersistence::getInstance().persistHostProperty("SPDIF0.AudioMode.AUTO", param->autoMode ? "TRUE" : "FALSE");
2604  break;
2605 
2606  default:
2607  break;
2608  }
2609  }
2610 
2611  if ((_APortType == dsAUDIOPORT_TYPE_HDMI_ARC) || (_APortType == dsAUDIOPORT_TYPE_SPDIF)) {
2612  typedef dsError_t (*dsSetStereoAuto_t)(intptr_t handle, int autoMode);
2613  static dsSetStereoAuto_t func = 0;
2614  if (func == 0) {
2615  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
2616  if (dllib) {
2617  func = (dsSetStereoAuto_t) dlsym(dllib, "dsSetStereoAuto");
2618  if (func) {
2619  printf("dsSetStereoAuto_t(int, int *) is defined and loaded\r\n");
2620  }
2621  else {
2622  printf("dsSetStereoAuto_t(int, int *) is not defined\r\n");
2623  }
2624  dlclose(dllib);
2625  }
2626  else {
2627  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
2628  }
2629  }
2630 
2631  if (func != 0 && param != NULL)
2632  {
2633  if (func(param->handle, param->autoMode) == dsERR_NONE)
2634  {
2635  result = IARM_RESULT_SUCCESS;
2636  }
2637  }
2638  }
2639 
2640  _srv_AudioAuto = param->autoMode ? 1 : 0;
2641 
2642  IARM_BUS_Unlock(lock);
2643  return IARM_RESULT_SUCCESS;
2644 }
2645 
2646 IARM_Result_t _dsSetAudioDucking(void *arg)
2647 {
2648  _DEBUG_ENTER();
2649 
2650  IARM_BUS_Lock(lock);
2651  int volume = 0;
2652  bool portEnabled = false;
2654  IARM_Bus_DSMgr_EventData_t eventData;
2655  printf("%s action : %d type :%d val :%d m_volumeLevel:%f \n",__FUNCTION__,param->action,param->type,param->level,m_volumeLevel );
2656 
2657  dsError_t ret = dsIsAudioPortEnabled(param->handle, &portEnabled);
2658  if (ret == dsERR_NONE) {
2659  printf("%s failed dsIsAudioPortEnabled\n",__FUNCTION__);
2660  }
2661 
2662  if(m_MuteStatus || !portEnabled)
2663  {
2664  printf("%s mute on/port disabled so ignore the duckig request\n",__FUNCTION__);
2665  IARM_BUS_Unlock(lock);
2666  return IARM_RESULT_SUCCESS;
2667  }
2668 
2669  if(param->action == dsAUDIO_DUCKINGACTION_START)
2670  {
2671  m_isDuckingInProgress = true;
2672  if(param->type == dsAUDIO_DUCKINGTYPE_RELATIVE )
2673  {
2674  volume = (m_volumeLevel * param->level) / 100;
2675  }
2676  else
2677  {
2678  if(param->level > m_volumeLevel)
2679  {
2680  volume = m_volumeLevel;
2681  }
2682  else
2683  {
2684  volume = param->level;
2685  }
2686  }
2687  }
2688  else
2689  {
2690  m_isDuckingInProgress = false;
2691  volume = m_volumeLevel;
2692  }
2693  printf(":%s adjusted volume volume :%d m_volumeDuckingLevel :%d\n",__FUNCTION__,volume,m_volumeDuckingLevel );
2694 
2695  // apply volume to hal layer
2696  dsAudioPortType_t _APortType = _GetAudioPortType(param->handle);
2697 
2698  typedef dsError_t (*dsSetAudioLevel_t)(intptr_t handle, float level);
2699  static dsSetAudioLevel_t func = 0;
2700  if (func == 0)
2701  {
2702  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
2703  if (dllib) {
2704  func = (dsSetAudioLevel_t) dlsym(dllib, "dsSetAudioLevel");
2705  if (func) {
2706  printf("dsSetAudioLevel_t(int, float ) is defined and loaded \r\n");
2707  }
2708  else {
2709  printf("dsSetAudioLevel_t(int, float ) is not defined \r\n");
2710  }
2711  dlclose(dllib);
2712  }
2713  else {
2714  printf("Opening RDK_DSHAL_NAME [%s] failed \r\n", RDK_DSHAL_NAME);
2715  }
2716  }
2717  if (func != 0 )
2718  {
2719  func(param->handle, volume);
2720  }
2721 
2722  if(volume != m_volumeDuckingLevel)
2723  {
2724  m_volumeDuckingLevel = volume;
2725 
2727  if (_APortType == dsAUDIOPORT_TYPE_SPDIF)
2728  {
2729  mode = _srv_SPDIF_Audiomode;
2730  }
2731  else if (_APortType == dsAUDIOPORT_TYPE_HDMI) {
2732  mode = _srv_HDMI_Audiomode;
2733  }
2734  printf("The Port type is :%d Audio Settings Mode is %d \r\n",_APortType, mode);
2735 
2736  if(mode == dsAUDIO_STEREO_PASSTHRU && volume != 100)
2737  {
2738  eventData.data.AudioLevelInfo.level = 0;
2739  printf(" IARM_BUS_DSMGR_EVENT_AUDIO_LEVEL_CHANGED PASSTHRU mode volume:%d \n",eventData.data.AudioLevelInfo.level);
2740  }
2741  else
2742  {
2743  eventData.data.AudioLevelInfo.level = volume;
2744  printf(" IARM_BUS_DSMGR_EVENT_AUDIO_LEVEL_CHANGED volume:%d \n ",eventData.data.AudioLevelInfo.level);
2745  }
2746  IARM_Bus_BroadcastEvent(IARM_BUS_DSMGR_NAME,(IARM_EventId_t)IARM_BUS_DSMGR_EVENT_AUDIO_LEVEL_CHANGED,(void *)&eventData, sizeof(eventData));
2747  }
2748  IARM_BUS_Unlock(lock);
2749 
2750  return IARM_RESULT_SUCCESS;
2751 }
2752 
2753 IARM_Result_t _dsGetAudioGain(void *arg)
2754 {
2755 #ifndef RDK_DSHAL_NAME
2756 #warning "RDK_DSHAL_NAME is not defined"
2757 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
2758 #endif
2759  _DEBUG_ENTER();
2760  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
2761  IARM_BUS_Lock(lock);
2762 
2763  typedef dsError_t (*dsGetAudioGain_t)(intptr_t handle, float *gain);
2764  static dsGetAudioGain_t func = 0;
2765  if (func == 0) {
2766  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
2767  if (dllib) {
2768  func = (dsGetAudioGain_t) dlsym(dllib, "dsGetAudioGain");
2769  if (func) {
2770  printf("dsGetAudioGain_t(int, float *) is defined and loaded\r\n");
2771  }
2772  else {
2773  printf("dsGetAudioGain_t(int, float *) is not defined\r\n");
2774  }
2775  dlclose(dllib);
2776  }
2777  else {
2778  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
2779  }
2780  }
2781 
2782  dsAudioGainParam_t *param = (dsAudioGainParam_t *)arg;
2783 
2784  if (func != 0 && param != NULL)
2785  {
2786  float gain = 0;
2787  param->gain = 0;
2788  if (func(param->handle, &gain) == dsERR_NONE)
2789  {
2790  param->gain = gain;
2791  result = IARM_RESULT_SUCCESS;
2792  }
2793  }
2794 
2795  IARM_BUS_Unlock(lock);
2796  return result;
2797 }
2798 
2799 IARM_Result_t _dsGetAudioLevel(void *arg)
2800 {
2801 #ifndef RDK_DSHAL_NAME
2802 #warning "RDK_DSHAL_NAME is not defined"
2803 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
2804 #endif
2805  _DEBUG_ENTER();
2806  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
2807  IARM_BUS_Lock(lock);
2808 
2809  typedef dsError_t (*dsGetAudioLevel_t)(intptr_t handle, float *level);
2810  static dsGetAudioLevel_t func = 0;
2811  if (func == 0) {
2812  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
2813  if (dllib) {
2814  func = (dsGetAudioLevel_t) dlsym(dllib, "dsGetAudioLevel");
2815  if (func) {
2816  printf("dsGetAudioLevel_t(int, float *) is defined and loaded\r\n");
2817  }
2818  else {
2819  printf("dsGetAudioLevel_t(int, float *) is not defined\r\n");
2820  }
2821  dlclose(dllib);
2822  }
2823  else {
2824  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
2825  }
2826  }
2827 
2829 
2830  if (func != 0 && param != NULL)
2831  {
2832  float level = 0;
2833  param->level = 0;
2834  if (func(param->handle, &level) == dsERR_NONE)
2835  {
2836  param->level = level;
2837  result = IARM_RESULT_SUCCESS;
2838  }
2839  }
2840 
2841  IARM_BUS_Unlock(lock);
2842  return result;
2843 }
2844 
2845 IARM_Result_t _dsSetAudioGain(void *arg)
2846 {
2847 #ifndef RDK_DSHAL_NAME
2848 #warning "RDK_DSHAL_NAME is not defined"
2849 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
2850 #endif
2851  _DEBUG_ENTER();
2852  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
2853  IARM_BUS_Lock(lock);
2854 
2855  typedef dsError_t (*dsSetAudioGain_t)(intptr_t handle, float gain);
2856  static dsSetAudioGain_t func = 0;
2857  if (func == 0) {
2858  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
2859  if (dllib) {
2860  func = (dsSetAudioGain_t) dlsym(dllib, "dsSetAudioGain");
2861  if (func) {
2862  printf("dsSetAudioGain_t(int, float ) is defined and loaded\r\n");
2863  }
2864  else {
2865  printf("dsSetAudioGain_t(int, float ) is not defined\r\n");
2866  }
2867  dlclose(dllib);
2868  }
2869  else {
2870  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
2871  }
2872  }
2873 
2874  dsAudioGainParam_t *param = (dsAudioGainParam_t *)arg;
2875 
2876  if (func != 0 && param != NULL)
2877  {
2878  if (func(param->handle, param->gain) == dsERR_NONE)
2879  {
2880 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
2881  std::string _AudioGain = std::to_string(param->gain);
2882  dsAudioPortType_t _APortType = _GetAudioPortType(param->handle);
2883  switch(_APortType) {
2885  printf("%s: port: %s , persist audio gain: %f\n",__func__,"SPDIF0", param->gain);
2886  device::HostPersistence::getInstance().persistHostProperty("SPDIF0.audio.Gain",_AudioGain);
2887  break;
2888  case dsAUDIOPORT_TYPE_HDMI:
2889  printf("%s: port: %s , persist audio gain: %f\n",__func__,"HDMI0", param->gain);
2890  device::HostPersistence::getInstance().persistHostProperty("HDMI0.audio.Gain",_AudioGain);
2891  break;
2893  printf("%s: port: %s , persist audio gain: %f\n",__func__,"SPEAKER0", param->gain);
2894  device::HostPersistence::getInstance().persistHostProperty("SPEAKER0.audio.Gain",_AudioGain);
2895  break;
2896  default:
2897  break;
2898  }
2899 #endif
2900  result = IARM_RESULT_SUCCESS;
2901  }
2902  }
2903 
2904  IARM_BUS_Unlock(lock);
2905 
2906  return result;
2907 
2908 }
2909 
2910 IARM_Result_t _dsSetAudioLevel(void *arg)
2911 {
2912 #ifndef RDK_DSHAL_NAME
2913 #warning "RDK_DSHAL_NAME is not defined"
2914 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
2915 #endif
2916  _DEBUG_ENTER();
2917  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
2918  IARM_BUS_Lock(lock);
2919 
2920  typedef dsError_t (*dsSetAudioLevel_t)(intptr_t handle, float level);
2921  static dsSetAudioLevel_t func = 0;
2922  if (func == 0) {
2923  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
2924  if (dllib) {
2925  func = (dsSetAudioLevel_t) dlsym(dllib, "dsSetAudioLevel");
2926  if (func) {
2927  printf("dsSetAudioLevel_t(int, float ) is defined and loaded\r\n");
2928  }
2929  else {
2930  printf("dsSetAudioLevel_t(int, float ) is not defined\r\n");
2931  }
2932  dlclose(dllib);
2933  }
2934  else {
2935  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
2936  }
2937  }
2938 
2940 
2941  if (func != 0 && param != NULL)
2942  {
2943  printf("_dsSetAudioLevel param->level :%f m_isDuckingInProgress :%d \n",param->level,m_isDuckingInProgress);
2944  if (m_isDuckingInProgress || func(param->handle, param->level) == dsERR_NONE)
2945  {
2946  m_volumeLevel = (int) param->level;
2947 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
2948  std::string _AudioLevel = std::to_string(param->level);
2949  dsAudioPortType_t _APortType = _GetAudioPortType(param->handle);
2950  switch(_APortType) {
2952  printf("%s: port: %s , persist audio level: %f\n",__func__,"SPDIF0", param->level);
2953  device::HostPersistence::getInstance().persistHostProperty("SPDIF0.audio.Level",_AudioLevel);
2954  break;
2955  case dsAUDIOPORT_TYPE_HDMI:
2956  printf("%s: port: %s , persist audio level: %f\n",__func__,"HDMI0", param->level);
2957  device::HostPersistence::getInstance().persistHostProperty("HDMI0.audio.Level",_AudioLevel);
2958  break;
2960  printf("%s: port: %s , persist audio level: %f\n",__func__,"SPEAKER0", param->level);
2961  device::HostPersistence::getInstance().persistHostProperty("SPEAKER0.audio.Level",_AudioLevel);
2962  break;
2964  printf("%s: port: %s , persist audio level: %f\n",__func__,"HEADPHONE0", param->level);
2965  device::HostPersistence::getInstance().persistHostProperty("HEADPHONE0.audio.Level",_AudioLevel);
2966  break;
2967  default:
2968  break;
2969  }
2970 #endif
2971  result = IARM_RESULT_SUCCESS;
2972  }
2973  }
2974 
2975  IARM_BUS_Unlock(lock);
2976 
2977  return result;
2978 
2979 }
2980 
2981 IARM_Result_t _dsSetAudioMute(void *arg)
2982 {
2983  _DEBUG_ENTER();
2984 
2985  IARM_BUS_Lock(lock);
2986 
2987  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
2988  dsError_t ret = dsERR_NONE;
2989 
2991  ret = dsSetAudioMute(param->handle, param->mute);
2992  if (ret == dsERR_NONE) {
2993  m_MuteStatus = param->mute;
2994 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
2995  std::string _mute = param->mute ? "TRUE" : "FALSE";
2996  dsAudioPortType_t _APortType = _GetAudioPortType(param->handle);
2997  switch(_APortType) {
2999  printf("%s: port: %s , persist audio mute: %s\n",__func__,"SPDIF0", param->mute ? "TRUE" : "FALSE");
3000  device::HostPersistence::getInstance().persistHostProperty("SPDIF0.audio.mute", _mute);
3001  break;
3002  case dsAUDIOPORT_TYPE_HDMI:
3003  printf("%s: port: %s , persist audio mute: %s\n",__func__,"HDMI0", param->mute ? "TRUE" : "FALSE");
3004  device::HostPersistence::getInstance().persistHostProperty("HDMI0.audio.mute", _mute);
3005  break;
3007  printf("%s: port: %s , persist audio mute: %s\n",__func__,"SPEAKER0", param->mute ? "TRUE" : "FALSE");
3008  device::HostPersistence::getInstance().persistHostProperty("SPEAKER0.audio.mute", _mute);
3009  break;
3011  printf("%s: port: %s , persist audio mute: %s\n",__func__,"HEADPHONE0", param->mute ? "TRUE" : "FALSE");
3012  device::HostPersistence::getInstance().persistHostProperty("HEADPHONE0.audio.mute", _mute);
3013  break;
3014  default:
3015  break;
3016  }
3017 #endif
3018  result = IARM_RESULT_SUCCESS;
3019  }
3020 
3021  IARM_BUS_Unlock(lock);
3022 
3023  return result;
3024 }
3025 
3026 
3027 IARM_Result_t _dsIsAudioMute(void *arg)
3028 {
3029  _DEBUG_ENTER();
3030 
3031  IARM_BUS_Lock(lock);
3032 
3033  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
3034 
3036  bool muted = false;
3037 
3038  dsError_t ret = dsIsAudioMute(param->handle, &muted);
3039  if (ret == dsERR_NONE) {
3040  param->mute = muted;
3041 
3042 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
3043  std::string isMuteKey("");
3044  std::string _mute("FALSE");
3045  dsAudioPortType_t _APortType = _GetAudioPortType(param->handle);
3046  switch(_APortType) {
3048  isMuteKey.append("SPDIF0.audio.mute");
3049  break;
3050  case dsAUDIOPORT_TYPE_HDMI:
3051  isMuteKey.append("HDMI0.audio.mute");
3052  break;
3054  isMuteKey.append("SPEAKER0.audio.mute");
3055  break;
3057  isMuteKey.append("HEADPHONE0.audio.mute");
3058  break;
3059  default:
3060  break;
3061  }
3062  try {
3063  _mute = device::HostPersistence::getInstance().getProperty(isMuteKey);
3064  }
3065  catch(...) {
3066  printf("%s : Exception in getting the %s from persistence storage\n", __FUNCTION__, isMuteKey.c_str());
3067  _mute = "FALSE";
3068  }
3069  if ("TRUE" == _mute) {
3070  param->mute = true;
3071  }
3072  printf("%s: persist value:%s for :%s\n", __FUNCTION__, _mute.c_str(), isMuteKey.c_str());
3073 #endif //DS_AUDIO_SETTINGS_PERSISTENCE end
3074 
3075  result = IARM_RESULT_SUCCESS;
3076  }
3077 
3078  IARM_BUS_Unlock(lock);
3079 
3080  return result;
3081 }
3082 
3083 
3084 IARM_Result_t _dsIsAudioPortEnabled(void *arg)
3085 {
3086  _DEBUG_ENTER();
3087 
3088  IARM_BUS_Lock(lock);
3089 
3090  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
3091 
3093  bool enabled = false;
3094 
3095  dsError_t ret = dsIsAudioPortEnabled(param->handle, &enabled);
3096  if (ret == dsERR_NONE) {
3097  param->enabled = enabled;
3098  result = IARM_RESULT_SUCCESS;
3099  }
3100  printf("%s : returned ret: %04x enabled: %s\n", __FUNCTION__, ret, param->enabled? "TRUE":"FALSE");
3101 
3102  IARM_BUS_Unlock(lock);
3103 
3104  return result;
3105 }
3106 
3107 
3108 IARM_Result_t _dsEnableAudioPort(void *arg)
3109 {
3110  _DEBUG_ENTER();
3111  IARM_BUS_Lock(lock);
3112 
3113  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
3114  dsError_t ret = dsERR_NONE;
3115 
3117  ret = dsEnableAudioPort(param->handle, param->enabled);
3118  if(ret == dsERR_NONE) {
3119  result = IARM_RESULT_SUCCESS;
3120  }
3121 
3122  std::string isEnabledAudioPortKey("audio.");
3123  isEnabledAudioPortKey.append (param->portName);
3124  isEnabledAudioPortKey.append (".isEnabled");
3125 
3126 
3127  /*Ensure settings is enabled properly in HAL*/
3128  bool bAudioPortEnableVerify = false;
3129  ret = dsIsAudioPortEnabled (param->handle, &bAudioPortEnableVerify);
3130  if(dsERR_NONE == ret) {
3131  if (bAudioPortEnableVerify != param->enabled) {
3132  printf("%s : %s Audio port status verification failed. param->enabled: %d bAudioPortEnableVerify:%d\n",
3133  __FUNCTION__, isEnabledAudioPortKey.c_str(), param->enabled, bAudioPortEnableVerify);
3134  }
3135  else {
3136  printf("%s : %s Audio port status verification passed. status %d\n", __FUNCTION__, isEnabledAudioPortKey.c_str(), param->enabled);
3137  }
3138  }
3139  else {
3140  printf("%s : %s Audio port status:%s verification step: dsIsAudioPortEnabled call failed\n",
3141  __FUNCTION__, isEnabledAudioPortKey.c_str(), param->enabled? "TRUE":"FALSE");
3142  }
3143 
3144  IARM_BUS_Unlock(lock);
3145 
3146  return result;
3147 }
3148 
3149 IARM_Result_t _dsGetEnablePersist(void *arg)
3150 {
3151  _DEBUG_ENTER();
3152 
3153  IARM_BUS_Lock(lock);
3154 
3155  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
3156 
3158  //By default all the ports are enabled.
3159  bool enabled = true;
3160 
3161  std::string isEnabledAudioPortKey("audio.");
3162  isEnabledAudioPortKey.append (param->portName);
3163  isEnabledAudioPortKey.append (".isEnabled");
3164  std::string _AudioPortEnable("TRUE");
3165 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
3166  try {
3167  _AudioPortEnable = device::HostPersistence::getInstance().getProperty(isEnabledAudioPortKey);
3168  }
3169  catch(...) {
3170  try {
3171  printf("Init: %s : %s port enable settings not found in persistence store. Try system default\n",__FUNCTION__, isEnabledAudioPortKey.c_str());
3172  _AudioPortEnable = device::HostPersistence::getInstance().getDefaultProperty(isEnabledAudioPortKey);
3173  }
3174  catch(...) {
3175  /*By default enable all the ports*/
3176  _AudioPortEnable = "TRUE";
3177  }
3178  }
3179  if ("FALSE" == _AudioPortEnable) {
3180  printf("%s: persist dsEnableAudioPort value: _AudioPortEnable:%s:\n", __FUNCTION__, _AudioPortEnable.c_str());
3181  enabled = false;
3182  }
3183  else {
3184  printf("%s: persist dsEnableAudioPort value: _AudioPortEnable:%s:\n", __FUNCTION__, _AudioPortEnable.c_str());
3185  enabled = true;
3186  }
3187 
3188 #endif //DS_AUDIO_SETTINGS_PERSISTENCE end
3189 
3190  param->enabled = enabled;
3191  result = IARM_RESULT_SUCCESS;
3192  printf("%s: persist dsEnableAudioPort value: %s for the port %s AudioPortEnable: %s result:%d \n",
3193  __FUNCTION__, param->enabled? "TRUE":"FALSE", isEnabledAudioPortKey.c_str(), _AudioPortEnable.c_str(), result);
3194 
3195  IARM_BUS_Unlock(lock);
3196 
3197  return result;
3198 }
3199 
3200 
3201 IARM_Result_t _dsSetEnablePersist(void *arg)
3202 {
3203  _DEBUG_ENTER();
3204  IARM_BUS_Lock(lock);
3205 
3206  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
3207  dsError_t ret = dsERR_NONE;
3208 
3210  result = IARM_RESULT_SUCCESS;
3211 
3212  std::string isEnabledAudioPortKey("audio.");
3213  isEnabledAudioPortKey.append (param->portName);
3214  isEnabledAudioPortKey.append (".isEnabled");
3215 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
3216  printf("%s: persist dsEnableAudioPort value: %s for the port %s\n", __FUNCTION__, param->enabled? "TRUE":"FALSE", isEnabledAudioPortKey.c_str());
3217  device::HostPersistence::getInstance().persistHostProperty(isEnabledAudioPortKey.c_str(), param->enabled? ("TRUE"):("FALSE"));
3218 #endif //DS_AUDIO_SETTINGS_PERSISTENCE end
3219 
3220  IARM_BUS_Unlock(lock);
3221 
3222  return result;
3223 }
3224 
3225 
3226 IARM_Result_t _dsAudioPortTerm(void *arg)
3227 {
3228  _DEBUG_ENTER();
3229 
3230  IARM_BUS_Lock(lock);
3231 
3232  m_isPlatInitialized--;
3233 
3234  if (0 == m_isPlatInitialized)
3235  {
3236  dsError_t ret = dsAudioPortTerm();
3237  if(ret != dsERR_NONE) {
3238  printf("_dsAudioPortTerm is not success\r\n");
3239  }
3240  }
3241 
3242  IARM_BUS_Unlock(lock);
3243 
3244  return IARM_RESULT_SUCCESS;
3245 }
3246 
3247 
3248 IARM_Result_t _dsGetAudioFormat(void *arg)
3249 {
3250  _DEBUG_ENTER();
3251  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
3252  IARM_BUS_Lock(lock);
3253 
3254  typedef dsError_t (*dsGetAudioFormat_t)(intptr_t handle, dsAudioFormat_t *audioFormat);
3255  static dsGetAudioFormat_t func = 0;
3256  if (func == 0) {
3257  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
3258  if (dllib) {
3259  func = (dsGetAudioFormat_t) dlsym(dllib, "dsGetAudioFormat");
3260  if (func) {
3261  printf("dsGetAudioFormat_t(int, dsAudioFormat_t *) is defined and loaded\r\n");
3262  }
3263  else {
3264  printf("dsGetAudioFormat_t(int, dsAudioFormat_t *) is not defined\r\n");
3265  }
3266  dlclose(dllib);
3267  }
3268  else {
3269  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
3270  }
3271  }
3272 
3274 
3275  if (func != 0 && param != NULL)
3276  {
3277  dsAudioFormat_t aFormat = dsAUDIO_FORMAT_NONE;
3278  param->audioFormat = dsAUDIO_FORMAT_NONE;
3279 
3280  if (func(param->handle, &aFormat) == dsERR_NONE)
3281  {
3282  param->audioFormat = aFormat;
3283  result = IARM_RESULT_SUCCESS;
3284  }
3285  }
3286 
3287  IARM_BUS_Unlock(lock);
3288  return result;
3289 }
3290 
3291 
3292 IARM_Result_t _dsGetEncoding(void *arg)
3293 {
3294  _DEBUG_ENTER();
3295 
3296  IARM_BUS_Lock(lock);
3297 
3298  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
3299  dsError_t ret = dsERR_NONE;
3300 
3302 
3303  if (param != NULL)
3304  {
3305 
3306  dsAudioEncoding_t _encoding = dsAUDIO_ENC_NONE;
3307  ret = dsGetAudioEncoding(param->handle, &_encoding);
3308 
3309  if(ret == dsERR_NONE) {
3310  result = IARM_RESULT_SUCCESS;
3311  }
3312  param->encoding = _encoding;
3313 
3314 
3315  __TIMESTAMP();printf("param->encoding = %d\r\n",_encoding);
3316 
3317  }
3318 
3319  IARM_BUS_Unlock(lock);
3320 
3321  return result;
3322 }
3323 
3324 static dsAudioPortType_t _GetAudioPortType(intptr_t handle)
3325 {
3326  int numPorts,i;
3327  intptr_t halhandle = 0;
3328 
3329  numPorts = dsUTL_DIM(kSupportedPortTypes);
3330 
3331  for(i=0; i< numPorts; i++)
3332  {
3333  if(dsGetAudioPort (kPorts[i].id.type, kPorts[i].id.index, &halhandle) == dsERR_NONE) {
3334  if (handle == halhandle)
3335  {
3336  return kPorts[i].id.type;
3337  }
3338  }
3339  }
3340  __TIMESTAMP();printf("Error: The Requested Audio Port is not part of Platform Port Configuration \r\n");
3341  return dsAUDIOPORT_TYPE_MAX;
3342 }
3343 
3344 
3345 IARM_Result_t _dsIsAudioMSDecode(void *arg)
3346 {
3347 
3348  IARM_BUS_Unlock(lock);
3349 
3350 #ifndef RDK_DSHAL_NAME
3351  #warning "RDK_DSHAL_NAME is not defined"
3352  #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
3353 #endif
3354  _DEBUG_ENTER();
3355 
3356  IARM_BUS_Lock(lock);
3357 
3358  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
3359  typedef dsError_t (*dsIsAudioMSDecode_t)(intptr_t handle, bool *HasMS11Decode);
3360  static dsIsAudioMSDecode_t func = NULL;
3361  if (func == NULL) {
3362  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
3363  if (dllib) {
3364  func = (dsIsAudioMSDecode_t) dlsym(dllib, "dsIsAudioMSDecode");
3365  if (func) {
3366  __TIMESTAMP();printf("dsIsAudioMSDecode(int, bool*) is defined and loaded\r\n");
3367  }
3368  else {
3369  __TIMESTAMP();printf("dsIsAudioMSDecode(int, bool*) is not defined\r\n");
3370  }
3371  dlclose(dllib);
3372  }
3373  else {
3374  __TIMESTAMP();printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
3375  }
3376  }
3377 
3379  if (func != NULL) {
3380  bool HasMS11Decode = false;
3381  dsError_t ret = func(param->handle, &HasMS11Decode);
3382  if (ret == dsERR_NONE) {
3383  param->ms11Enabled = HasMS11Decode;
3384  result = IARM_RESULT_SUCCESS;
3385  }
3386  }else {
3387  param->ms11Enabled = false;
3388  }
3389 
3390  IARM_BUS_Unlock(lock);
3391 
3392  return result;
3393 }
3394 
3395 IARM_Result_t _dsIsAudioMS12Decode(void *arg)
3396 {
3397 
3398  IARM_BUS_Unlock(lock);
3399 
3400 #ifndef RDK_DSHAL_NAME
3401  #warning "RDK_DSHAL_NAME is not defined"
3402  #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
3403 #endif
3404  _DEBUG_ENTER();
3405 
3406  IARM_BUS_Lock(lock);
3407 
3408  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
3409  typedef dsError_t (*dsIsAudioMS12Decode_t)(intptr_t handle, bool *HasMS12Decode);
3410  static dsIsAudioMS12Decode_t func = NULL;
3411  if (func == NULL) {
3412  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
3413  if (dllib) {
3414  func = (dsIsAudioMS12Decode_t) dlsym(dllib, "dsIsAudioMS12Decode");
3415  if (func) {
3416  __TIMESTAMP();printf("dsIsAudioMS12Decode(int, bool*) is defined and loaded\r\n");
3417  }
3418  else {
3419  __TIMESTAMP();printf("dsIsAudioMS12Decode(int, bool*) is not defined\r\n");
3420  }
3421  dlclose(dllib);
3422  }
3423  else {
3424  __TIMESTAMP();printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
3425  }
3426  }
3427 
3429  if (func != NULL) {
3430  bool HasMS12Decode = false;
3431  dsError_t ret = func(param->handle, &HasMS12Decode);
3432  if (ret == dsERR_NONE) {
3433  param->ms12Enabled = HasMS12Decode;
3434  result = IARM_RESULT_SUCCESS;
3435  }
3436  }else {
3437  param->ms12Enabled = false;
3438  }
3439 
3440  IARM_BUS_Unlock(lock);
3441 
3442  return result;
3443 }
3444 
3445 IARM_Result_t _dsSetAudioDelay(void *arg)
3446 {
3447 #ifndef RDK_DSHAL_NAME
3448 #warning "RDK_DSHAL_NAME is not defined"
3449 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
3450 #endif
3451  _DEBUG_ENTER();
3452  IARM_BUS_Lock(lock);
3453 
3454  IARM_Result_t result = IARM_RESULT_SUCCESS;
3455  typedef dsError_t (*dsSetAudioDelay_t)(intptr_t handle, uint32_t audioDelayMs);
3456  static dsSetAudioDelay_t func = 0;
3457  if (func == 0) {
3458  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
3459  if (dllib) {
3460  func = (dsSetAudioDelay_t) dlsym(dllib, "dsSetAudioDelay");
3461  if (func) {
3462  printf("dsSetAudioDelay_t(int, uint32_t) is defined and loaded\r\n");
3463  }
3464  else {
3465  printf("dsSetAudioDelay_t(int, uint32_t) is not defined\r\n");
3466  }
3467  dlclose(dllib);
3468  }
3469  else {
3470  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
3471  }
3472  }
3473 
3475 
3476  if (func != 0 && param != NULL)
3477  {
3478  if (func(param->handle, param->audioDelayMs) != dsERR_NONE)
3479  {
3480  __TIMESTAMP();printf("%s: (SERVER) Unable to set audiodelay\n", __FUNCTION__);
3481  result = IARM_RESULT_INVALID_STATE;
3482  }
3483 
3484 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
3485  std::string _AudioDelay = std::to_string(param->audioDelayMs);
3486  dsAudioPortType_t _APortType = _GetAudioPortType(param->handle);
3487  switch(_APortType) {
3489  printf("%s: port: %s , persist audio delay: %d\n",__func__,"SPDIF0", param->audioDelayMs);
3490  device::HostPersistence::getInstance().persistHostProperty("SPDIF0.audio.Delay",_AudioDelay);
3491  break;
3492  case dsAUDIOPORT_TYPE_HDMI:
3493  printf("%s: port: %s , persist audio delay: %d\n",__func__,"HDMI0", param->audioDelayMs);
3494  device::HostPersistence::getInstance().persistHostProperty("HDMI0.audio.Delay",_AudioDelay);
3495  break;
3497  printf("%s: port: %s , persist audio delay: %d\n",__func__,"SPEAKER0", param->audioDelayMs);
3498  device::HostPersistence::getInstance().persistHostProperty("SPEAKER0.audio.Delay",_AudioDelay);
3499  break;
3500  case dsAUDIOPORT_TYPE_HDMI_ARC:
3501  printf("%s: port: %s , persist audio delay: %d\n",__func__,"HDMI_ARC0", param->audioDelayMs);
3502  device::HostPersistence::getInstance().persistHostProperty("HDMI_ARC0.audio.Delay",_AudioDelay);
3503  break;
3504  default:
3505  printf("%s: port: UNKNOWN , persist audio delay: %d : NOT SET\n",__func__, param->audioDelayMs);
3506  break;
3507  }
3508 #endif
3509  }
3510  else {
3511  result = IARM_RESULT_INVALID_STATE;
3512  }
3513 
3514  IARM_BUS_Unlock(lock);
3515  return result;
3516 
3517 }
3518 
3519 IARM_Result_t _dsGetAudioDelay(void *arg)
3520 {
3521 #ifndef RDK_DSHAL_NAME
3522 #warning "RDK_DSHAL_NAME is not defined"
3523 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
3524 #endif
3525  _DEBUG_ENTER();
3526  IARM_BUS_Lock(lock);
3527 
3528  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
3529  typedef dsError_t (*dsGetAudioDelay_t)(intptr_t handle, uint32_t *audioDelayMs);
3530  static dsGetAudioDelay_t func = 0;
3531  if (func == 0) {
3532  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
3533  if (dllib) {
3534  func = (dsGetAudioDelay_t) dlsym(dllib, "dsGetAudioDelay");
3535  if (func) {
3536  printf("dsGetAudioDelay_t(int, uint32_t*) is defined and loaded\r\n");
3537  }
3538  else {
3539  printf("dsGetAudioDelay_t(int, uint32_t*) is not defined\r\n");
3540  }
3541  dlclose(dllib);
3542  }
3543  else {
3544  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
3545  }
3546  }
3547 
3549 
3550  if (func != 0 && param != NULL)
3551  {
3552  uint32_t audioDelayMs = 0;
3553  param->audioDelayMs = 0;
3554  if (func(param->handle, &audioDelayMs) == dsERR_NONE)
3555  {
3556  param->audioDelayMs = audioDelayMs;
3557  result = IARM_RESULT_SUCCESS;
3558  }
3559  }
3560 
3561  IARM_BUS_Unlock(lock);
3562  return result;
3563 }
3564 
3565 IARM_Result_t _dsSetAudioDelayOffset(void *arg)
3566 {
3567 #ifndef RDK_DSHAL_NAME
3568 #warning "RDK_DSHAL_NAME is not defined"
3569 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
3570 #endif
3571  _DEBUG_ENTER();
3572  IARM_BUS_Lock(lock);
3573 
3574  IARM_Result_t result = IARM_RESULT_SUCCESS;
3575  typedef dsError_t (*dsSetAudioDelayOffset_t)(intptr_t handle, uint32_t audioDelayOffsetMs);
3576  static dsSetAudioDelayOffset_t func = 0;
3577  if (func == 0) {
3578  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
3579  if (dllib) {
3580  func = (dsSetAudioDelayOffset_t) dlsym(dllib, "dsSetAudioDelayOffset");
3581  if (func) {
3582  printf("dsSetAudioDelayOffset_t(int, uint32_t) is defined and loaded\r\n");
3583  }
3584  else {
3585  printf("dsSetAudioDelayOffset_t(int, uint32_t) is not defined\r\n");
3586  }
3587  dlclose(dllib);
3588  }
3589  else {
3590  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
3591  }
3592  }
3593 
3595 
3596  if (func != 0 && param != NULL)
3597  {
3598  if (func(param->handle, param->audioDelayOffsetMs) != dsERR_NONE)
3599  {
3600  __TIMESTAMP();printf("%s: (SERVER) Unable to set audiodelay offset\n", __FUNCTION__);
3601  result = IARM_RESULT_INVALID_STATE;
3602  }
3603 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
3604  std::string _AudioDelayOffset = std::to_string(param->audioDelayOffsetMs);
3605  dsAudioPortType_t _APortType = _GetAudioPortType(param->handle);
3606  switch(_APortType) {
3608  printf("%s: port: %s , persist audio delay offset ms: %d\n",__func__,"SPDIF0", param->audioDelayOffsetMs);
3609  device::HostPersistence::getInstance().persistHostProperty("SPDIF0.audio.DelayOffset",_AudioDelayOffset);
3610  break;
3611  case dsAUDIOPORT_TYPE_HDMI:
3612  printf("%s: port: %s , persist audio delay offset ms: %d\n",__func__,"HDMI0", param->audioDelayOffsetMs);
3613  device::HostPersistence::getInstance().persistHostProperty("HDMI0.audio.DelayOffset",_AudioDelayOffset);
3614  break;
3616  printf("%s: port: %s , persist audio delay offset ms: %d\n",__func__,"SPEAKER0", param->audioDelayOffsetMs);
3617  device::HostPersistence::getInstance().persistHostProperty("SPEAKER0.audio.DelayOffset",_AudioDelayOffset);
3618  break;
3619  case dsAUDIOPORT_TYPE_HDMI_ARC:
3620  printf("%s: port: %s , persist audio delay: %d\n",__func__,"HDMI_ARC0", param->audioDelayOffsetMs);
3621  device::HostPersistence::getInstance().persistHostProperty("HDMI_ARC0.audio.DelayOffset",_AudioDelayOffset);
3622  break;
3623  default:
3624  break;
3625  }
3626 #endif
3627  }
3628  else {
3629  result = IARM_RESULT_INVALID_STATE;
3630  }
3631 
3632  IARM_BUS_Unlock(lock);
3633  return result;
3634 
3635 }
3636 
3637 IARM_Result_t _dsGetAudioDelayOffset(void *arg)
3638 {
3639 #ifndef RDK_DSHAL_NAME
3640 #warning "RDK_DSHAL_NAME is not defined"
3641 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
3642 #endif
3643  _DEBUG_ENTER();
3644  IARM_BUS_Lock(lock);
3645 
3646  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
3647  typedef dsError_t (*dsGetAudioDelayOffset_t)(intptr_t handle, uint32_t *audioDelayOffsetMs);
3648  static dsGetAudioDelayOffset_t func = 0;
3649  if (func == 0) {
3650  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
3651  if (dllib) {
3652  func = (dsGetAudioDelayOffset_t) dlsym(dllib, "dsGetAudioDelayOffset");
3653  if (func) {
3654  printf("dsGetAudioDelayOffset_t(int, uint32_t*) is defined and loaded\r\n");
3655  }
3656  else {
3657  printf("dsGetAudioDelayOffset_t(int, uint32_t*) is not defined\r\n");
3658  }
3659  dlclose(dllib);
3660  }
3661  else {
3662  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
3663  }
3664  }
3665 
3667 
3668  if (func != 0 && param != NULL)
3669  {
3670  uint32_t audioDelayOffsetMs = 0;
3671  param->audioDelayOffsetMs = 0;
3672  if (func(param->handle, &audioDelayOffsetMs) == dsERR_NONE)
3673  {
3674  param->audioDelayOffsetMs = audioDelayOffsetMs;
3675  result = IARM_RESULT_SUCCESS;
3676  }
3677  }
3678 
3679  IARM_BUS_Unlock(lock);
3680  return result;
3681 }
3682 
3683 IARM_Result_t _dsSetAudioAtmosOutputMode(void *arg)
3684 {
3685 #ifndef RDK_DSHAL_NAME
3686 #warning "RDK_DSHAL_NAME is not defined"
3687 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
3688 #endif
3689  _DEBUG_ENTER();
3690  IARM_BUS_Lock(lock);
3691 
3692  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
3693  typedef dsError_t (*dsSetAudioAtmosOutputMode_t)(intptr_t handle, bool enable);
3694  static dsSetAudioAtmosOutputMode_t func = 0;
3695  if (func == 0) {
3696  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
3697  if (dllib) {
3698  func = (dsSetAudioAtmosOutputMode_t) dlsym(dllib, "dsSetAudioAtmosOutputMode");
3699  if (func) {
3700  printf("dsSetAudioAtmosOutputMode_t (intptr_t handle, bool enable ) is defined and loaded\r\n");
3701  }
3702  else {
3703  printf("dsSetAudioAtmosOutputMode_t (intptr_t handle, bool enable) is not defined\r\n");
3704  }
3705  dlclose(dllib);
3706  }
3707  else {
3708  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
3709  }
3710  }
3711 
3713 
3714  if (func != 0 && param != NULL)
3715  {
3716  if(func(param->handle, param->enable) == dsERR_NONE) {
3717  result = IARM_RESULT_SUCCESS;
3718  }
3719  }
3720 
3721  IARM_BUS_Unlock(lock);
3722  return result;
3723 }
3724 
3725 IARM_Result_t _dsGetSinkDeviceAtmosCapability(void *arg)
3726 {
3727 #ifndef RDK_DSHAL_NAME
3728 #warning "RDK_DSHAL_NAME is not defined"
3729 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
3730 #endif
3731  _DEBUG_ENTER();
3732  IARM_BUS_Lock(lock);
3733 
3734  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
3735  typedef dsError_t (*dsGetSinkDeviceAtmosCapability_t)(intptr_t handle, dsATMOSCapability_t *capability);
3736  static dsGetSinkDeviceAtmosCapability_t func = 0;
3737  if (func == 0) {
3738  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
3739  if (dllib) {
3740  func = (dsGetSinkDeviceAtmosCapability_t) dlsym(dllib, "dsGetSinkDeviceAtmosCapability");
3741  if (func) {
3742  printf("dsGetSinkDeviceAtmosCapability_t (intptr_t handle, dsATMOSCapability_t *capability ) is defined and loaded\r\n");
3743  }
3744  else {
3745  printf("dsGetSinkDeviceAtmosCapability_t (intptr_t handle, dsATMOSCapability_t *capability ) is not defined\r\n");
3746  }
3747  dlclose(dllib);
3748  }
3749  else {
3750  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
3751  }
3752  }
3753 
3755 
3756  if (func != 0 && param != NULL)
3757  {
3758  dsATMOSCapability_t capability = dsAUDIO_ATMOS_NOTSUPPORTED;
3759 
3760  param->capability= dsAUDIO_ATMOS_NOTSUPPORTED;
3761  if (func(param->handle, &capability) == dsERR_NONE)
3762  {
3763  param->capability = capability;
3764  result = IARM_RESULT_SUCCESS;
3765  }
3766  }
3767 
3768  IARM_BUS_Unlock(lock);
3769  return result;
3770 }
3771 
3772 IARM_Result_t _dsSetAudioCompression(void *arg)
3773 {
3774 #ifndef RDK_DSHAL_NAME
3775 #warning "RDK_DSHAL_NAME is not defined"
3776 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
3777 #endif
3778  _DEBUG_ENTER();
3779  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
3780  IARM_BUS_Lock(lock);
3781 
3782  typedef dsError_t (*dsSetAudioCompression_t)(intptr_t handle, int compressionLevel);
3783  static dsSetAudioCompression_t func = 0;
3784  if (func == 0) {
3785  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
3786  if (dllib) {
3787  func = (dsSetAudioCompression_t) dlsym(dllib, "dsSetAudioCompression");
3788  if (func) {
3789  printf("dsSetAudioCompression_t(int, int ) is defined and loaded\r\n");
3790  }
3791  else {
3792  printf("dsSetAudioCompression_t(int, int) is not defined\r\n");
3793  }
3794  dlclose(dllib);
3795  }
3796  else {
3797  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
3798  }
3799  }
3800 
3802 
3803  if (func != 0 && param != NULL)
3804  {
3805  if (func(param->handle, param->compression) == dsERR_NONE)
3806  {
3807 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
3808  std::string _Compression = std::to_string(param->compression);
3809  printf("%s: persist audio compression: %d\n",__func__, param->compression);
3810  device::HostPersistence::getInstance().persistHostProperty("audio.Compression",_Compression);
3811 #endif
3812  result = IARM_RESULT_SUCCESS;
3813  }
3814  }
3815 
3816  IARM_BUS_Unlock(lock);
3817  return result;
3818 }
3819 
3820 IARM_Result_t _dsGetAudioCompression(void *arg)
3821 {
3822 #ifndef RDK_DSHAL_NAME
3823 #warning "RDK_DSHAL_NAME is not defined"
3824 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
3825 #endif
3826  _DEBUG_ENTER();
3827  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
3828  IARM_BUS_Lock(lock);
3829 
3830  typedef dsError_t (*dsGetAudioCompression_t)(intptr_t handle, int *compressionLevel);
3831  static dsGetAudioCompression_t func = 0;
3832  if (func == 0) {
3833  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
3834  if (dllib) {
3835  func = (dsGetAudioCompression_t) dlsym(dllib, "dsGetAudioCompression");
3836  if (func) {
3837  printf("dsGetAudioCompression_t(int, int *) is defined and loaded\r\n");
3838  }
3839  else {
3840  printf("dsGetAudioCompression_t(int, int *) is not defined\r\n");
3841  }
3842  dlclose(dllib);
3843  }
3844  else {
3845  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
3846  }
3847  }
3848 
3850 
3851  if (func != 0 && param != NULL)
3852  {
3853  int compression = 0;
3854  param->compression= 0;
3855  if (func(param->handle, &compression) == dsERR_NONE)
3856  {
3857  param->compression = compression;
3858  result = IARM_RESULT_SUCCESS;
3859  }
3860  }
3861 
3862  IARM_BUS_Unlock(lock);
3863  return result;
3864 }
3865 
3866 IARM_Result_t _dsSetDialogEnhancement(void *arg)
3867 {
3868 #ifndef RDK_DSHAL_NAME
3869 #warning "RDK_DSHAL_NAME is not defined"
3870 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
3871 #endif
3872  _DEBUG_ENTER();
3873  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
3874  IARM_BUS_Lock(lock);
3876  if(param != NULL)
3877  result = _setDialogEnhancement(param->handle, param->enhancerLevel);
3878  IARM_BUS_Unlock(lock);
3879  return result;
3880 }
3881 
3882 static IARM_Result_t _setDialogEnhancement(intptr_t handle, int enhancerLevel)
3883 {
3884  typedef dsError_t (*dsSetDialogEnhancement_t)(intptr_t handle, int enhancerLevel);
3885  static dsSetDialogEnhancement_t func = 0;
3886  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
3887 
3888  if (func == 0) {
3889  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
3890  if (dllib) {
3891  func = (dsSetDialogEnhancement_t) dlsym(dllib, "dsSetDialogEnhancement");
3892  if (func) {
3893  printf("dsSetDialogEnhancement_t(int, int) is defined and loaded\r\n");
3894  }
3895  else {
3896  printf("dsSetDialogEnhancement_t(int, int ) is not defined\r\n");
3897  }
3898  dlclose(dllib);
3899  }
3900  else {
3901  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
3902  }
3903  }
3904 
3905  std::string _Property = _dsGetCurrentProfileProperty("EnhancerLevel");
3906  if (func != 0)
3907  {
3908  if (func(handle, enhancerLevel) == dsERR_NONE)
3909  {
3910 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
3911  std::string _EnhancerLevel = std::to_string(enhancerLevel);
3912  printf("%s: persist enhancer level: %d\n",__func__, enhancerLevel);
3913  device::HostPersistence::getInstance().persistHostProperty(_Property ,_EnhancerLevel);
3914 #endif
3915  result = IARM_RESULT_SUCCESS;
3916  }
3917  }
3918  return result;
3919 }
3920 
3921 
3922 IARM_Result_t _dsGetDialogEnhancement(void *arg)
3923 {
3924 #ifndef RDK_DSHAL_NAME
3925 #warning "RDK_DSHAL_NAME is not defined"
3926 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
3927 #endif
3928  _DEBUG_ENTER();
3929  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
3930  IARM_BUS_Lock(lock);
3931 
3932  typedef dsError_t (*dsGetDialogEnhancement_t)(intptr_t handle, int *enhancerLevel);
3933  static dsGetDialogEnhancement_t func = 0;
3934  if (func == 0) {
3935  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
3936  if (dllib) {
3937  func = (dsGetDialogEnhancement_t) dlsym(dllib, "dsGetDialogEnhancement");
3938  if (func) {
3939  printf("dsGetDialogEnhancement_t(int, int *) is defined and loaded\r\n");
3940  }
3941  else {
3942  printf("dsGetDialogEnhancement_t(int, int *) is not defined\r\n");
3943  }
3944  dlclose(dllib);
3945  }
3946  else {
3947  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
3948  }
3949  }
3950 
3952 
3953  if (func != 0 && param != NULL)
3954  {
3955  int enhancerLevel = 0;
3956  param->enhancerLevel = 0;
3957  if (func(param->handle, &enhancerLevel) == dsERR_NONE)
3958  {
3959  param->enhancerLevel = enhancerLevel;
3960  result = IARM_RESULT_SUCCESS;
3961  }
3962  }
3963 
3964  IARM_BUS_Unlock(lock);
3965  return result;
3966 }
3967 
3968 
3969 IARM_Result_t _dsSetDolbyVolumeMode(void *arg)
3970 {
3971 #ifndef RDK_DSHAL_NAME
3972 #warning "RDK_DSHAL_NAME is not defined"
3973 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
3974 #endif
3975  _DEBUG_ENTER();
3976  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
3977  IARM_BUS_Lock(lock);
3978 
3979  typedef dsError_t (*dsSetDolbyVolumeMode_t)(intptr_t handle, bool enable);
3980  static dsSetDolbyVolumeMode_t func = 0;
3981  if (func == 0) {
3982  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
3983  if (dllib) {
3984  func = (dsSetDolbyVolumeMode_t) dlsym(dllib, "dsSetDolbyVolumeMode");
3985  if (func) {
3986  printf("dsSetDolbyVolumeMode_t(int, bool) is defined and loaded\r\n");
3987  }
3988  else {
3989  printf("dsSetDolbyVolumeMode_t(int, bool) is not defined\r\n");
3990  }
3991  dlclose(dllib);
3992  }
3993  else {
3994  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
3995  }
3996  }
3997 
3999 
4000  if (func != 0 && param != NULL)
4001  {
4002  if (func(param->handle, param->enable) == dsERR_NONE)
4003  {
4004 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
4005  printf("%s: persist dolby volume mode: %s\n",__func__, param->enable ? "TRUE":"FALSE");
4006  device::HostPersistence::getInstance().persistHostProperty("audio.DolbyVolumeMode",param->enable ? "TRUE":"FALSE");
4007 #endif
4008  result = IARM_RESULT_SUCCESS;
4009  }
4010  }
4011 
4012  IARM_BUS_Unlock(lock);
4013  return result;
4014 }
4015 
4016 IARM_Result_t _dsGetDolbyVolumeMode(void *arg)
4017 {
4018 #ifndef RDK_DSHAL_NAME
4019 #warning "RDK_DSHAL_NAME is not defined"
4020 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
4021 #endif
4022  _DEBUG_ENTER();
4023  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
4024  IARM_BUS_Lock(lock);
4025 
4026  typedef dsError_t (*dsGetDolbyVolumeMode_t)(intptr_t handle, bool *enable);
4027  static dsGetDolbyVolumeMode_t func = 0;
4028  if (func == 0) {
4029  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
4030  if (dllib) {
4031  func = (dsGetDolbyVolumeMode_t) dlsym(dllib, "dsGetDolbyVolumeMode");
4032  if (func) {
4033  printf("dsGetDolbyVolumeMode_t(int, bool *) is defined and loaded\r\n");
4034  }
4035  else {
4036  printf("dsGetDolbyVolumeMode_t(int, bool *) is not defined\r\n");
4037  }
4038  dlclose(dllib);
4039  }
4040  else {
4041  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
4042  }
4043  }
4044 
4046  bool enable = false;
4047 
4048  if (func != 0 && param != NULL)
4049  {
4050  param->enable = false;
4051  if (func(param->handle, &enable) == dsERR_NONE)
4052  {
4053  param->enable = enable;
4054  result = IARM_RESULT_SUCCESS;
4055  }
4056  }
4057 
4058  IARM_BUS_Unlock(lock);
4059  return result;
4060 }
4061 
4062 IARM_Result_t _dsSetIntelligentEqualizerMode(void *arg)
4063 {
4064 #ifndef RDK_DSHAL_NAME
4065 #warning "RDK_DSHAL_NAME is not defined"
4066 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
4067 #endif
4068  _DEBUG_ENTER();
4069  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
4070  IARM_BUS_Lock(lock);
4071 
4072  typedef dsError_t (*dsSetIntelligentEqualizerMode_t)(intptr_t handle, int mode);
4073  static dsSetIntelligentEqualizerMode_t func = 0;
4074  if (func == 0) {
4075  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
4076  if (dllib) {
4077  func = (dsSetIntelligentEqualizerMode_t) dlsym(dllib, "dsSetIntelligentEqualizerMode");
4078  if (func) {
4079  printf("dsSetIntelligentEqualizerMode_t(int, int) is defined and loaded\r\n");
4080  }
4081  else {
4082  printf("dsSetIntelligentEqualizerMode_t(int, int) is not defined\r\n");
4083  }
4084  dlclose(dllib);
4085  }
4086  else {
4087  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
4088  }
4089  }
4090 
4092 
4093  if (func != 0 && param != NULL)
4094  {
4095  if (func(param->handle, param->mode) == dsERR_NONE)
4096  {
4097 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
4098  std::string _IntelligentEQ = std::to_string(param->mode);
4099  printf("%s: persist intelligent equalizer value: %d\n",__func__, param->mode);
4100  device::HostPersistence::getInstance().persistHostProperty("audio.IntelligentEQ",_IntelligentEQ);
4101 #endif
4102  result = IARM_RESULT_SUCCESS;
4103  }
4104  }
4105 
4106  IARM_BUS_Unlock(lock);
4107  return result;
4108 }
4109 
4110 
4111 IARM_Result_t _dsGetIntelligentEqualizerMode(void *arg)
4112 {
4113 #ifndef RDK_DSHAL_NAME
4114 #warning "RDK_DSHAL_NAME is not defined"
4115 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
4116 #endif
4117  _DEBUG_ENTER();
4118  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
4119  IARM_BUS_Lock(lock);
4120 
4121  typedef dsError_t (*dsGetIntelligentEqualizerMode_t)(intptr_t handle, int *mode);
4122  static dsGetIntelligentEqualizerMode_t func = 0;
4123  if (func == 0) {
4124  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
4125  if (dllib) {
4126  func = (dsGetIntelligentEqualizerMode_t) dlsym(dllib, "dsGetIntelligentEqualizerMode");
4127  if (func) {
4128  printf("dsGetIntelligentEqualizerMode_t(int, int *) is defined and loaded\r\n");
4129  }
4130  else {
4131  printf("dsGetIntelligentEqualizerMode_t(int, int *) is not defined\r\n");
4132  }
4133  dlclose(dllib);
4134  }
4135  else {
4136  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
4137  }
4138  }
4139 
4141 
4142  if (func != 0 && param != NULL)
4143  {
4144  int mode = 0;
4145  param->mode = 0;
4146  if (func(param->handle, &mode) == dsERR_NONE)
4147  {
4148  param->mode = mode;
4149  result = IARM_RESULT_SUCCESS;
4150  }
4151  }
4152 
4153  IARM_BUS_Unlock(lock);
4154  return result;
4155 }
4156 
4157 
4158 IARM_Result_t _dsGetVolumeLeveller(void *arg)
4159 {
4160 #ifndef RDK_DSHAL_NAME
4161 #warning "RDK_DSHAL_NAME is not defined"
4162 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
4163 #endif
4164  _DEBUG_ENTER();
4165  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
4166  IARM_BUS_Lock(lock);
4167 
4168  typedef dsError_t (*dsGetVolumeLeveller_t)(intptr_t handle, dsVolumeLeveller_t *volLeveller);
4169  static dsGetVolumeLeveller_t func = 0;
4170  if (func == 0) {
4171  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
4172  if (dllib) {
4173  func = (dsGetVolumeLeveller_t) dlsym(dllib, "dsGetVolumeLeveller");
4174  if (func) {
4175  printf("dsGetVolumeLeveller_t(int, dsVolumeLeveller_t *) is defined and loaded\r\n");
4176  }
4177  else {
4178  printf("dsGetVolumeLeveller_t(int, dsVolumeLeveller_t *) is not defined\r\n");
4179  }
4180  dlclose(dllib);
4181  }
4182  else {
4183  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
4184  }
4185  }
4186 
4188 
4189  if (func != 0 && param != NULL)
4190  {
4191  dsVolumeLeveller_t volLeveller;
4192  volLeveller.mode = 0;
4193  volLeveller.level = 0;
4194  param->volLeveller.mode = 0;
4195  param->volLeveller.level = 0;
4196  if (func(param->handle, &volLeveller) == dsERR_NONE)
4197  {
4198  param->volLeveller.mode = volLeveller.mode;
4199  param->volLeveller.level = volLeveller.level;
4200  result = IARM_RESULT_SUCCESS;
4201  }
4202  }
4203 
4204  IARM_BUS_Unlock(lock);
4205  return result;
4206 }
4207 
4208 
4209 IARM_Result_t _dsSetVolumeLeveller(void *arg)
4210 {
4211 #ifndef RDK_DSHAL_NAME
4212 #warning "RDK_DSHAL_NAME is not defined"
4213 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
4214 #endif
4215  _DEBUG_ENTER();
4216  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
4217  IARM_BUS_Lock(lock);
4218 
4220  if( param != NULL )
4221  result = _setVolumeLeveller(param->handle, param->volLeveller.mode, param->volLeveller.level);
4222  IARM_BUS_Unlock(lock);
4223  return result;
4224 }
4225 
4226 static IARM_Result_t _setVolumeLeveller(intptr_t handle, int volLevellerMode, int volLevellerLevel)
4227 {
4228  typedef dsError_t (*dsSetVolumeLeveller_t)(intptr_t handle, dsVolumeLeveller_t volLeveller);
4229  static dsSetVolumeLeveller_t func = 0;
4230  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
4231 
4232  if (func == 0) {
4233  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
4234  if (dllib) {
4235  func = (dsSetVolumeLeveller_t) dlsym(dllib, "dsSetVolumeLeveller");
4236  if (func) {
4237  printf("dsSetVolumeLeveller_t(int, dsVolumeLeveller_t) is defined and loaded\r\n");
4238  }
4239  else {
4240  printf("dsSetVolumeLeveller_t(int, dsVolumeLeveller_t) is not defined\r\n");
4241  }
4242  dlclose(dllib);
4243  }
4244  else {
4245  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
4246  }
4247  }
4248 
4250 
4251  param.handle = handle;
4252  param.volLeveller.mode = volLevellerMode;
4253  param.volLeveller.level = volLevellerLevel;
4254 
4255  if (func != 0 )
4256  {
4257  if (func(param.handle, param.volLeveller) == dsERR_NONE)
4258  {
4259 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
4260  std::string _PropertyMode = _dsGetCurrentProfileProperty("VolumeLeveller.mode");
4261  std::string _Propertylevel = _dsGetCurrentProfileProperty("VolumeLeveller.level");
4262  std::string _mode = std::to_string(param.volLeveller.mode);
4263  printf("%s: persist volume leveller mode: %d\n",__func__, param.volLeveller.mode);
4265 
4266  if((param.volLeveller.mode == 0) || (param.volLeveller.mode == 1)) {
4267  std::string _level = std::to_string(param.volLeveller.level);
4268  printf("%s: persist volume leveller value: %d\n",__func__, param.volLeveller.level);
4270  }
4271 #endif
4272  result = IARM_RESULT_SUCCESS;
4273  }
4274  }
4275 
4276  return result;
4277 }
4278 
4279 
4280 IARM_Result_t _dsGetBassEnhancer(void *arg)
4281 {
4282 #ifndef RDK_DSHAL_NAME
4283 #warning "RDK_DSHAL_NAME is not defined"
4284 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
4285 #endif
4286  _DEBUG_ENTER();
4287  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
4288  IARM_BUS_Lock(lock);
4289 
4290  typedef dsError_t (*dsGetBassEnhancer_t)(intptr_t handle, int *boost);
4291  static dsGetBassEnhancer_t func = 0;
4292  if (func == 0) {
4293  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
4294  if (dllib) {
4295  func = (dsGetBassEnhancer_t) dlsym(dllib, "dsGetBassEnhancer");
4296  if (func) {
4297  printf("dsGetBassEnhancer_t(int, int *) is defined and loaded\r\n");
4298  }
4299  else {
4300  printf("dsGetBassEnhancer_t(int, int *) is not defined\r\n");
4301  }
4302  dlclose(dllib);
4303  }
4304  else {
4305  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
4306  }
4307  }
4308 
4310  int boost = 0;
4311  if (func != 0 && param != NULL)
4312  {
4313  param->boost = 0; //CID:155155 - Rverse_inull
4314  if (func(param->handle, &boost) == dsERR_NONE)
4315  {
4316  param->boost = boost;
4317  result = IARM_RESULT_SUCCESS;
4318  }
4319  }
4320 
4321  IARM_BUS_Unlock(lock);
4322  return result;
4323 }
4324 
4325 
4326 IARM_Result_t _dsSetBassEnhancer(void *arg)
4327 {
4328 #ifndef RDK_DSHAL_NAME
4329 #warning "RDK_DSHAL_NAME is not defined"
4330 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
4331 #endif
4332  _DEBUG_ENTER();
4333  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
4334  IARM_BUS_Lock(lock);
4336  if( param != NULL )
4337  result = _setBassEnhancer(param->handle, param->boost);
4338  IARM_BUS_Unlock(lock);
4339  return result;
4340 }
4341 
4342 static IARM_Result_t _setBassEnhancer(intptr_t handle ,int boost)
4343 {
4344  typedef dsError_t (*dsSetBassEnhancer_t)(intptr_t handle, int boost);
4345  static dsSetBassEnhancer_t func = 0;
4346  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
4347 
4348  if (func == 0) {
4349  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
4350  if (dllib) {
4351  func = (dsSetBassEnhancer_t) dlsym(dllib, "dsSetBassEnhancer");
4352  if (func) {
4353  printf("dsSetBassEnhancer_t(int, int) is defined and loaded\r\n");
4354  }
4355  else {
4356  printf("dsSetBassEnhancer_t(int, int) is not defined\r\n");
4357  }
4358  dlclose(dllib);
4359  }
4360  else {
4361  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
4362  }
4363  }
4364 
4365  if (func != 0)
4366  {
4367  if (func(handle, boost) == dsERR_NONE)
4368  {
4369 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
4370  std::string _BassBoost = std::to_string(boost);
4371  printf("%s: persist boost value: %d\n",__func__, boost);
4372  device::HostPersistence::getInstance().persistHostProperty("audio.BassBoost", _BassBoost);
4373 #endif
4374  result = IARM_RESULT_SUCCESS;
4375  }
4376  }
4377 
4378  return result;
4379 }
4380 
4381 
4382 IARM_Result_t _dsIsSurroundDecoderEnabled(void *arg)
4383 {
4384 #ifndef RDK_DSHAL_NAME
4385 #warning "RDK_DSHAL_NAME is not defined"
4386 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
4387 #endif
4388  _DEBUG_ENTER();
4389  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
4390  IARM_BUS_Lock(lock);
4391 
4392  typedef dsError_t (*dsIsSurroundDecoderEnabled_t)(intptr_t handle, bool *enabled);
4393  static dsIsSurroundDecoderEnabled_t func = 0;
4394  if (func == 0) {
4395  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
4396  if (dllib) {
4397  func = (dsIsSurroundDecoderEnabled_t) dlsym(dllib, "dsIsSurroundDecoderEnabled");
4398  if (func) {
4399  printf("dsIsSurroundDecoderEnabled_t(int, bool *) is defined and loaded\r\n");
4400  }
4401  else {
4402  printf("dsIsSurroundDecoderEnabled_t(int, bool *) is not defined\r\n");
4403  }
4404  dlclose(dllib);
4405  }
4406  else {
4407  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
4408  }
4409  }
4410 
4412  bool enable = false;
4413 
4414  if (func != 0 && param != NULL)
4415  {
4416  param->enable = false; //CID:155170 - Reverse_inull
4417  if (func(param->handle, &enable) == dsERR_NONE)
4418  {
4419  param->enable = enable;
4420  result = IARM_RESULT_SUCCESS;
4421 
4422  }
4423  }
4424 
4425  IARM_BUS_Unlock(lock);
4426  return result;
4427 }
4428 
4429 IARM_Result_t _dsEnableSurroundDecoder(void *arg)
4430 {
4431 #ifndef RDK_DSHAL_NAME
4432 #warning "RDK_DSHAL_NAME is not defined"
4433 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
4434 #endif
4435  _DEBUG_ENTER();
4436  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
4437  IARM_BUS_Lock(lock);
4438 
4439  typedef dsError_t (*dsEnableSurroundDecoder_t)(intptr_t handle, bool enabled);
4440  static dsEnableSurroundDecoder_t func = 0;
4441  if (func == 0) {
4442  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
4443  if (dllib) {
4444  func = (dsEnableSurroundDecoder_t) dlsym(dllib, "dsEnableSurroundDecoder");
4445  if (func) {
4446  printf("dsEnableSurroundDecoder_t(int, bool) is defined and loaded\r\n");
4447  }
4448  else {
4449  printf("dsEnableSurroundDecoder_t(int, bool) is not defined\r\n");
4450  }
4451  dlclose(dllib);
4452  }
4453  else {
4454  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
4455  }
4456  }
4457 
4459 
4460  if (func != 0 && param != NULL)
4461  {
4462  if (func(param->handle, param->enable) == dsERR_NONE)
4463  {
4464 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
4465  printf("%s: persist surround decoder value: %s\n",__func__, param->enable ? "TRUE":"FALSE");
4466  device::HostPersistence::getInstance().persistHostProperty("audio.SurroundDecoderEnabled",param->enable ? "TRUE":"FALSE");
4467 #endif
4468  result = IARM_RESULT_SUCCESS;
4469  }
4470  }
4471 
4472  IARM_BUS_Unlock(lock);
4473  return result;
4474 }
4475 
4476 
4477 IARM_Result_t _dsGetDRCMode(void *arg)
4478 {
4479 #ifndef RDK_DSHAL_NAME
4480 #warning "RDK_DSHAL_NAME is not defined"
4481 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
4482 #endif
4483  _DEBUG_ENTER();
4484  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
4485  IARM_BUS_Lock(lock);
4486 
4487  typedef dsError_t (*dsGetDRCMode_t)(intptr_t handle, int *mode);
4488  static dsGetDRCMode_t func = 0;
4489  if (func == 0) {
4490  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
4491  if (dllib) {
4492  func = (dsGetDRCMode_t) dlsym(dllib, "dsGetDRCMode");
4493  if (func) {
4494  printf("dsGetDRCMode_t(int, int *) is defined and loaded\r\n");
4495  }
4496  else {
4497  printf("dsGetDRCMode_t(int, int *) is not defined\r\n");
4498  }
4499  dlclose(dllib);
4500  }
4501  else {
4502  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
4503  }
4504  }
4505 
4506  dsDRCModeParam_t *param = (dsDRCModeParam_t *)arg;
4507 
4508  if (func != 0 && param != NULL)
4509  {
4510  int mode = 0;
4511  param->mode = 0;
4512  if (func(param->handle, &mode) == dsERR_NONE)
4513  {
4514  param->mode = mode;
4515  result = IARM_RESULT_SUCCESS;
4516  }
4517  }
4518 
4519  IARM_BUS_Unlock(lock);
4520  return result;
4521 }
4522 
4523 
4524 IARM_Result_t _dsSetDRCMode(void *arg)
4525 {
4526 #ifndef RDK_DSHAL_NAME
4527 #warning "RDK_DSHAL_NAME is not defined"
4528 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
4529 #endif
4530  _DEBUG_ENTER();
4531  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
4532  IARM_BUS_Lock(lock);
4533 
4534  typedef dsError_t (*dsSetDRCMode_t)(intptr_t handle, int mode);
4535  static dsSetDRCMode_t func = 0;
4536  if (func == 0) {
4537  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
4538  if (dllib) {
4539  func = (dsSetDRCMode_t) dlsym(dllib, "dsSetDRCMode");
4540  if (func) {
4541  printf("dsSetDRCMode_t(int, int) is defined and loaded\r\n");
4542  }
4543  else {
4544  printf("dsSetDRCMode_t(int, int) is not defined\r\n");
4545  }
4546  dlclose(dllib);
4547  }
4548  else {
4549  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
4550  }
4551  }
4552 
4553  dsDRCModeParam_t *param = (dsDRCModeParam_t *)arg;
4554 
4555  if (func != 0 && param != NULL)
4556  {
4557  if (func(param->handle, param->mode) == dsERR_NONE)
4558  {
4559 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
4560  printf("%s: persist DRC Mode value: %s\n",__func__, param->mode ? "RF":"Line");
4561  device::HostPersistence::getInstance().persistHostProperty("audio.DRCMode",param->mode ? "RF":"Line");
4562 #endif
4563  result = IARM_RESULT_SUCCESS;
4564  }
4565  }
4566 
4567  IARM_BUS_Unlock(lock);
4568  return result;
4569 }
4570 
4571 IARM_Result_t _dsGetSurroundVirtualizer(void *arg)
4572 {
4573 #ifndef RDK_DSHAL_NAME
4574 #warning "RDK_DSHAL_NAME is not defined"
4575 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
4576 #endif
4577  _DEBUG_ENTER();
4578  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
4579  IARM_BUS_Lock(lock);
4580 
4581  typedef dsError_t (*dsGetSurroundVirtualizer_t)(intptr_t handle, dsSurroundVirtualizer_t *virtualizer);
4582  static dsGetSurroundVirtualizer_t func = 0;
4583  if (func == 0) {
4584  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
4585  if (dllib) {
4586  func = (dsGetSurroundVirtualizer_t) dlsym(dllib, "dsGetSurroundVirtualizer");
4587  if (func) {
4588  printf("dsGetSurroundVirtualizer_t(int, dsSurroundVirtualizer_t *) is defined and loaded\r\n");
4589  }
4590  else {
4591  printf("dsGetSurroundVirtualizer_t(int, dsSurroundVirtualizer_t *) is not defined\r\n");
4592  }
4593  dlclose(dllib);
4594  }
4595  else {
4596  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
4597  }
4598  }
4599 
4601 
4602  if (func != 0 && param != NULL)
4603  {
4604  dsSurroundVirtualizer_t virtualizer;
4605  virtualizer.mode = 0;
4606  virtualizer.boost = 0;
4607  param->virtualizer.mode = 0;
4608  param->virtualizer.boost = 0;
4609  if (func(param->handle, &virtualizer) == dsERR_NONE)
4610  {
4611  param->virtualizer.mode = virtualizer.mode;
4612  param->virtualizer.boost = virtualizer.boost;
4613  result = IARM_RESULT_SUCCESS;
4614  }
4615  }
4616 
4617  IARM_BUS_Unlock(lock);
4618  return result;
4619 }
4620 
4621 
4622 IARM_Result_t _dsSetSurroundVirtualizer(void *arg)
4623 {
4624 #ifndef RDK_DSHAL_NAME
4625 #warning "RDK_DSHAL_NAME is not defined"
4626 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
4627 #endif
4628  _DEBUG_ENTER();
4629  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
4630  IARM_BUS_Lock(lock);
4631 
4633  if( param != NULL )
4634  result = _setSurroundVirtualizer(param->handle, param->virtualizer.mode, param->virtualizer.boost);
4635  IARM_BUS_Unlock(lock);
4636  return result;
4637 }
4638 
4639 static IARM_Result_t _setSurroundVirtualizer(intptr_t handle , int virtualizerMode , int virtualizerBoost)
4640 {
4641  typedef dsError_t (*dsSetSurroundVirtualizer_t)(intptr_t handle, dsSurroundVirtualizer_t virtualizer);
4642  static dsSetSurroundVirtualizer_t func = 0;
4643  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
4644 
4645  if (func == 0) {
4646  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
4647  if (dllib) {
4648  func = (dsSetSurroundVirtualizer_t) dlsym(dllib, "dsSetSurroundVirtualizer");
4649  if (func) {
4650  printf("dsSetSurroundVirtualizer_t(int, dsSurroundVirtualizer_t) is defined and loaded\r\n");
4651  }
4652  else {
4653  printf("dsSetSurroundVirtualizer_t(int, dsSurroundVirtualizer_t) is not defined\r\n");
4654  }
4655  dlclose(dllib);
4656  }
4657  else {
4658  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
4659  }
4660  }
4661 
4663  param.handle = handle;
4664  param.virtualizer.mode = virtualizerMode;
4665  param.virtualizer.boost = virtualizerBoost;
4666 
4667  if (func != 0)
4668  {
4669  if (func(param.handle, param.virtualizer) == dsERR_NONE)
4670  {
4671 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
4672  std::string _mode = std::to_string(param.virtualizer.mode);
4673  printf("%s: persist surround virtualizer mode: %d\n",__func__, param.virtualizer.mode);
4674  std::string _PropertyMode = _dsGetCurrentProfileProperty("SurroundVirtualizer.mode");
4675  std::string _Propertylevel = _dsGetCurrentProfileProperty("SurroundVirtualizer.boost");
4677 
4678  if(((param.virtualizer.mode) >= 0) && ((param.virtualizer.mode) <= 2)) {
4679  std::string _boost = std::to_string(param.virtualizer.boost);
4680  printf("%s: persist surround virtualizer boost value: %d\n",__func__, param.virtualizer.boost);
4682  }
4683 #endif
4684  result = IARM_RESULT_SUCCESS;
4685  }
4686  }
4687 
4688  IARM_BUS_Unlock(lock);
4689  return result;
4690 }
4691 
4692 
4693 IARM_Result_t _dsGetMISteering(void *arg)
4694 {
4695 #ifndef RDK_DSHAL_NAME
4696 #warning "RDK_DSHAL_NAME is not defined"
4697 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
4698 #endif
4699  _DEBUG_ENTER();
4700  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
4701  IARM_BUS_Lock(lock);
4702 
4703  typedef dsError_t (*dsGetMISteering_t)(intptr_t handle, bool *enabled);
4704  static dsGetMISteering_t func = 0;
4705  if (func == 0) {
4706  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
4707  if (dllib) {
4708  func = (dsGetMISteering_t) dlsym(dllib, "dsGetMISteering");
4709  if (func) {
4710  printf("dsGetMISteering_t(int, bool *) is defined and loaded\r\n");
4711  }
4712  else {
4713  printf("dsGetMISteering_t(int, bool *) is not defined\r\n");
4714  }
4715  dlclose(dllib);
4716  }
4717  else {
4718  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
4719  }
4720  }
4721 
4722  dsMISteeringParam_t *param = (dsMISteeringParam_t *)arg;
4723  bool enable = false;
4724  if (func != 0 && param != NULL)
4725  {
4726  param->enable = false; //CID:155153 - Reverse_inull
4727  if (func(param->handle, &enable) == dsERR_NONE)
4728  {
4729  param->enable = enable;
4730  result = IARM_RESULT_SUCCESS;
4731  }
4732  }
4733 
4734  IARM_BUS_Unlock(lock);
4735  return result;
4736 }
4737 
4738 
4739 IARM_Result_t _dsSetMISteering(void *arg)
4740 {
4741 #ifndef RDK_DSHAL_NAME
4742 #warning "RDK_DSHAL_NAME is not defined"
4743 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
4744 #endif
4745  _DEBUG_ENTER();
4746  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
4747  IARM_BUS_Lock(lock);
4748 
4749  typedef dsError_t (*dsSetMISteering_t)(intptr_t handle, bool enabled);
4750  static dsSetMISteering_t func = 0;
4751  if (func == 0) {
4752  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
4753  if (dllib) {
4754  func = (dsSetMISteering_t) dlsym(dllib, "dsSetMISteering");
4755  if (func) {
4756  printf("dsSetMISteering_t(int, bool) is defined and loaded\r\n");
4757  }
4758  else {
4759  printf("dsSetMISteering_t(int, bool) is not defined\r\n");
4760  }
4761  dlclose(dllib);
4762  }
4763  else {
4764  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
4765  }
4766  }
4767 
4768  dsMISteeringParam_t *param = (dsMISteeringParam_t *)arg;
4769 
4770  if (func != 0 && param != NULL)
4771  {
4772  if (func(param->handle, param->enable) == dsERR_NONE)
4773  {
4774 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
4775  printf("%s: persist MISteering value: %s\n", __func__, param->enable ? "Enabled":"Disabled");
4776  device::HostPersistence::getInstance().persistHostProperty("audio.MISteering",param->enable ? "Enabled":"Disabled");
4777 #endif
4778  result = IARM_RESULT_SUCCESS;
4779  }
4780  }
4781 
4782  IARM_BUS_Unlock(lock);
4783  return result;
4784 }
4785 
4786 
4787 IARM_Result_t _dsSetGraphicEqualizerMode(void *arg)
4788 {
4789 #ifndef RDK_DSHAL_NAME
4790 #warning "RDK_DSHAL_NAME is not defined"
4791 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
4792 #endif
4793  _DEBUG_ENTER();
4794  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
4795  IARM_BUS_Lock(lock);
4796 
4797  typedef dsError_t (*dsSetGraphicEqualizerMode_t)(intptr_t handle, int mode);
4798  static dsSetGraphicEqualizerMode_t func = 0;
4799  if (func == 0) {
4800  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
4801  if (dllib) {
4802  func = (dsSetGraphicEqualizerMode_t) dlsym(dllib, "dsSetGraphicEqualizerMode");
4803  if (func) {
4804  printf("dsSetGraphicEqualizerMode_t(int, int) is defined and loaded\r\n");
4805  }
4806  else {
4807  printf("dsSetGraphicEqualizerMode_t(int, int) is not defined\r\n");
4808  }
4809  dlclose(dllib);
4810  }
4811  else {
4812  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
4813  }
4814  }
4815 
4817 
4818  if (func != 0 && param != NULL)
4819  {
4820  if (func(param->handle, param->mode) == dsERR_NONE)
4821  {
4822 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
4823  std::string _GraphicEQ = std::to_string(param->mode);
4824  printf("%s: persist graphic equalizer value: %d\n",__func__, param->mode);
4825  device::HostPersistence::getInstance().persistHostProperty("audio.GraphicEQ",_GraphicEQ);
4826 #endif
4827  result = IARM_RESULT_SUCCESS;
4828  }
4829  }
4830 
4831  IARM_BUS_Unlock(lock);
4832  return result;
4833 }
4834 
4835 
4836 IARM_Result_t _dsGetGraphicEqualizerMode(void *arg)
4837 {
4838 #ifndef RDK_DSHAL_NAME
4839 #warning "RDK_DSHAL_NAME is not defined"
4840 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
4841 #endif
4842  _DEBUG_ENTER();
4843  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
4844  IARM_BUS_Lock(lock);
4845 
4846  typedef dsError_t (*dsGetGraphicEqualizerMode_t)(intptr_t handle, int *mode);
4847  static dsGetGraphicEqualizerMode_t func = 0;
4848  if (func == 0) {
4849  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
4850  if (dllib) {
4851  func = (dsGetGraphicEqualizerMode_t) dlsym(dllib, "dsGetGraphicEqualizerMode");
4852  if (func) {
4853  printf("dsGetGraphicEqualizerMode_t(int, int *) is defined and loaded\r\n");
4854  }
4855  else {
4856  printf("dsGetGraphicEqualizerMode_t(int, int *) is not defined\r\n");
4857  }
4858  dlclose(dllib);
4859  }
4860  else {
4861  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
4862  }
4863  }
4864 
4866 
4867  if (func != 0 && param != NULL)
4868  {
4869  int mode = 0;
4870  param->mode = 0;
4871  if (func(param->handle, &mode) == dsERR_NONE)
4872  {
4873  param->mode = mode;
4874  result = IARM_RESULT_SUCCESS;
4875  }
4876  }
4877 
4878  IARM_BUS_Unlock(lock);
4879  return result;
4880 }
4881 
4882 
4883 IARM_Result_t _dsGetMS12AudioProfileList(void *arg)
4884 {
4885 #ifndef RDK_DSHAL_NAME
4886 #warning "RDK_DSHAL_NAME is not defined"
4887 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
4888 #endif
4889  _DEBUG_ENTER();
4890  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
4891  IARM_BUS_Lock(lock);
4892 
4893  typedef dsError_t (*dsGetMS12AudioProfileList_t)(intptr_t handle, dsMS12AudioProfileList_t* profiles);
4894  static dsGetMS12AudioProfileList_t func = 0;
4895  if (func == 0) {
4896  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
4897  if (dllib) {
4898  func = (dsGetMS12AudioProfileList_t) dlsym(dllib, "dsGetMS12AudioProfileList");
4899  if (func) {
4900  printf("dsGetMS12AudioProfileList_t(int, dsMS12AudioProfileList_t*) is defined and loaded\r\n");
4901  }
4902  else {
4903  printf("dsGetMS12AudioProfileList_t(int, dsMS12AudioProfileList_t*) is not defined\r\n");
4904  }
4905  dlclose(dllib);
4906  }
4907  else {
4908  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
4909  }
4910  }
4911 
4914  dsError_t ret = dsERR_NONE;
4915  if (func != 0 && param != NULL)
4916  {
4917  ret = func(param->handle, &pList);
4918  if (ret == dsERR_NONE)
4919  {
4920  printf("%s: Total number of supported profiles: %d\n",__FUNCTION__, pList.audioProfileCount);
4921  printf("%s: Profile List: %s\n",__FUNCTION__, pList.audioProfileList);
4922 
4923  param->profileList.audioProfileCount = pList.audioProfileCount;
4924  strncpy(param->profileList.audioProfileList,pList.audioProfileList,MAX_PROFILE_LIST_BUFFER_LEN);
4925  result = IARM_RESULT_SUCCESS;
4926  }
4927  }
4928 
4929  IARM_BUS_Unlock(lock);
4930  return result;
4931 }
4932 
4933 
4934 IARM_Result_t _dsGetMS12AudioProfile(void *arg)
4935 {
4936 #ifndef RDK_DSHAL_NAME
4937 #warning "RDK_DSHAL_NAME is not defined"
4938 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
4939 #endif
4940  errno_t rc = -1;
4941  _DEBUG_ENTER();
4942  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
4943  IARM_BUS_Lock(lock);
4944 
4945  typedef dsError_t (*dsGetMS12AudioProfile_t)(intptr_t handle, char* profile);
4946  static dsGetMS12AudioProfile_t func = 0;
4947  if (func == 0) {
4948  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
4949  if (dllib) {
4950  func = (dsGetMS12AudioProfile_t) dlsym(dllib, "dsGetMS12AudioProfile");
4951  if (func) {
4952  printf("dsGetMS12AudioProfile_t(int, char* ) is defined and loaded\r\n");
4953  }
4954  else {
4955  printf("dsGetMS12AudioProfile_t(int, char*) is not defined\r\n");
4956  }
4957  dlclose(dllib);
4958  }
4959  else {
4960  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
4961  }
4962  }
4963 
4965  char m_profile[MAX_PROFILE_STRING_LEN] = {0};
4966  if (func != 0 && param != NULL)
4967  {
4968  if (func(param->handle, m_profile) == dsERR_NONE)
4969  {
4970  rc = strcpy_s(param->profile,sizeof(param->profile), m_profile);
4971  if(rc!=EOK)
4972  {
4973  ERR_CHK(rc);
4974  }
4975  result = IARM_RESULT_SUCCESS;
4976  }
4977  }
4978 
4979  IARM_BUS_Unlock(lock);
4980  return result;
4981 }
4982 
4983 
4984 IARM_Result_t _dsSetMS12AudioProfile(void *arg)
4985 {
4986 #ifndef RDK_DSHAL_NAME
4987 #warning "RDK_DSHAL_NAME is not defined"
4988 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
4989 #endif
4990  _DEBUG_ENTER();
4991  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
4992  IARM_BUS_Lock(lock);
4993 
4994  typedef dsError_t (*dsSetMS12AudioProfile_t)(intptr_t handle, const char* profile);
4995  static dsSetMS12AudioProfile_t func = 0;
4996  if (func == 0) {
4997  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
4998  if (dllib) {
4999  func = (dsSetMS12AudioProfile_t) dlsym(dllib, "dsSetMS12AudioProfile");
5000  if (func) {
5001  printf("dsSetMS12AudioProfile_t(int, const char*) is defined and loaded\r\n");
5002  }
5003  else {
5004  printf("dsSetMS12AudioProfile_t(int, const char*) is not defined\r\n");
5005  }
5006  dlclose(dllib);
5007  }
5008  else {
5009  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
5010  }
5011  }
5012 
5014 
5015  if (func != 0 && param != NULL)
5016  {
5017  if (func(param->handle, param->profile) == dsERR_NONE)
5018  {
5019 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
5020  printf("%s: persist MS12 Audio Profile selection : %s\n", __func__, param->profile);
5021  device::HostPersistence::getInstance().persistHostProperty("audio.MS12Profile",param->profile);
5022 #endif
5023  result = IARM_RESULT_SUCCESS;
5024  }
5025  }
5026 
5027  _dsMS12ProfileSettingOverride(param->handle);
5028 
5029  IARM_BUS_Unlock(lock);
5030  return result;
5031 }
5032 
5033 IARM_Result_t _dsSetAssociatedAudioMixing(void *arg)
5034 {
5035 #ifndef RDK_DSHAL_NAME
5036 #warning "RDK_DSHAL_NAME is not defined"
5037 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
5038 #endif
5039  _DEBUG_ENTER();
5040  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
5041  IARM_BUS_Lock(lock);
5042 
5043  typedef dsError_t (*dsSetAssociatedAudioMixing_t)(intptr_t handle, bool mixing);
5044  static dsSetAssociatedAudioMixing_t func = 0;
5045  if (func == 0) {
5046  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
5047  if (dllib) {
5048  func = (dsSetAssociatedAudioMixing_t) dlsym(dllib, "dsSetAssociatedAudioMixing");
5049  if (func) {
5050  printf("dsSetAssociatedAudioMixing_t(int, bool) is defined and loaded\r\n");
5051  }
5052  else {
5053  printf("dsSetMS12AudioProfile_t(int, bool) is not defined\r\n");
5054  }
5055  dlclose(dllib);
5056  }
5057  else {
5058  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
5059  }
5060  }
5061 
5063 
5064  if (func != 0 && param != NULL)
5065  {
5066  if (func(param->handle, param->mixing) == dsERR_NONE)
5067  {
5068 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
5069  printf("%s: persist Associated Audio Mixing status : %s\n", __func__, param->mixing ? "Enabled":"Disabled");
5070  device::HostPersistence::getInstance().persistHostProperty("audio.AssociatedAudioMixing",param->mixing ? "Enabled":"Disabled");
5071 #endif
5072  IARM_Bus_DSMgr_EventData_t associated_audio_mixing_event_data;
5073  printf("%s: Associated Audio Mixing status changed :%d \r\n", __FUNCTION__, param->mixing);
5074  associated_audio_mixing_event_data.data.AssociatedAudioMixingInfo.mixing = param->mixing;
5075 
5076  IARM_Bus_BroadcastEvent(IARM_BUS_DSMGR_NAME,
5078  (void *)&associated_audio_mixing_event_data,
5079  sizeof(associated_audio_mixing_event_data));
5080 
5081  result = IARM_RESULT_SUCCESS;
5082  }
5083  }
5084 
5085  IARM_BUS_Unlock(lock);
5086  return result;
5087 }
5088 
5089 IARM_Result_t _dsGetAssociatedAudioMixing(void *arg)
5090 {
5091 #ifndef RDK_DSHAL_NAME
5092 #warning "RDK_DSHAL_NAME is not defined"
5093 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
5094 #endif
5095  _DEBUG_ENTER();
5096  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
5097  IARM_BUS_Lock(lock);
5098 
5099  typedef dsError_t (*dsGetAssociatedAudioMixing_t)(intptr_t handle, bool *mixing);
5100  static dsGetAssociatedAudioMixing_t func = 0;
5101  if (func == 0) {
5102  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
5103  if (dllib) {
5104  func = (dsGetAssociatedAudioMixing_t) dlsym(dllib, "dsGetAssociatedAudioMixing");
5105  if (func) {
5106  printf("dsGetAssociatedAudioMixing_t(int, bool *) is defined and loaded\r\n");
5107  }
5108  else {
5109  printf("dsGetAssociatedAudioMixing_t(int, bool *) is not defined\r\n");
5110  }
5111  dlclose(dllib);
5112  }
5113  else {
5114  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
5115  }
5116  }
5117 
5119  bool mixing = false;
5120  if (func != 0 && param != NULL)
5121  {
5122  param->mixing = false;
5123  if (func(param->handle, &mixing) == dsERR_NONE)
5124  {
5125  param->mixing = mixing;
5126  result = IARM_RESULT_SUCCESS;
5127  }
5128  }
5129 
5130  IARM_BUS_Unlock(lock);
5131  return result;
5132 }
5133 
5134 IARM_Result_t _dsSetFaderControl(void *arg)
5135 {
5136 #ifndef RDK_DSHAL_NAME
5137 #warning "RDK_DSHAL_NAME is not defined"
5138 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
5139 #endif
5140  _DEBUG_ENTER();
5141  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
5142  IARM_BUS_Lock(lock);
5143 
5144  typedef dsError_t (*dsSetFaderControl_t)(intptr_t handle, int mixerbalance);
5145  static dsSetFaderControl_t func = 0;
5146 
5147  if (func == 0) {
5148  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
5149  if (dllib) {
5150  func = (dsSetFaderControl_t) dlsym(dllib, "dsSetFaderControl");
5151  if (func) {
5152  printf("dsSetFaderControl_t(int, int) is defined and loaded\r\n");
5153  }
5154  else {
5155  printf("dsSetFaderControl_t(int, int) is not defined\r\n");
5156  }
5157  dlclose(dllib);
5158  }
5159  else {
5160  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
5161  }
5162  }
5163 
5165 
5166  if (func != 0 && param != NULL)
5167  {
5168  if (func(param->handle, param->mixerbalance) == dsERR_NONE)
5169  {
5170 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
5171  std::string _mixerbalance = std::to_string(param->mixerbalance);
5172  printf("%s: persist fader control level: %d\n",__func__, param->mixerbalance);
5173  device::HostPersistence::getInstance().persistHostProperty("audio.FaderControl",_mixerbalance);
5174 #endif
5175  IARM_Bus_DSMgr_EventData_t fader_control_event_data;
5176  printf("%s: Fader Control changed :%d \r\n", __FUNCTION__, param->mixerbalance);
5177  fader_control_event_data.data.FaderControlInfo.mixerbalance = param->mixerbalance;
5178 
5179  IARM_Bus_BroadcastEvent(IARM_BUS_DSMGR_NAME,
5181  (void *)&fader_control_event_data,
5182  sizeof(fader_control_event_data));
5183 
5184  result = IARM_RESULT_SUCCESS;
5185  }
5186  }
5187 
5188  IARM_BUS_Unlock(lock);
5189  return result;
5190 }
5191 
5192 
5193 
5194 
5195 IARM_Result_t _dsGetFaderControl(void *arg)
5196 {
5197 #ifndef RDK_DSHAL_NAME
5198 #warning "RDK_DSHAL_NAME is not defined"
5199 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
5200 #endif
5201  _DEBUG_ENTER();
5202  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
5203  IARM_BUS_Lock(lock);
5204 
5205  typedef dsError_t (*dsGetFaderControl_t)(intptr_t handle, int *mixerbalance);
5206  static dsGetFaderControl_t func = 0;
5207  if (func == 0) {
5208  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
5209  if (dllib) {
5210  func = (dsGetFaderControl_t) dlsym(dllib, "dsGetFaderControl");
5211  if (func) {
5212  printf("dsGetFaderControl_t(int, int *) is defined and loaded\r\n");
5213  }
5214  else {
5215  printf("dsGetFaderControl_t(int, int *) is not defined\r\n");
5216  }
5217  dlclose(dllib);
5218  }
5219  else {
5220  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
5221  }
5222  }
5223 
5225  int mixerbalance = 0;
5226  if (func != 0 && param != NULL)
5227  {
5228  param->mixerbalance = 0;
5229  if (func(param->handle, &mixerbalance) == dsERR_NONE)
5230  {
5231  param->mixerbalance = mixerbalance;
5232  result = IARM_RESULT_SUCCESS;
5233  }
5234  }
5235 
5236  IARM_BUS_Unlock(lock);
5237  return result;
5238 }
5239 
5240 
5241 IARM_Result_t _dsSetPrimaryLanguage(void *arg)
5242 {
5243 #ifndef RDK_DSHAL_NAME
5244 #warning "RDK_DSHAL_NAME is not defined"
5245 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
5246 #endif
5247  _DEBUG_ENTER();
5248  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
5249  IARM_BUS_Lock(lock);
5250 
5251  typedef dsError_t (*dsSetPrimaryLanguage_t)(intptr_t handle, const char* pLang);
5252  static dsSetPrimaryLanguage_t func = 0;
5253  if (func == 0) {
5254  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
5255  if (dllib) {
5256  func = (dsSetPrimaryLanguage_t) dlsym(dllib, "dsSetPrimaryLanguage");
5257  if (func) {
5258  printf("dsSetPrimaryLanguage_t(int, const char*) is defined and loaded\r\n");
5259  }
5260  else {
5261  printf("dsSetPrimaryLanguage_t(int, const char*) is not defined\r\n");
5262  }
5263  dlclose(dllib);
5264  }
5265  else {
5266  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
5267  }
5268  }
5269 
5271 
5272  if (func != 0 && param != NULL)
5273  {
5274  if (func(param->handle, param->primaryLanguage) == dsERR_NONE)
5275  {
5276 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
5277  printf("%s: persist Primary Language : %s\n", __func__, param->primaryLanguage);
5278  device::HostPersistence::getInstance().persistHostProperty("audio.PrimaryLanguage",param->primaryLanguage);
5279 #endif
5280  IARM_Bus_DSMgr_EventData_t primary_language_event_data;
5281  printf("%s: Primary Language changed :%s \r\n", __FUNCTION__, param->primaryLanguage);
5282  memset(primary_language_event_data.data.AudioLanguageInfo.audioLanguage,'\0',MAX_LANGUAGE_LEN);
5283  strncpy(primary_language_event_data.data.AudioLanguageInfo.audioLanguage, param->primaryLanguage, MAX_LANGUAGE_LEN-1);
5284 
5285  IARM_Bus_BroadcastEvent(IARM_BUS_DSMGR_NAME,
5287  (void *)&primary_language_event_data,
5288  sizeof(primary_language_event_data));
5289 
5290  result = IARM_RESULT_SUCCESS;
5291  }
5292  }
5293 
5294  IARM_BUS_Unlock(lock);
5295  return result;
5296 }
5297 
5298 
5299 IARM_Result_t _dsGetPrimaryLanguage(void *arg)
5300 {
5301 #ifndef RDK_DSHAL_NAME
5302 #warning "RDK_DSHAL_NAME is not defined"
5303 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
5304 #endif
5305  errno_t rc = -1;
5306  _DEBUG_ENTER();
5307  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
5308  IARM_BUS_Lock(lock);
5309 
5310  typedef dsError_t (*dsGetPrimaryLanguage_t)(intptr_t handle, char* pLang);
5311  static dsGetPrimaryLanguage_t func = 0;
5312  if (func == 0) {
5313  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
5314  if (dllib) {
5315  func = (dsGetPrimaryLanguage_t) dlsym(dllib, "dsGetPrimaryLanguage");
5316  if (func) {
5317  printf("dsGetPrimaryLanguage_t(int, char* ) is defined and loaded\r\n");
5318  }
5319  else {
5320  printf("dsGetPrimaryLanguage_t(int, char*) is not defined\r\n");
5321  }
5322  dlclose(dllib);
5323  }
5324  else {
5325  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
5326  }
5327  }
5328 
5330  char primaryLanguage[MAX_LANGUAGE_LEN] = {0};
5331  if (func != 0 && param != NULL)
5332  {
5333  if (func(param->handle, primaryLanguage) == dsERR_NONE)
5334  {
5335  rc = strcpy_s(param->primaryLanguage,sizeof(param->primaryLanguage), primaryLanguage);
5336  if(rc!=EOK)
5337  {
5338  ERR_CHK(rc);
5339  }
5340  result = IARM_RESULT_SUCCESS;
5341  }
5342  }
5343 
5344  IARM_BUS_Unlock(lock);
5345  return result;
5346 }
5347 
5348 
5349 IARM_Result_t _dsSetSecondaryLanguage(void *arg)
5350 {
5351 #ifndef RDK_DSHAL_NAME
5352 #warning "RDK_DSHAL_NAME is not defined"
5353 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
5354 #endif
5355  _DEBUG_ENTER();
5356  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
5357  IARM_BUS_Lock(lock);
5358 
5359  typedef dsError_t (*dsSetSecondaryLanguage_t)(intptr_t handle, const char* sLang);
5360  static dsSetSecondaryLanguage_t func = 0;
5361  if (func == 0) {
5362  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
5363  if (dllib) {
5364  func = (dsSetSecondaryLanguage_t) dlsym(dllib, "dsSetSecondaryLanguage");
5365  if (func) {
5366  printf("dsSetSecondaryLanguage_t(int, const char*) is defined and loaded\r\n");
5367  }
5368  else {
5369  printf("dsSetSecondaryLanguage_t(int, const char*) is not defined\r\n");
5370  }
5371  dlclose(dllib);
5372  }
5373  else {
5374  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
5375  }
5376  }
5377 
5379 
5380  if (func != 0 && param != NULL)
5381  {
5382  if (func(param->handle, param->secondaryLanguage) == dsERR_NONE)
5383  {
5384 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
5385  printf("%s: persist Secondary Language : %s\n", __func__, param->secondaryLanguage);
5386  device::HostPersistence::getInstance().persistHostProperty("audio.SecondaryLanguage",param->secondaryLanguage);
5387 #endif
5388  IARM_Bus_DSMgr_EventData_t secondary_language_event_data;
5389  printf("%s: Secondary Language changed :%s \r\n", __FUNCTION__, param->secondaryLanguage);
5390  memset(secondary_language_event_data.data.AudioLanguageInfo.audioLanguage,'\0',MAX_LANGUAGE_LEN);
5391  strncpy(secondary_language_event_data.data.AudioLanguageInfo.audioLanguage, param->secondaryLanguage, MAX_LANGUAGE_LEN-1);
5392 
5393  IARM_Bus_BroadcastEvent(IARM_BUS_DSMGR_NAME,
5395  (void *)&secondary_language_event_data,
5396  sizeof(secondary_language_event_data));
5397 
5398  result = IARM_RESULT_SUCCESS;
5399  }
5400  }
5401 
5402  IARM_BUS_Unlock(lock);
5403  return result;
5404 }
5405 
5406 
5407 IARM_Result_t _dsGetSecondaryLanguage(void *arg)
5408 {
5409 #ifndef RDK_DSHAL_NAME
5410 #warning "RDK_DSHAL_NAME is not defined"
5411 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
5412 #endif
5413  errno_t rc = -1;
5414  _DEBUG_ENTER();
5415  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
5416  IARM_BUS_Lock(lock);
5417 
5418  typedef dsError_t (*dsGetSecondaryLanguage_t)(intptr_t handle, char* sLang);
5419  static dsGetSecondaryLanguage_t func = 0;
5420  if (func == 0) {
5421  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
5422  if (dllib) {
5423  func = (dsGetSecondaryLanguage_t) dlsym(dllib, "dsGetSecondaryLanguage");
5424  if (func) {
5425  printf("dsGetSecondaryLanguage_t(int, char* ) is defined and loaded\r\n");
5426  }
5427  else {
5428  printf("dsGetSecondaryLanguage_t(int, char*) is not defined\r\n");
5429  }
5430  dlclose(dllib);
5431  }
5432  else {
5433  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
5434  }
5435  }
5436 
5438  char secondaryLanguage[MAX_LANGUAGE_LEN] = {0};
5439  if (func != 0 && param != NULL)
5440  {
5441  if (func(param->handle, secondaryLanguage) == dsERR_NONE)
5442  {
5443  rc = strcpy_s(param->secondaryLanguage,sizeof(param->secondaryLanguage), secondaryLanguage);
5444  if(rc!=EOK)
5445  {
5446  ERR_CHK(rc);
5447  }
5448  result = IARM_RESULT_SUCCESS;
5449  }
5450  }
5451 
5452  IARM_BUS_Unlock(lock);
5453  return result;
5454 }
5455 
5456 IARM_Result_t _dsSetMS12SetttingsOverride(void *arg)
5457 {
5458 #ifndef RDK_DSHAL_NAME
5459 #warning "RDK_DSHAL_NAME is not defined"
5460 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
5461 #endif
5462  _DEBUG_ENTER();
5463  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
5464  IARM_BUS_Lock(lock);
5466  std::string _hostProperty;
5467  std::string _value;
5468  std::string _AProfile("Off");
5469 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
5470  if(!(_dsMs12ProfileSupported(param->handle,param->profileName))) {
5471  printf("%s: Unknow MS12 profile %s \n",__func__, param->profileName);
5472  IARM_BUS_Unlock(lock);
5473  return result;
5474  }
5475  try {
5476  _AProfile = device::HostPersistence::getInstance().getProperty("audio.MS12Profile");
5477  }
5478  catch(...) {
5479  try {
5480  printf("audio.MS12Profile not found in persistence store. Try system default\n");
5481  _AProfile = device::HostPersistence::getInstance().getDefaultProperty("audio.MS12Profile");
5482  }
5483  catch(...) {
5484  _AProfile = "Off";
5485  }
5486  }
5487 
5488  if(strcmp(param->profileName,_AProfile.c_str()) == 0) {
5489  if(strcmp(param->profileSettingsName, "DialogEnhance") == 0) {
5490  if(strcmp(param->profileState, "ADD") == 0) {
5491  result = _setDialogEnhancement(param->handle,atoi(param->profileSettingValue));
5492  }
5493  else if(strcmp(param->profileState, "REMOVE") == 0) {
5494  result = _resetDialogEnhancerLevel(param->handle);
5495  }
5496  }
5497  else if(strcmp(param->profileSettingsName, "VolumeLevellerMode") == 0) {
5498  std::string _PropertyMode = _dsGetCurrentProfileProperty("VolumeLeveller.mode");
5499  if((atoi(param->profileSettingValue) == 0) || (atoi(param->profileSettingValue) == 1)) {
5500  device::HostPersistence::getInstance().persistHostProperty(_PropertyMode,param->profileSettingValue);
5501  result = IARM_RESULT_SUCCESS;
5502  }else {
5503  printf("%s: Unknow MS12 property value %s %s \n",__func__, param->profileSettingsName,param->profileSettingValue);
5504  result = IARM_RESULT_INVALID_STATE;
5505  }
5506  }
5507  else if(strcmp(param->profileSettingsName, "VolumeLevellerLevel") == 0) {
5508  if(strcmp(param->profileState, "ADD") == 0) {
5509  std::string _volLevellerMode("0");
5510  std::string _PropertyMode = _dsGetCurrentProfileProperty("VolumeLeveller.mode");
5511  _volLevellerMode = device::HostPersistence::getInstance().getProperty(_PropertyMode);
5512  result = _setVolumeLeveller(param->handle,atoi(_volLevellerMode.c_str()),atoi(param->profileSettingValue));
5513  }
5514  else if(strcmp(param->profileState, "REMOVE") == 0) {
5515  result = _resetVolumeLeveller(param->handle);
5516  }
5517  }
5518  else if(strcmp(param->profileSettingsName, "BassEnhancer") == 0) {
5519  if(strcmp(param->profileState, "ADD") == 0) {
5520  result = _setBassEnhancer(param->handle,atoi(param->profileSettingValue));
5521  }
5522  else if(strcmp(param->profileState, "REMOVE") == 0) {
5523  result = _resetBassEnhancer(param->handle);
5524  }
5525  }
5526  else if(strcmp(param->profileSettingsName, "SurroundVirtualizerMode") == 0) {
5527  std::string _PropertyMode = _dsGetCurrentProfileProperty("SurroundVirtualizer.mode");
5528  if((atoi(param->profileSettingValue) >= 0) && (atoi(param->profileSettingValue) <= 2)) {
5529  device::HostPersistence::getInstance().persistHostProperty(_PropertyMode,param->profileSettingValue);
5530  result = IARM_RESULT_SUCCESS;
5531  }
5532  else {
5533  printf("%s: Unknow MS12 property value %s %s \n",__func__, param->profileSettingsName,param->profileSettingValue);
5534  result = IARM_RESULT_INVALID_STATE;
5535  }
5536  }
5537  else if(strcmp(param->profileSettingsName, "SurroundVirtualizerLevel") == 0) {
5538  if(strcmp(param->profileState, "ADD") == 0) {
5539  std::string _SVMode("0");
5540  std::string _PropertyMode = _dsGetCurrentProfileProperty("SurroundVirtualizer.mode");
5541  _SVMode = device::HostPersistence::getInstance().getProperty(_PropertyMode);
5542  result = _setSurroundVirtualizer(param->handle,atoi(_SVMode.c_str()),atoi(param->profileSettingValue));
5543  }
5544  else if(strcmp(param->profileState, "REMOVE") == 0) {
5545  result = _resetSurroundVirtualizer(param->handle);
5546  }
5547  }
5548  else {
5549  printf("%s: Unknow MS12 property %s \n",__func__, param->profileSettingsName);
5550  result = IARM_RESULT_INVALID_STATE;
5551  }
5552  if(result != IARM_RESULT_SUCCESS)
5553  {
5554  IARM_BUS_Unlock(lock);
5555  return result;
5556  }
5557  }
5558  else {
5559  if(strcmp(param->profileSettingsName, "DialogEnhance") == 0) {
5560  _hostProperty = _dsGenerateProfileProperty(param->profileName,"EnhancerLevel");
5561  }
5562  else if(strcmp(param->profileSettingsName, "VolumeLevellerMode") == 0) {
5563  _hostProperty = _dsGenerateProfileProperty(param->profileName,"VolumeLeveller.mode");
5564  }
5565  else if(strcmp(param->profileSettingsName, "VolumeLevellerLevel") == 0) {
5566  _hostProperty = _dsGenerateProfileProperty(param->profileName,"VolumeLeveller.level");
5567  }
5568  else if(strcmp(param->profileSettingsName, "BassEnhancer") == 0) {
5569  _hostProperty = "audio.BassBoost";
5570  }
5571  else if(strcmp(param->profileSettingsName, "SurroundVirtualizerMode") == 0) {
5572  _hostProperty = _dsGenerateProfileProperty(param->profileName,"SurroundVirtualizer.mode");
5573  }
5574  else if(strcmp(param->profileSettingsName, "SurroundVirtualizerLevel") == 0) {
5575  _hostProperty = _dsGenerateProfileProperty(param->profileName,"SurroundVirtualizer.boost");
5576  }
5577  else {
5578  printf("%s: Unknow MS12 property %s \n",__func__, param->profileSettingsName);
5579  IARM_BUS_Unlock(lock);
5580  return result;
5581  }
5582  if(strcmp(param->profileState, "ADD") == 0) {
5583  printf("%s: Profile %s property %s persist value: %s\n",__func__,param->profileName, param->profileSettingsName , param->profileSettingValue);
5584  device::HostPersistence::getInstance().persistHostProperty(_hostProperty ,param->profileSettingValue);
5585  }
5586  else if(strcmp(param->profileState, "REMOVE") == 0) {
5587  try {
5588  _value = device::HostPersistence::getInstance().getDefaultProperty(_hostProperty);
5589  }
5590  catch(...) {
5591  _value = "0";
5592  }
5593  printf("%s: Profile %s property %s persist value: %s\n",__func__,param->profileName, param->profileSettingsName , _value.c_str());
5595  }
5596  else {
5597  printf("%s: Unknow State %s \n",__func__, param->profileState);
5598  IARM_BUS_Unlock(lock);
5599  return result;
5600  }
5601  }
5602  result = IARM_RESULT_SUCCESS;
5603 #endif
5604  IARM_BUS_Unlock(lock);
5605  return result;
5606 }
5607 
5608 IARM_Result_t _dsGetSupportedARCTypes(void *arg)
5609 {
5610 #ifndef RDK_DSHAL_NAME
5611 #warning "RDK_DSHAL_NAME is not defined"
5612 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
5613 #endif
5614  _DEBUG_ENTER();
5615  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
5616  IARM_BUS_Lock(lock);
5617 
5618  typedef dsError_t (*dsGetSupportedARCTypes_t)(intptr_t handle, int *types);
5619  static dsGetSupportedARCTypes_t func = 0;
5620  if (func == 0) {
5621  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
5622  if (dllib) {
5623  func = (dsGetSupportedARCTypes_t) dlsym(dllib, "dsGetSupportedARCTypes");
5624  if (func) {
5625  printf("dsGetSupportedARCTypes_t(int, int*) is defined and loaded\r\n");
5626  }
5627  else {
5628  printf("dsGetSupportedARCTypes_t(int, int*) is not defined\r\n");
5629  }
5630  dlclose(dllib);
5631  }
5632  else {
5633  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
5634  }
5635  }
5636 
5638  int types = dsAUDIOARCSUPPORT_NONE;
5639 
5640  if (func != 0 && param != NULL)
5641  {
5642  param->types = dsAUDIOARCSUPPORT_NONE; //CID:163840 - Reverse_inull
5643  if (func(param->handle, &types) == dsERR_NONE)
5644  {
5645  param->types = types;
5646  result = IARM_RESULT_SUCCESS;
5647  }
5648  }
5649 
5650  IARM_BUS_Unlock(lock);
5651  return result;
5652 }
5653 
5654 
5655 IARM_Result_t _dsAudioSetSAD(void *arg)
5656 {
5657 #ifndef RDK_DSHAL_NAME
5658 #warning "RDK_DSHAL_NAME is not defined"
5659 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
5660 #endif
5661  _DEBUG_ENTER();
5662  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
5663  IARM_BUS_Lock(lock);
5664 
5665  typedef dsError_t (*dsAudioSetSAD_t)(intptr_t handle, dsAudioSADList_t sad_list);
5666  static dsAudioSetSAD_t func = 0;
5667  if (func == 0) {
5668  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
5669  if (dllib) {
5670  func = (dsAudioSetSAD_t) dlsym(dllib, "dsAudioSetSAD");
5671  if (func) {
5672  printf("dsAudioSetSAD_t(int, dsAudioSADList_t) is defined and loaded\r\n");
5673  }
5674  else {
5675  printf("dsAudioSetSAD_t(int, dsAudioSADList_t) is not defined\r\n");
5676  }
5677  dlclose(dllib);
5678  }
5679  else {
5680  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
5681  }
5682  }
5683 
5685 
5686  if (func != 0 && param != NULL)
5687  {
5688  if (func(param->handle, param->list) == dsERR_NONE)
5689  {
5690  result = IARM_RESULT_SUCCESS;
5691  }
5692  }
5693 
5694  IARM_BUS_Unlock(lock);
5695  return result;
5696 }
5697 
5698 IARM_Result_t _dsAudioEnableARC(void *arg)
5699 {
5700 #ifndef RDK_DSHAL_NAME
5701 #warning "RDK_DSHAL_NAME is not defined"
5702 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
5703 #endif
5704  _DEBUG_ENTER();
5705  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
5706  IARM_BUS_Lock(lock);
5707 
5708  dsError_t ret = dsERR_GENERAL;
5709  std::string _isEnabledAudoARCPortKey("audio.hdmiArc0.isEnabled");
5710  std::string _audoARCPortTypeKey("audio.hdmiArc0.type");
5711  //Default is eARC
5712  std::string _audoARCPortiCapVal("eARC");
5713 
5714 
5715  typedef dsError_t (*dsAudioEnableARC_t)(intptr_t handle, dsAudioARCStatus_t arcStatus);
5716  static dsAudioEnableARC_t func = 0;
5717  if (func == 0) {
5718  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
5719  if (dllib) {
5720  func = (dsAudioEnableARC_t) dlsym(dllib, "dsAudioEnableARC");
5721  if (func) {
5722  printf("dsAudioEnableARC_t(int, dsAudioARCStatus_t) is defined and loaded\r\n");
5723  }
5724  else {
5725  printf("dsAudioEnableARC_t(int, dsAudioARCStatus_t) is not defined\r\n");
5726  }
5727  dlclose(dllib);
5728  }
5729  else {
5730  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
5731  }
5732  }
5733 
5735 
5736  if (func != 0 && param != NULL)
5737  {
5738  if (func(param->handle, param->arcStatus) == dsERR_NONE)
5739  {
5740  result = IARM_RESULT_SUCCESS;
5741  }
5742 
5743 
5744 
5745  /*Ensure settings is enabled properly in HAL*/
5746  ret = dsERR_NONE;
5747  bool bAudioPortEnableVerify = false;
5748  ret = (dsError_t) dsIsAudioPortEnabled (param->handle, &bAudioPortEnableVerify);
5749  if(dsERR_NONE == ret) {
5750  if (bAudioPortEnableVerify != param->arcStatus.status) {
5751  printf("Init: %s : %s Audio port status:%s verification failed. bAudioPortEnable: %d bAudioPortEnableVerify:%d\n",
5752  __FUNCTION__, _audoARCPortTypeKey.c_str(), _isEnabledAudoARCPortKey.c_str(), param->arcStatus.status, bAudioPortEnableVerify);
5753  }
5754  else {
5755  printf("%s : %s Audio port status verification passed. status %d\n",
5756  __FUNCTION__, _isEnabledAudoARCPortKey.c_str(), param->arcStatus.status);
5757  }
5758  }
5759  else {
5760  printf("Init: %s : %s Audio port status:%s verification step: dsIsAudioPortEnabled call failed\n",
5761  __FUNCTION__, _audoARCPortTypeKey.c_str(), _isEnabledAudoARCPortKey.c_str());
5762  }
5763 
5764  }
5765 
5766  IARM_BUS_Unlock(lock);
5767  return result;
5768 }
5769 
5770 IARM_Result_t _dsEnableLEConfig(void *arg)
5771 {
5772 
5773 #ifndef RDK_DSHAL_NAME
5774  #warning "RDK_DSHAL_NAME is not defined"
5775  #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
5776 #endif
5777  _DEBUG_ENTER();
5778  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
5779 
5780  IARM_BUS_Lock(lock);
5781 
5782  typedef dsError_t (*dsEnableLEConfig_t)(intptr_t handle,const bool enable);
5783  static dsEnableLEConfig_t func = NULL;
5784  if (func == NULL) {
5785  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
5786  if (dllib) {
5787  func = (dsEnableLEConfig_t) dlsym(dllib, "dsEnableLEConfig");
5788  if (func) {
5789  __TIMESTAMP();printf("dsEnableLEConfig(int, bool) is defined and loaded\r\n");
5790  }
5791  else {
5792  __TIMESTAMP();printf("dsEnableLEConfig(int, bool) is not defined\r\n");
5793  }
5794  dlclose(dllib);
5795  }
5796  else {
5797  __TIMESTAMP();printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
5798  }
5799  }
5800 
5801  _dsLEConfigParam_t *param = (_dsLEConfigParam_t *)arg;
5802  if (func != NULL) {
5803  __TIMESTAMP();printf("LE: %s enable status:%d \r\n",__FUNCTION__,param->enable);
5804 
5805  if(param->enable != m_LEEnabled)
5806  {
5807  m_LEEnabled = param->enable;
5808  //Persist DAPV2 setting
5809  if(m_LEEnabled)
5810  device::HostPersistence::getInstance().persistHostProperty("audio.LEEnable","TRUE");
5811  else
5812  device::HostPersistence::getInstance().persistHostProperty("audio.LEEnable","FALSE");
5813 
5814  dsError_t ret = func(param->handle, param->enable);
5815  if (ret == dsERR_NONE) {
5816  result = IARM_RESULT_SUCCESS;
5817  }
5818  }
5819  else
5820  {
5821  __TIMESTAMP();printf("LE: %s Current enable status is same as requested:%d \r\n",__FUNCTION__,param->enable);
5822  result = IARM_RESULT_SUCCESS;
5823  }
5824  }
5825 
5826  IARM_BUS_Unlock(lock);
5827 
5828  return result;
5829 }
5830 
5831 IARM_Result_t _dsGetLEConfig(void *arg)
5832 {
5833 
5834 #ifndef RDK_DSHAL_NAME
5835  #warning "RDK_DSHAL_NAME is not defined"
5836  #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
5837 #endif
5838  _DEBUG_ENTER();
5839 
5840  IARM_BUS_Lock(lock);
5841 
5842  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
5843  typedef dsError_t (*dsGetLEConfig_t)(intptr_t handle, bool *enable);
5844  static dsGetLEConfig_t func = NULL;
5845  if (func == NULL) {
5846  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
5847  if (dllib) {
5848  func = (dsGetLEConfig_t) dlsym(dllib, "dsGetLEConfig");
5849  if (func) {
5850  __TIMESTAMP();printf("dsGetLEConfig(int , bool *) is defined and loaded\r\n");
5851  }
5852  else {
5853  __TIMESTAMP();printf("dsGetLEConfig(int , bool *) is not defined\r\n");
5854  }
5855  dlclose(dllib);
5856  }
5857  else {
5858  __TIMESTAMP();printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
5859  }
5860  }
5861 
5863  if (param != NULL) {
5864  param->result = dsERR_GENERAL;
5865 
5866  if (func != NULL) {
5867  param->result = func(param->handle, &param->enable);
5868  if(param->result == dsERR_NONE) {
5869  result = IARM_RESULT_SUCCESS;
5870  }
5871  }
5872  }
5873 
5874 
5875  IARM_BUS_Unlock(lock);
5876 
5877  return result;
5878 
5879 }
5880 
5881 static void _GetAudioModeFromPersistent(void *arg)
5882 {
5883  _DEBUG_ENTER();
5884 
5886 
5887  if (param != NULL)
5888  {
5889  dsAudioPortType_t _APortType = _GetAudioPortType(param->handle);
5890  std::string _AudioModeSettings("STEREO");
5891 
5892  if (_APortType == dsAUDIOPORT_TYPE_SPDIF)
5893  {
5894  _AudioModeSettings = device::HostPersistence::getInstance().getProperty("SPDIF0.AudioMode",_AudioModeSettings);
5895  __TIMESTAMP();printf("The SPDIF Audio Mode Setting From Persistent is %s \r\n",_AudioModeSettings.c_str());
5896  }
5897  else if (_APortType == dsAUDIOPORT_TYPE_HDMI) {
5898  _AudioModeSettings = device::HostPersistence::getInstance().getProperty("HDMI0.AudioMode",_AudioModeSettings);
5899  __TIMESTAMP();printf("The HDMI Audio Mode Setting From Persistent is %s \r\n",_AudioModeSettings.c_str());
5900  }
5901  else if (_APortType == dsAUDIOPORT_TYPE_HDMI_ARC){
5902  _AudioModeSettings = device::HostPersistence::getInstance().getProperty("HDMI_ARC0.AudioMode",_AudioModeSettings);
5903  __TIMESTAMP();printf("The HDMI_ARC Audio Mode Setting From Persistent is %s \r\n",_AudioModeSettings.c_str());
5904  }
5905 
5906  if (_AudioModeSettings.compare("SURROUND") == 0)
5907  {
5908  param->mode = dsAUDIO_STEREO_SURROUND;
5909  }
5910  else if (_AudioModeSettings.compare("PASSTHRU") == 0)
5911  {
5912  param->mode = dsAUDIO_STEREO_PASSTHRU;
5913  }
5914  else if (_AudioModeSettings.compare("DOLBYDIGITAL") == 0)
5915  {
5916  param->mode = dsAUDIO_STEREO_DD;
5917  }
5918  else if (_AudioModeSettings.compare("DOLBYDIGITALPLUS") == 0)
5919  {
5920  param->mode = dsAUDIO_STEREO_DDPLUS;
5921  }
5922  else
5923  {
5924  param->mode = dsAUDIO_STEREO_STEREO;
5925  }
5926  }
5927 }
5928 
5929 IARM_Result_t _dsGetAudioCapabilities(void *arg)
5930 {
5931  _DEBUG_ENTER();
5932 
5933  IARM_BUS_Lock(lock);
5934 
5935  typedef dsError_t (*dsGetAudioCapabilitiesFunc_t)(intptr_t handle, int *capabilities);
5936  static dsGetAudioCapabilitiesFunc_t func = 0;
5937  if (func == 0) {
5938  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
5939  if (dllib) {
5940  func = (dsGetAudioCapabilitiesFunc_t)dlsym(dllib, "dsGetAudioCapabilities");
5941  if (func) {
5942  printf("dsGetAudioCapabilities() is defined and loaded\r\n");
5943  }
5944  else {
5945  printf("dsGetAudioCapabilities() is not defined\r\n");
5946  }
5947  dlclose(dllib);
5948  }
5949  else {
5950  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
5951  }
5952  }
5954  if(0 != func) {
5955  param->result = func(param->handle, &param->capabilities);
5956  }
5957  else {
5958  param->capabilities = dsAUDIOSUPPORT_NONE;
5959  }
5960 
5961  IARM_BUS_Unlock(lock);
5962  return IARM_RESULT_SUCCESS;
5963 }
5964 
5965 
5966 IARM_Result_t _dsGetMS12Capabilities(void *arg)
5967 {
5968  _DEBUG_ENTER();
5969 
5970  IARM_BUS_Lock(lock);
5971 
5972  typedef dsError_t (*dsGetMS12CapabilitiesFunc_t)(intptr_t handle, int *capabilities);
5973  static dsGetMS12CapabilitiesFunc_t func = 0;
5974  if (func == 0) {
5975  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
5976  if (dllib) {
5977  func = (dsGetMS12CapabilitiesFunc_t)dlsym(dllib, "dsGetMS12Capabilities");
5978  if (func) {
5979  printf("dsGetMS12Capabilities() is defined and loaded\r\n");
5980  }
5981  else {
5982  printf("dsGetMS12Capabilities() is not defined\r\n");
5983  }
5984  dlclose(dllib);
5985  }
5986  else {
5987  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
5988  }
5989  }
5991  if(0 != func) {
5992  param->result = func(param->handle, &param->capabilities);
5993  }
5994  else {
5995  param->capabilities = dsMS12SUPPORT_NONE;
5996  }
5997 
5998  IARM_BUS_Unlock(lock);
5999  return IARM_RESULT_SUCCESS;
6000 }
6001 
6002 void _dsAudioOutPortConnectCB(dsAudioPortType_t portType, unsigned int uiPortNo, bool isPortConnected)
6003 {
6004  IARM_Bus_DSMgr_EventData_t audio_out_hpd_eventData;
6005  printf("%s: AudioOutPort type:%d portNo:%d Hotplug happened\r\n",
6006  __FUNCTION__, portType, uiPortNo);
6007  audio_out_hpd_eventData.data.audio_out_connect.portType = portType;
6008  audio_out_hpd_eventData.data.audio_out_connect.uiPortNo = uiPortNo;
6009  audio_out_hpd_eventData.data.audio_out_connect.isPortConnected = isPortConnected;
6010 
6011  IARM_Bus_BroadcastEvent(IARM_BUS_DSMGR_NAME,
6013  (void *)&audio_out_hpd_eventData,
6014  sizeof(audio_out_hpd_eventData));
6015  printf ("%s portType%d uiPortNo:%d isPortConnected:%d",
6016  __FUNCTION__, portType, uiPortNo, isPortConnected);
6017 }
6018 
6019 static dsError_t _dsAudioOutRegisterConnectCB (dsAudioOutPortConnectCB_t cbFun) {
6020  dsError_t eRet = dsERR_GENERAL;
6021  printf("%s: %d - Inside \n", __FUNCTION__, __LINE__);
6022 
6023  typedef dsError_t (*dsAudioOutRegisterConnectCB_t)(dsAudioOutPortConnectCB_t cbFunArg);
6024  static dsAudioOutRegisterConnectCB_t dsAudioOutRegisterConnectCBFun = 0;
6025  if (dsAudioOutRegisterConnectCBFun == 0) {
6026  printf("%s: %d - dlerror: %s\n", __FUNCTION__, __LINE__, dlerror());
6027  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
6028  if (dllib) {
6029  dsAudioOutRegisterConnectCBFun = (dsAudioOutRegisterConnectCB_t) dlsym(dllib, "dsAudioOutRegisterConnectCB");
6030  if(dsAudioOutRegisterConnectCBFun == 0) {
6031  printf("%s: dsAudioOutRegisterConnectCB (int) is not defined %s\r\n", __FUNCTION__, dlerror());
6032  eRet = dsERR_GENERAL;
6033  }
6034  else {
6035  printf("%s: dsAudioOutRegisterConnectCB is loaded\r\n", __FUNCTION__);
6036  }
6037  dlclose(dllib);
6038  }
6039  else {
6040  printf("%s: Opening RDK_DSHAL_NAME [%s] failed %s\r\n",
6041  __FUNCTION__, RDK_DSHAL_NAME, dlerror());
6042  eRet = dsERR_GENERAL;
6043  }
6044  }
6045  if (0 != dsAudioOutRegisterConnectCBFun) {
6046  eRet = dsAudioOutRegisterConnectCBFun (cbFun);
6047  printf("%s: dsAudioOutRegisterConnectCBFun registered\r\n", __FUNCTION__);
6048  }
6049  else {
6050  printf("%s: dsAudioOutRegisterConnectCBFun NULL\r\n", __FUNCTION__);
6051  }
6052  return eRet;
6053 }
6054 
6055 IARM_Result_t _dsAudioOutIsConnected (void *arg) {
6056  _DEBUG_ENTER();
6057  IARM_BUS_Lock(lock);
6058 
6059  IARM_Result_t eIarmRet = IARM_RESULT_INVALID_PARAM;
6061  dsError_t eRet = dsERR_GENERAL;
6062  //By default all audio ports are connected
6063  bool isConnected = true;
6064  param->isCon = true;
6065 
6066  printf("%s: %d - Inside \n", __FUNCTION__, __LINE__);
6067 
6068  typedef dsError_t (*dsAudioOutIsConnected_t)(intptr_t handleArg, bool* pisConArg);
6069  static dsAudioOutIsConnected_t dsAudioOutIsConFunc = 0;
6070  if (dsAudioOutIsConFunc == 0) {
6071  printf("%s: %d - dlerror:%s\n", __FUNCTION__, __LINE__, dlerror());
6072  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
6073  if (dllib) {
6074  dsAudioOutIsConFunc = (dsAudioOutIsConnected_t) dlsym(dllib, "dsAudioOutIsConnected");
6075  if(dsAudioOutIsConFunc == 0) {
6076  printf("%s: dsAudioOutIsConnected is not defined %s\r\n", __FUNCTION__, dlerror());
6077  eRet = dsERR_GENERAL;
6078  }
6079  else {
6080  printf("%s: dsAudioOutIsConnected is loaded\r\n", __FUNCTION__);
6081  }
6082  dlclose(dllib);
6083  }
6084  else {
6085  printf("%s: Opening RDK_DSHAL_NAME [%s] failed %s\r\n",
6086  __FUNCTION__, RDK_DSHAL_NAME, dlerror());
6087  eRet = dsERR_GENERAL;
6088  }
6089  }
6090  if (0 != dsAudioOutIsConFunc) {
6091  eRet = dsAudioOutIsConFunc (param->handle, &isConnected);
6092  printf("%s: pisCon:%d eRet:%04x\r\n",
6093  __FUNCTION__, isConnected, eRet);
6094  }
6095  else {
6096  printf("%s: dsAudioOutIsConFunc NULL\n", __FUNCTION__);
6097  }
6098 
6099  param->result = eRet;
6100  if (dsERR_NONE == eRet) {
6101  param->isCon = isConnected;
6102  eIarmRet = IARM_RESULT_SUCCESS;
6103  }
6104 
6105 
6106  IARM_BUS_Unlock(lock);
6107  return eIarmRet;
6108 }
6109 
6110 void _dsAudioFormatUpdateCB(dsAudioFormat_t audioFormat)
6111 {
6112  IARM_Bus_DSMgr_EventData_t audio_format_event_data;
6113  printf("%s: AudioOutPort format:%d \r\n", __FUNCTION__, audioFormat);
6114  audio_format_event_data.data.AudioFormatInfo.audioFormat = audioFormat;
6115 
6116  IARM_Bus_BroadcastEvent(IARM_BUS_DSMGR_NAME,
6118  (void *)&audio_format_event_data,
6119  sizeof(audio_format_event_data));
6120 }
6121 
6122 static dsError_t _dsAudioFormatUpdateRegisterCB (dsAudioFormatUpdateCB_t cbFun) {
6123  dsError_t eRet = dsERR_GENERAL;
6124  printf("%s: %d - Inside \n", __FUNCTION__, __LINE__);
6125 
6126  typedef dsError_t (*dsAudioFormatUpdateRegisterCB_t)(dsAudioFormatUpdateCB_t cbFunArg);
6127  static dsAudioFormatUpdateRegisterCB_t dsAudioFormatUpdateRegisterCBFun = 0;
6128  if (dsAudioFormatUpdateRegisterCBFun == 0) {
6129  printf("%s: %d - dlerror: %s\n", __FUNCTION__, __LINE__, dlerror());
6130  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
6131  if (dllib) {
6132  dsAudioFormatUpdateRegisterCBFun = (dsAudioFormatUpdateRegisterCB_t) dlsym(dllib, "dsAudioFormatUpdateRegisterCB");
6133  if(dsAudioFormatUpdateRegisterCBFun == 0) {
6134  printf("%s: dsAudioFormatUpdateRegisterCB is not defined %s\r\n", __FUNCTION__, dlerror());
6135  eRet = dsERR_GENERAL;
6136  }
6137  else {
6138  printf("%s: dsAudioFormatUpdateRegisterCB is loaded\r\n", __FUNCTION__);
6139  }
6140  dlclose(dllib);
6141  }
6142  else {
6143  printf("%s: Opening RDK_DSHAL_NAME [%s] failed %s\r\n",
6144  __FUNCTION__, RDK_DSHAL_NAME, dlerror());
6145  eRet = dsERR_GENERAL;
6146  }
6147  }
6148  if (0 != dsAudioFormatUpdateRegisterCBFun) {
6149  eRet = dsAudioFormatUpdateRegisterCBFun (cbFun);
6150  printf("%s: dsAudioFormatUpdateRegisterCBFun registered\r\n", __FUNCTION__);
6151  }
6152  else {
6153  printf("%s: dsAudioFormatUpdateRegisterCBFun NULL\r\n", __FUNCTION__);
6154  }
6155 
6156  return eRet;
6157 }
6158 
6159 IARM_Result_t _dsResetBassEnhancer(void *arg)
6160 {
6161  _DEBUG_ENTER();
6162  IARM_BUS_Lock(lock);
6163 
6164  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
6165  intptr_t *handle = (intptr_t*)arg;
6166  result = _resetBassEnhancer(*handle);
6167  IARM_BUS_Unlock(lock);
6168  return result;
6169 
6170 }
6171 
6172 static IARM_Result_t _resetBassEnhancer(intptr_t handle)
6173 {
6174  typedef dsError_t (*dsSetBassEnhancer_t)(intptr_t handle, int boost);
6175  static dsSetBassEnhancer_t func = 0;
6176  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
6177  if (func == 0) {
6178  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
6179  if (dllib) {
6180  func = (dsSetBassEnhancer_t) dlsym(dllib, "dsSetBassEnhancer");
6181  if (func) {
6182  printf("dsSetBassEnhancer_t(int, int) is defined and loaded\r\n");
6183  }
6184  else {
6185  printf("dsSetBassEnhancer_t(int, int) is not defined\r\n");
6186  }
6187  dlclose(dllib);
6188  }
6189  else {
6190  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
6191  }
6192  }
6193 
6194 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
6195  if (func != 0) {
6196  std::string _Property = _dsGetCurrentProfileProperty("BassBoost");
6197  std::string _BassBoost("0");
6198  int m_bassBoost = 0;
6199  try {
6200  _BassBoost = device::HostPersistence::getInstance().getDefaultProperty(_Property);
6201  }
6202  catch(...) {
6203  _BassBoost = "0";
6204  }
6205  m_bassBoost = atoi(_BassBoost.c_str());
6206 
6207  if (func(handle,m_bassBoost) == dsERR_NONE) {
6208  printf("%s:%s Initialized Bass Boost : %d\n",__func__, _Property.c_str(), m_bassBoost);
6209  device::HostPersistence::getInstance().persistHostProperty("audio.BassBoost" ,_BassBoost);
6210  result = IARM_RESULT_SUCCESS;
6211  }
6212  }
6213 #endif
6214  return result;
6215 }
6216 
6217 IARM_Result_t _dsResetVolumeLeveller(void *arg)
6218 {
6219  _DEBUG_ENTER();
6220  IARM_BUS_Lock(lock);
6221  intptr_t *handle = (intptr_t*)arg;
6222  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
6223 
6224  result = _resetVolumeLeveller(*handle);
6225  IARM_BUS_Unlock(lock);
6226  return result;
6227 }
6228 
6229 static IARM_Result_t _resetVolumeLeveller(intptr_t handle)
6230 {
6231  typedef dsError_t (*dsSetVolumeLeveller_t)(intptr_t handle, dsVolumeLeveller_t volLeveller);
6232  static dsSetVolumeLeveller_t func = 0;
6233  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
6234 
6235  if (func == 0) {
6236  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
6237  if (dllib) {
6238  func = (dsSetVolumeLeveller_t) dlsym(dllib, "dsSetVolumeLeveller");
6239  if (func) {
6240  printf("dsSetVolumeLeveller_t(int, dsVolumeLeveller_t) is defined and loaded\r\n");
6241  }
6242  else {
6243  printf("dsSetVolumeLeveller_t(int, dsVolumeLeveller_t) is not defined\r\n");
6244  }
6245  dlclose(dllib);
6246  }
6247  else {
6248  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
6249  }
6250  }
6251 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
6252  if (func != 0) {
6253  std::string _PropertyMode = _dsGetCurrentProfileProperty("VolumeLeveller.mode");
6254  std::string _Propertylevel = _dsGetCurrentProfileProperty("VolumeLeveller.level");
6255  std::string _volLevellerMode("0");
6256  std::string _volLevellerLevel("0");
6257  dsVolumeLeveller_t m_volumeLeveller;
6258  try {
6259  _volLevellerMode = device::HostPersistence::getInstance().getDefaultProperty(_PropertyMode);
6260  _volLevellerLevel = device::HostPersistence::getInstance().getDefaultProperty(_Propertylevel);
6261  }
6262  catch(...) {
6263  _volLevellerMode = "0";
6264  _volLevellerLevel = "0";
6265  }
6266  m_volumeLeveller.mode = atoi(_volLevellerMode.c_str());
6267  m_volumeLeveller.level = atoi(_volLevellerLevel.c_str());
6268  if (func(handle, m_volumeLeveller) == dsERR_NONE) {
6269  printf("%s %s %s Default Volume Leveller : Mode: %d, Level: %d\n",__func__,_PropertyMode.c_str(),_Propertylevel.c_str(), m_volumeLeveller.mode, m_volumeLeveller.level);
6270  device::HostPersistence::getInstance().persistHostProperty(_PropertyMode ,_volLevellerMode);
6271  device::HostPersistence::getInstance().persistHostProperty(_Propertylevel ,_volLevellerLevel);
6272  result = IARM_RESULT_SUCCESS;
6273  }
6274  }
6275 #endif
6276  IARM_BUS_Unlock(lock);
6277  return result;
6278 }
6279 
6280 IARM_Result_t _dsResetSurroundVirtualizer(void *arg)
6281 {
6282  _DEBUG_ENTER();
6283  IARM_BUS_Lock(lock);
6284  intptr_t *handle = (intptr_t*)arg;
6285  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
6286 
6287  result = _resetSurroundVirtualizer(*handle);
6288  IARM_BUS_Unlock(lock);
6289  return result;
6290 }
6291 
6292 static IARM_Result_t _resetSurroundVirtualizer(intptr_t handle)
6293 {
6294  typedef dsError_t (*dsSetSurroundVirtualizer_t)(intptr_t handle, dsSurroundVirtualizer_t virtualizer);
6295  static dsSetSurroundVirtualizer_t func = 0;
6296  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
6297  if (func == 0) {
6298  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
6299  if (dllib) {
6300  func = (dsSetSurroundVirtualizer_t) dlsym(dllib, "dsSetSurroundVirtualizer");
6301  if (func) {
6302  printf("dsSetSurroundVirtualizer_t(int, dsSurroundVirtualizer_t) is defined and loaded\r\n");
6303  }
6304  else {
6305  printf("dsSetSurroundVirtualizer_t(int, dsSurroundVirtualizer_t) is not defined\r\n");
6306  }
6307  dlclose(dllib);
6308  }
6309  else {
6310  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
6311  }
6312  }
6313 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
6314  if (func != 0) {
6315  std::string _PropertyMode = _dsGetCurrentProfileProperty("SurroundVirtualizer.mode");
6316  std::string _Propertylevel = _dsGetCurrentProfileProperty("SurroundVirtualizer.boost");
6317  std::string _SVMode("0");
6318  std::string _SVBoost("0");
6319  dsSurroundVirtualizer_t m_virtualizer;
6320  try {
6321  _SVMode = device::HostPersistence::getInstance().getDefaultProperty(_PropertyMode);
6322  _SVBoost = device::HostPersistence::getInstance().getDefaultProperty(_Propertylevel);
6323  }
6324  catch(...) {
6325  _SVMode = "0";
6326  _SVBoost = "0";
6327  }
6328  m_virtualizer.mode = atoi(_SVMode.c_str());
6329  m_virtualizer.boost = atoi(_SVBoost.c_str());
6330  if (func(handle, m_virtualizer) == dsERR_NONE) {
6331  printf("%s %s %s Default Surround Virtualizer : Mode: %d, Boost : %d\n",__func__,_PropertyMode.c_str(),_Propertylevel.c_str(), m_virtualizer.mode, m_virtualizer.boost);
6333  device::HostPersistence::getInstance().persistHostProperty(_Propertylevel ,_SVBoost);
6334  result = IARM_RESULT_SUCCESS;
6335  }
6336  }
6337 #endif
6338  return result;
6339 }
6340 
6341 IARM_Result_t _dsResetDialogEnhancement(void *arg)
6342 {
6343  _DEBUG_ENTER();
6344  IARM_BUS_Lock(lock);
6345  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
6346  intptr_t *handle = (intptr_t*)arg;
6347 
6348  result = _resetDialogEnhancerLevel(*handle);
6349  IARM_BUS_Unlock(lock);
6350  return result;
6351 }
6352 
6353 static IARM_Result_t _resetDialogEnhancerLevel(intptr_t handle)
6354 {
6355  typedef dsError_t (*dsSetDialogEnhancement_t)(intptr_t handle, int enhancerLevel);
6356  static dsSetDialogEnhancement_t func = 0;
6357  IARM_Result_t result = IARM_RESULT_INVALID_STATE;
6358  if (func == 0) {
6359  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
6360  if (dllib) {
6361  func = (dsSetDialogEnhancement_t) dlsym(dllib, "dsSetDialogEnhancement");
6362  if (func) {
6363  printf("dsSetDialogEnhancement_t(int, int) is defined and loaded\r\n");
6364  }
6365  else {
6366  printf("dsSetDialogEnhancement_t(int, int ) is not defined\r\n");
6367  }
6368  dlclose(dllib);
6369  }
6370  else {
6371  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
6372  }
6373  }
6374 
6375 #ifdef DS_AUDIO_SETTINGS_PERSISTENCE
6376  std::string _Property = _dsGetCurrentProfileProperty("EnhancerLevel");
6377  if (func) {
6378  std::string _EnhancerLevel("0");
6379  int m_enhancerLevel = 0;
6380  try {
6381  _EnhancerLevel = device::HostPersistence::getInstance().getDefaultProperty(_Property);
6382  }
6383  catch(...) {
6384  _EnhancerLevel = "0";
6385  }
6386  m_enhancerLevel = atoi(_EnhancerLevel.c_str());
6387  if (func(handle, m_enhancerLevel) == dsERR_NONE) {
6388  printf("%s %s Default dialog enhancement level : %d\n",__func__,_Property.c_str(), m_enhancerLevel);
6389  device::HostPersistence::getInstance().persistHostProperty(_Property ,_EnhancerLevel);
6390  result = IARM_RESULT_SUCCESS;
6391  }
6392  }
6393 #endif
6394  return result;
6395 }
6396 
6397 std::string _dsGetCurrentProfileProperty(std::string property)
6398 {
6399  std::string _AProfile("Off");
6400  std::string _AProfileSupport("FALSE");
6401  try {
6402  _AProfileSupport = device::HostPersistence::getInstance().getDefaultProperty("audio.MS12Profile.supported");
6403  }
6404  catch(...) {
6405  _AProfileSupport = "FALSE";
6406  printf("audio.MS12Profile.supported setting not found in hostDataDeafult \r\n");
6407  }
6408  printf(" audio.MS12Profile.supported = %s ..... \r\n",_AProfileSupport.c_str());
6409 
6410  if(_AProfileSupport == "TRUE") {
6411  try {
6412  _AProfile = device::HostPersistence::getInstance().getProperty("audio.MS12Profile");
6413  }
6414  catch(...) {
6415  try {
6416  printf("audio.MS12Profile not found in persistence store. Try system default\n");
6417  _AProfile = device::HostPersistence::getInstance().getDefaultProperty("audio.MS12Profile");
6418  }
6419  catch(...) {
6420  _AProfile = "Off";
6421  }
6422  }
6423  }
6424  std::string profileProperty("audio.");
6425  if(_AProfileSupport == "TRUE") {
6426  profileProperty.append (_AProfile);
6427  profileProperty.append (".");
6428  }
6429  profileProperty.append (property);
6430  return profileProperty;
6431 }
6432 
6433 static std::string _dsGenerateProfileProperty(std::string profile,std::string property)
6434 {
6435  std::string profileProperty("audio.");
6436  profileProperty.append (profile);
6437  profileProperty.append (".");
6438  profileProperty.append (property);
6439  return profileProperty;
6440 }
6441 
6442 void _dsMS12ProfileSettingOverride(intptr_t handle)
6443 {
6444 
6445  typedef dsError_t (*dsSetDialogEnhancement_t)(intptr_t handle, int enhancerLevel);
6446  static dsSetDialogEnhancement_t dsSetDialogEnhancementfunc = 0;
6447  if (dsSetDialogEnhancementfunc == 0) {
6448  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
6449  if (dllib) {
6450  dsSetDialogEnhancementfunc = (dsSetDialogEnhancement_t) dlsym(dllib, "dsSetDialogEnhancement");
6451  if (dsSetDialogEnhancementfunc) {
6452  printf("dsSetDialogEnhancement_t(int, int) is defined and loaded\r\n");
6453  }
6454  else {
6455  printf("dsSetDialogEnhancement_t(int, int ) is not defined\r\n");
6456  }
6457  dlclose(dllib);
6458  }
6459  else {
6460  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
6461  }
6462  }
6463 
6464  if (dsSetDialogEnhancementfunc) {
6465  std::string _EnhancerLevel("0");
6466  int m_enhancerLevel = 0;
6467  std::string _Property = _dsGetCurrentProfileProperty("EnhancerLevel");
6468  try {
6469  _EnhancerLevel = device::HostPersistence::getInstance().getProperty(_Property);
6470  }
6471  catch(...) {
6472  try {
6473  printf("audio.EnhancerLevel not found in persistence store. Try system default\n");
6474  _EnhancerLevel = device::HostPersistence::getInstance().getDefaultProperty(_Property);
6475  }
6476  catch(...) {
6477  _EnhancerLevel = "0";
6478  }
6479  }
6480  m_enhancerLevel = atoi(_EnhancerLevel.c_str());
6481  if (dsSetDialogEnhancementfunc(handle, m_enhancerLevel) == dsERR_NONE) {
6482  device::HostPersistence::getInstance().persistHostProperty(_Property ,_EnhancerLevel);
6483  printf("%s: persist enhancer level: %d\n",__func__,m_enhancerLevel );
6484  }
6485  }
6486 
6487  typedef dsError_t (*dsSetBassEnhancer_t)(intptr_t handle, int boost);
6488  static dsSetBassEnhancer_t dsSetBassEnhancerFunc = 0;
6489  if (dsSetBassEnhancerFunc == 0) {
6490  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
6491  if (dllib) {
6492  dsSetBassEnhancerFunc = (dsSetBassEnhancer_t) dlsym(dllib, "dsSetBassEnhancer");
6493  if (dsSetBassEnhancerFunc) {
6494  printf("dsSetBassEnhancer_t(int, int) is defined and loaded\r\n");
6495  }
6496  else {
6497  printf("dsSetBassEnhancer_t(int, int) is not defined\r\n");
6498  }
6499  dlclose(dllib);
6500  }
6501  else {
6502  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
6503  }
6504  }
6505  if (dsSetBassEnhancerFunc != 0)
6506  {
6507  std::string _BassBoost("0");
6508  int m_bassBoost = 0;
6509  std::string _Property = _dsGetCurrentProfileProperty("BassBoost");
6510  try {
6511  _BassBoost = device::HostPersistence::getInstance().getProperty("audio.BassBoost");
6512  }
6513  catch(...) {
6514  try {
6515  printf("audio.EnhancerLevel not found in persistence store. Try system default\n");
6516  _BassBoost = device::HostPersistence::getInstance().getDefaultProperty(_Property);
6517  }
6518  catch(...) {
6519  _BassBoost = "0";
6520  }
6521  }
6522  m_bassBoost = atoi(_BassBoost.c_str());
6523  if (dsSetBassEnhancerFunc(handle, m_bassBoost) == dsERR_NONE)
6524  {
6525  printf("%s: persist boost value: %d\n",__func__, m_bassBoost);
6526  device::HostPersistence::getInstance().persistHostProperty("audio.BassBoost" ,_BassBoost);
6527  }
6528  }
6529 
6530  typedef dsError_t (*dsSetVolumeLeveller_t)(intptr_t handle, dsVolumeLeveller_t volLeveller);
6531  static dsSetVolumeLeveller_t dsSetVolumeLevellerfunc = 0;
6532  if (dsSetVolumeLevellerfunc == 0) {
6533  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
6534  if (dllib) {
6535  dsSetVolumeLevellerfunc = (dsSetVolumeLeveller_t) dlsym(dllib, "dsSetVolumeLeveller");
6536  if (dsSetVolumeLevellerfunc) {
6537  printf("dsSetVolumeLeveller_t(int, dsVolumeLeveller_t) is defined and loaded\r\n");
6538  }
6539  else {
6540  printf("dsSetVolumeLeveller_t(int, dsVolumeLeveller_t) is not defined\r\n");
6541  }
6542  dlclose(dllib);
6543  }
6544  else {
6545  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
6546  }
6547  }
6548 
6549  if (dsSetVolumeLevellerfunc != 0 )
6550  {
6551  std::string _volLevellerMode("0");
6552  std::string _volLevellerLevel("0");
6553  dsVolumeLeveller_t m_volumeLeveller;
6554  std::string _PropertyMode = _dsGetCurrentProfileProperty("VolumeLeveller.mode");
6555  std::string _PropertyLevel = _dsGetCurrentProfileProperty("VolumeLeveller.level");
6556  try {
6557  _volLevellerMode = device::HostPersistence::getInstance().getProperty(_PropertyMode);
6558  _volLevellerLevel = device::HostPersistence::getInstance().getProperty(_PropertyLevel);
6559  }
6560  catch(...) {
6561  try {
6562  _volLevellerMode = device::HostPersistence::getInstance().getDefaultProperty(_PropertyMode);
6563  _volLevellerLevel = device::HostPersistence::getInstance().getDefaultProperty(_PropertyLevel);
6564  }
6565  catch(...) {
6566  _volLevellerMode = "0";
6567  _volLevellerLevel = "0";
6568  }
6569  }
6570  m_volumeLeveller.mode = atoi(_volLevellerMode.c_str());
6571  m_volumeLeveller.level = atoi(_volLevellerLevel.c_str());
6572  if (dsSetVolumeLevellerfunc(handle, m_volumeLeveller) == dsERR_NONE)
6573  {
6574  printf("%s: persist volume leveller mode: %d\n",__func__, m_volumeLeveller.mode);
6575  device::HostPersistence::getInstance().persistHostProperty(_PropertyMode,_volLevellerMode);
6576  printf("%s: persist volume leveller value: %d\n",__func__, m_volumeLeveller.level);
6577  device::HostPersistence::getInstance().persistHostProperty(_PropertyLevel,_volLevellerLevel);
6578  }
6579  }
6580 
6581  typedef dsError_t (*dsSetSurroundVirtualizer_t)(intptr_t handle, dsSurroundVirtualizer_t virtualizer);
6582  static dsSetSurroundVirtualizer_t dsSetSurroundVirtualizerfunc = 0;
6583  if (dsSetSurroundVirtualizerfunc == 0) {
6584  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
6585  if (dllib) {
6586  dsSetSurroundVirtualizerfunc = (dsSetSurroundVirtualizer_t) dlsym(dllib, "dsSetSurroundVirtualizer");
6587  if (dsSetSurroundVirtualizerfunc) {
6588  printf("dsSetSurroundVirtualizer_t(int, dsSurroundVirtualizer_t) is defined and loaded\r\n");
6589  }
6590  else {
6591  printf("dsSetSurroundVirtualizer_t(int, dsSurroundVirtualizer_t) is not defined\r\n");
6592  }
6593  dlclose(dllib);
6594  }
6595  else {
6596  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
6597  }
6598  }
6599 
6600  if (dsSetSurroundVirtualizerfunc != 0 )
6601  {
6602  std::string _SVMode("0");
6603  std::string _SVBoost("0");
6604  dsSurroundVirtualizer_t m_virtualizer;
6605  std::string _PropertyMode = _dsGetCurrentProfileProperty("SurroundVirtualizer.mode");
6606  std::string _PropertyBoost = _dsGetCurrentProfileProperty("SurroundVirtualizer.boost");
6607  try {
6608  _SVMode = device::HostPersistence::getInstance().getProperty(_PropertyMode);
6609  _SVBoost = device::HostPersistence::getInstance().getProperty(_PropertyBoost);
6610  }
6611  catch(...) {
6612  try {
6613  _SVMode = device::HostPersistence::getInstance().getDefaultProperty(_PropertyMode);
6614  _SVBoost = device::HostPersistence::getInstance().getDefaultProperty(_PropertyBoost);
6615  }
6616  catch(...) {
6617  _SVMode = "0";
6618  _SVBoost = "0";
6619  }
6620  }
6621  m_virtualizer.mode = atoi(_SVMode.c_str());
6622  m_virtualizer.boost = atoi(_SVBoost.c_str());
6623 
6624  if (dsSetSurroundVirtualizerfunc(handle,m_virtualizer) == dsERR_NONE)
6625  {
6626  printf("%s: persist surround virtualizer mode: %d\n",__func__, m_virtualizer.mode);
6628  printf("%s: persist surround virtualizer boost value: %d\n",__func__, m_virtualizer.boost);
6629  device::HostPersistence::getInstance().persistHostProperty(_PropertyBoost,_SVBoost);
6630  }
6631  }
6632 }
6633 
6634 bool _dsMs12ProfileSupported(intptr_t handle,std::string profile)
6635 {
6636  typedef dsError_t (*dsGetMS12AudioProfileList_t)(intptr_t handle, dsMS12AudioProfileList_t* profiles);
6637  static dsGetMS12AudioProfileList_t func = 0;
6638  if (func == 0) {
6639  void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
6640  if (dllib) {
6641  func = (dsGetMS12AudioProfileList_t) dlsym(dllib, "dsGetMS12AudioProfileList");
6642  if (func) {
6643  printf("dsGetMS12AudioProfileList_t(int, dsMS12AudioProfileList_t*) is defined and loaded\r\n");
6644  }
6645  else {
6646  printf("dsGetMS12AudioProfileList_t(int, dsMS12AudioProfileList_t*) is not defined\r\n");
6647  }
6648  dlclose(dllib);
6649  }
6650  else {
6651  printf("Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
6652  }
6653  }
6654 
6655  dsMS12AudioProfileList_t pProfilesStr;
6656  bool result = 0;
6657  dsError_t ret = dsERR_NONE;
6658  if (func != 0 )
6659  {
6660  ret = func(handle, &pProfilesStr);
6661  if (ret == dsERR_NONE)
6662  {
6663  if(strstr(pProfilesStr.audioProfileList,profile.c_str()))
6664  result = 1;
6665  else
6666  result = 0;
6667  }
6668  }
6669  return result;
6670 }
6671 
6672 IARM_Result_t _dsGetHDMIARCPortId(void *arg)
6673 {
6674 #ifndef RDK_DSHAL_NAME
6675 #warning "RDK_DSHAL_NAME is not defined"
6676 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
6677 #endif
6678  _DEBUG_ENTER();
6679 
6680  IARM_BUS_Lock(lock);
6681  std::string _HDMIARCPortId("0");
6683  try {
6684  _HDMIARCPortId = device::HostPersistence::getInstance().getDefaultProperty("HDMIARC.port.Id");
6685  }
6686  catch(...) {
6687  _HDMIARCPortId = "-1";
6688  }
6689  param->portId = atoi(_HDMIARCPortId.c_str());
6690  printf("The HDMI ARC Port Id is %d \r\n",param->portId);
6691  IARM_BUS_Unlock(lock);
6692  return IARM_RESULT_SUCCESS;
6693 }
6694 
6695 /** @} */
6696 /** @} */
dsAUDIOPORT_TYPE_SPEAKER
@ dsAUDIOPORT_TYPE_SPEAKER
Definition: dsTypes.h:169
_dsGrpahicEqualizerModeParam_t
Definition: dsRpc.h:458
_dsDRCModeParam_t
Definition: dsRpc.h:443
_dsSurroundDecoderParam_t
Definition: dsRpc.h:438
_dsAudioARCStatus_t
Structure that defines ARC status for the HDMI ARC/EARC port.
Definition: dsTypes.h:307
_dsAudioSetLevelParam_t
Definition: dsRpc.h:346
_dsAudioSADList_t
Definition: dsTypes.h:299
_dsAssociatedAudioMixingParam_t
Definition: dsRpc.h:463
IARM_BUS_DSMGR_EVENT_AUDIO_FADER_CONTROL_CHANGED
@ IARM_BUS_DSMGR_EVENT_AUDIO_FADER_CONTROL_CHANGED
Definition: dsMgr.h:68
_dsSetDolbyVolumeParam_t
Definition: dsRpc.h:418
_dsAudioSetStereoAutoParam_t
Definition: dsRpc.h:330
_dsAudioCompressionParam_t
Definition: dsRpc.h:408
_dsAudioEnableARCParam_t
Definition: dsRpc.h:318
_dsBassEnhancerParam_t
Definition: dsRpc.h:433
dsAUDIOPORT_TYPE_MAX
@ dsAUDIOPORT_TYPE_MAX
Definition: dsTypes.h:172
_dsMS12SetttingsOverrideParam_t
Definition: dsRpc.h:490
dsGetAudioEncoding
dsError_t dsGetAudioEncoding(intptr_t handle, dsAudioEncoding_t *encoding)
Get the encoding type of an audio port.
Definition: dsAudio.c:95
_dsAudioSetStereoModeParam_t
Definition: dsRpc.h:323
dsSetStereoMode
dsError_t dsSetStereoMode(intptr_t handle, dsAudioStereoMode_t mode)
Set the stereo mode of an audio port.
_dsVolumeLevellerParam_t
Definition: dsRpc.h:428
_dsGetAudioDelayParam_t
Definition: dsRpc.h:383
_dsGetSupportedARCTypesParam_t
Definition: dsRpc.h:308
dsEnableAudioPort
dsError_t dsEnableAudioPort(intptr_t handle, bool enabled)
This function is used to enable or disable the specified Audio port.
dsAUDIO_ATMOS_NOTSUPPORTED
@ dsAUDIO_ATMOS_NOTSUPPORTED
Definition: dsTypes.h:387
_dsVolumeLeveller_t
Definition: dsTypes.h:352
dsAudioPortType_t
enum _dsAudioPortType_t dsAudioPortType_t
dsGetStereoMode
dsError_t dsGetStereoMode(intptr_t handle, dsAudioStereoMode_t *stereoMode)
Get the stereo mode of an audio port.
dsTypes.h
Device Settings HAL types.
_dsIntelligentEqualizerModeParam_t
Definition: dsRpc.h:423
_dsAudioGetMS12Param_t
Definition: dsRpc.h:378
_dsGetLEConfigParam_t
Definition: dsRpc.h:869
dsAUDIO_STEREO_STEREO
@ dsAUDIO_STEREO_STEREO
Definition: dsTypes.h:376
_dsSetAudioDelayParam_t
Definition: dsRpc.h:398
IARM_BUS_DSMGR_EVENT_AUDIO_MODE
@ IARM_BUS_DSMGR_EVENT_AUDIO_MODE
Definition: dsMgr.h:51
dsAUDIO_DUCKINGACTION_START
@ dsAUDIO_DUCKINGACTION_START
Definition: dsTypes.h:236
device::HostPersistence::persistHostProperty
void persistHostProperty(const std::string &key, const std::string &value)
Definition: hostPersistence.cpp:273
dsError.h
Device Settings HAL error codes.
IARM_Bus_RegisterCall
IARM_Result_t IARM_Bus_RegisterCall(const char *methodName, IARM_BusCall_t handler)
This API is used to register an RPC method that can be invoked by other applications.
dsAUDIO_ENC_NONE
@ dsAUDIO_ENC_NONE
Definition: dsTypes.h:184
dsAUDIOPORT_TYPE_HEADPHONE
@ dsAUDIOPORT_TYPE_HEADPHONE
Definition: dsTypes.h:171
_dsVideoPortEnabledParam_t
Definition: dsRpc.h:509
_dsAudioGetHandleParam_t
Definition: dsRpc.h:302
dsUtl.h
Device Settings HAL utilities.
IARM_BUS_DSMGR_EVENT_AUDIO_FORMAT_UPDATE
@ IARM_BUS_DSMGR_EVENT_AUDIO_FORMAT_UPDATE
Definition: dsMgr.h:65
dsERR_GENERAL
@ dsERR_GENERAL
Definition: dsError.h:86
_dsDialogEnhancementParam_t
Definition: dsRpc.h:413
_dsSurroundVirtualizer_t
Definition: dsTypes.h:360
dsERR_NONE
@ dsERR_NONE
Definition: dsError.h:85
dsIsAudioPortEnabled
dsError_t dsIsAudioPortEnabled(intptr_t handle, bool *enabled)
This function indicates whether the specified Audio port is enabled or not.
Definition: dsAudio.c:303
dsAUDIO_STEREO_SURROUND
@ dsAUDIO_STEREO_SURROUND
Definition: dsTypes.h:377
_dsMISteeringParam_t
Definition: dsRpc.h:453
_dsAudioSetDuckingParam_t
Definition: dsRpc.h:351
IARM_BUS_DSMGR_EVENT_AUDIO_SECONDARY_LANGUAGE_CHANGED
@ IARM_BUS_DSMGR_EVENT_AUDIO_SECONDARY_LANGUAGE_CHANGED
Definition: dsMgr.h:67
dsAudioPortTerm
dsError_t dsAudioPortTerm(void)
Terminate the Audio Port sub-system.
Definition: dsAudio.c:591
IARM_Bus_BroadcastEvent
IARM_Result_t IARM_Bus_BroadcastEvent(const char *ownerName, IARM_EventId_t eventId, void *data, size_t len)
This API is used to publish an Asynchronous event to all IARM client registered for this perticular e...
_dsAudioGetEncodingModeParam_t
Definition: dsRpc.h:368
libIBus.h
RDK IARM-Bus API Declarations.
IARM_BUS_DSMGR_EVENT_AUDIO_PORT_STATE
@ IARM_BUS_DSMGR_EVENT_AUDIO_PORT_STATE
Definition: dsMgr.h:73
dsIsAudioMute
dsError_t dsIsAudioMute(intptr_t handle, bool *muted)
Get the audio mute status of an audio port.
Definition: dsAudio.c:284
dsAUDIO_STEREO_DDPLUS
@ dsAUDIO_STEREO_DDPLUS
Definition: dsTypes.h:380
_dsFaderControlParam_t
Definition: dsRpc.h:468
_dsAudioSetAtmosOutputModeParam_t
Definition: dsRpc.h:388
dsAudioStereoMode_t
enum StereoMode dsAudioStereoMode_t
dsAUDIOPORT_TYPE_SPDIF
@ dsAUDIOPORT_TYPE_SPDIF
Definition: dsTypes.h:168
_dsMS12AudioProfileParam_t
Definition: dsRpc.h:485
dsSetAudioMute
dsError_t dsSetAudioMute(intptr_t handle, bool mute)
Mute or un-mute an audio port.
Definition: dsAudio.c:565
_dsAudioGainParam_t
Definition: dsRpc.h:358
dsAUDIO_STEREO_PASSTHRU
@ dsAUDIO_STEREO_PASSTHRU
Definition: dsTypes.h:378
IARM_BUS_DSMGR_EVENT_AUDIO_PRIMARY_LANGUAGE_CHANGED
@ IARM_BUS_DSMGR_EVENT_AUDIO_PRIMARY_LANGUAGE_CHANGED
Definition: dsMgr.h:66
_dsSurroundVirtualizerParam_t
Definition: dsRpc.h:448
dsAudio.h
_dsAudioSetSADParam_t
Definition: dsRpc.h:313
dsAudioPortInit
dsError_t dsAudioPortInit()
Initialize the underlying Audio Port sub-system.
Definition: dsAudio.c:47
_dsLEConfigParam_t
Definition: dsRpc.h:809
dsAUDIO_STEREO_UNKNOWN
@ dsAUDIO_STEREO_UNKNOWN
Definition: dsTypes.h:374
dsAUDIO_DUCKINGTYPE_RELATIVE
@ dsAUDIO_DUCKINGTYPE_RELATIVE
Definition: dsTypes.h:245
_dsSecondaryLanguageParam_t
Definition: dsRpc.h:478
device::HostPersistence::getDefaultProperty
std::string getDefaultProperty(const std::string &key)
Definition: hostPersistence.cpp:239
dsGetAudioPort
dsError_t dsGetAudioPort(dsAudioPortType_t type, int index, intptr_t *handle)
Get the audio port handle.
Definition: dsAudio.c:66
_dsAudioOutIsConnectedParam_t
Definition: dsRpc.h:932
_dsAudioFormatParam_t
Definition: dsRpc.h:363
_dsGetMS12CapabilitiesParam_t
Definition: dsRpc.h:795
_dsPrimaryLanguageParam_t
Definition: dsRpc.h:473
dsAudioFormat_t
enum _dsAudioFormat_t dsAudioFormat_t
_dsGetAudioCapabilitiesParam_t
Definition: dsRpc.h:788
IARM_BUS_DSMGR_EVENT_AUDIO_ASSOCIATED_AUDIO_MIXING_CHANGED
@ IARM_BUS_DSMGR_EVENT_AUDIO_ASSOCIATED_AUDIO_MIXING_CHANGED
Definition: dsMgr.h:69
_dsGetHDMIARCPortIdParam_t
Definition: dsRpc.h:973
dsUTL_DIM
#define dsUTL_DIM(arr)
Device Settings general Array dimension calculation inline definition.
Definition: dsUtl.h:85
dsERR_INVALID_PARAM
@ dsERR_INVALID_PARAM
Definition: dsError.h:87
IARM_BUS_DSMGR_EVENT_AUDIO_OUT_HOTPLUG
@ IARM_BUS_DSMGR_EVENT_AUDIO_OUT_HOTPLUG
Definition: dsMgr.h:64
MAX_PROFILE_LIST_BUFFER_LEN
#define MAX_PROFILE_LIST_BUFFER_LEN
Structure that captures MS12 Audio Profile list.
Definition: dsTypes.h:333
dsAUDIO_STEREO_DD
@ dsAUDIO_STEREO_DD
Definition: dsTypes.h:379
device::HostPersistence::getInstance
static HostPersistence & getInstance(void)
Definition: hostPersistence.cpp:122
_dsAudioSetMutedParam_t
Definition: dsRpc.h:336
dsError_t
dsError_t
Device Settings API Error return codes.
Definition: dsError.h:84
_dsMS12AudioProfileList_t
Definition: dsTypes.h:334
dsAudioFormatUpdateCB_t
void(* dsAudioFormatUpdateCB_t)(dsAudioFormat_t audioFormat)
Callback function used to notify applications of Audio Format change.
Definition: dsAudio.h:58
IARM_BUS_DSMGR_EVENT_AUDIO_LEVEL_CHANGED
@ IARM_BUS_DSMGR_EVENT_AUDIO_LEVEL_CHANGED
Definition: dsMgr.h:63
_dsMS12AudioProfileListParam_t
Definition: dsRpc.h:498
_DSMgr_EventData_t
Definition: dsMgr.h:81
_dsAudioDelayOffsetParam_t
Definition: dsRpc.h:403
dsAUDIOPORT_TYPE_HDMI
@ dsAUDIOPORT_TYPE_HDMI
Definition: dsTypes.h:167
_dsAudioGetMS11Param_t
Definition: dsRpc.h:373
_dsGetAudioAtmosCapabilityParam_t
Definition: dsRpc.h:393
dsAudioEncoding_t
enum _dsAudioEncoding_t dsAudioEncoding_t