-
Notifications
You must be signed in to change notification settings - Fork 4
RDKEMW-8587: consume the config variables using dlsym() in MW. #168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 8 commits
1374c07
6b95abb
2f17837
2e068a5
6fd6b4f
9932c3c
cc2121a
0d13c48
397cf75
8433557
51c8af5
020d7fc
7e8a9f4
b1e9412
661e8ec
bbe42f2
299bf52
5f5a634
6553c8f
12f0193
565dbde
17faa45
8f60d7e
7455db3
8e51e51
329c312
1928496
05aa70f
64a4609
9789231
dde8258
edb8f55
2864e49
e287d3a
bccfc77
103ec2a
76d0910
acd9e70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| /* | ||
| * If not stated otherwise in this file or this component's LICENSE file the | ||
| * following copyright and licenses apply: | ||
|
Check failure on line 3 in ds/audioOutputPortConfig.cpp
|
||
| * | ||
| * Copyright 2016 RDK Management | ||
| * | ||
|
|
@@ -34,6 +34,19 @@ | |
| #include "dsUtl.h" | ||
| #include "stdlib.h" | ||
| #include "dslogger.h" | ||
| #include <dlfcn.h> | ||
|
|
||
| #define DEBUG 1 | ||
|
|
||
| static pthread_mutex_t dsLock = PTHREAD_MUTEX_INITIALIZER; | ||
|
|
||
| typedef struct Configs | ||
| { | ||
| const dsAudioTypeConfig_t *pKConfigs; | ||
| const dsAudioPortConfig_t *pKPorts; | ||
| int *pKConfigSize; | ||
| int *pKPortSize; | ||
| }Configs_t; | ||
|
|
||
| namespace device { | ||
|
|
||
|
|
@@ -108,8 +121,240 @@ | |
| return supportedTypes; | ||
| } | ||
|
|
||
| bool searchConfigs(Configs_t *config, const char *searchVaribles[]) | ||
| { | ||
| INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); | ||
| INT_INFO("%d:%s: searchVaribles[0] = %s\n", __LINE__, __func__, &searchVaribles[0]); | ||
| INT_INFO("%d:%s: searchVaribles[1] = %s\n", __LINE__, __func__, &searchVaribles[1]); | ||
santoshcomcast marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| INT_INFO("%d:%s: searchVaribles[2] = %s\n", __LINE__, __func__, &searchVaribles[2]); | ||
|
||
| INT_INFO("%d:%s: searchVaribles[3] = %s\n", __LINE__, __func__, &searchVaribles[4]); | ||
santoshcomcast marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| pthread_mutex_lock(&dsLock); | ||
|
|
||
| void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY); | ||
| if (dllib) { | ||
| config->pKConfigs = (dsAudioTypeConfig_t *) dlsym(dllib, searchVaribles[0]); | ||
| if (config->pKConfigs) { | ||
| INT_INFO("kAudioConfigs is defined and loaded kConfigs1 = %p\r\n", config->pKConfigs); | ||
| } | ||
| else { | ||
| INT_ERROR("%d:%s: kAudioConfigs is not defined\n", __LINE__, __func__); | ||
| } | ||
|
|
||
| config->pKConfigSize = (int *) dlsym(dllib, searchVaribles[2]); | ||
| if(config->pKConfigSize) | ||
| { | ||
| //kConfig_size_local = *pKConSize; | ||
| INT_INFO("%d:%s: kAudioConfigs_size is defined and loaded kConfig_size_local = %d\n", __LINE__, __func__, *config->pKConfigSize); | ||
| } | ||
| else | ||
| { | ||
| INT_ERROR("%d:%s: kAudioConfigs_size is not defined\n", __LINE__, __func__); | ||
| *(config->pKConfigSize) = -1; | ||
santoshcomcast marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| config->pKPorts = (dsAudioPortConfig_t *) dlsym(dllib, searchVaribles[1]); | ||
| if (config->pKPorts) { | ||
| INT_INFO("%d:%s: kAudioPorts is defined and loaded config->pKPorts = %p\n", __LINE__, __func__, config->pKPorts); | ||
| } | ||
| else { | ||
| INT_ERROR("%d:%s: kAudioPorts is not defined\n", __LINE__, __func__); | ||
| } | ||
|
|
||
| config->pKPortSize = (int *) dlsym(dllib, searchVaribles[3]); | ||
| if(config->pKPortSize) | ||
| { | ||
| INT_INFO("%d:%s: kAudioPorts_size is defined and loaded config->pKPortSize = %d\n", __LINE__, __func__, *config->pKPortSize); | ||
| } | ||
| else | ||
| { | ||
| INT_ERROR("%d:%s: kAudioPorts_size is not defined\n", __LINE__, __func__); | ||
| *(config->pKPortSize) = -1; | ||
santoshcomcast marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| dlclose(dllib); | ||
| } | ||
| else { | ||
| INT_ERROR("%d:%s: Opening libds-hal.so failed\n", __LINE__, __func__); | ||
| } | ||
| pthread_mutex_unlock(&dsLock); | ||
| #if DEBUG | ||
| INT_INFO("\n\n=========================================================================================================================\n\n"); | ||
|
||
| INT_INFO("\n%d:%s print configs using extern\n", __LINE__, __func__); | ||
| //printf("%d:%s: size of(kConfig_audio) = %d size of(kPort_audio) = %d\n", __LINE__, __func__, kConfig_size, kPort_size); | ||
| //kConfig_size_local = kConfig_size; | ||
| //kPort_size_local = kPort_size; | ||
|
|
||
| if(config->pKConfigs != NULL && *(config->pKConfigSize) != -1) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add null check for pKConfigs and pKConfigSize since it is pointer variable
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
| { | ||
| for (size_t i = 0; i < *(config->pKConfigSize); i++) { | ||
| const dsAudioTypeConfig_t *typeCfg = &(config->pKConfigs[i]); | ||
| //AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); | ||
| //aPortType.enable(); | ||
| INT_INFO("%d:%s: typeCfg->typeId = %d\n", __LINE__, __func__, typeCfg->typeId); | ||
| INT_INFO("%d:%s: typeCfg->name = %s\n", __LINE__, __func__, typeCfg->name); | ||
| INT_INFO("%d:%s: typeCfg->numSupportedEncodings = %zu\n", __LINE__, __func__, typeCfg->numSupportedEncodings); | ||
| INT_INFO("%d:%s: typeCfg->numSupportedCompressions = %zu\n", __LINE__, __func__, typeCfg->numSupportedCompressions); | ||
| INT_INFO("%d:%s: typeCfg->numSupportedStereoModes = %zu\n", __LINE__, __func__, typeCfg->numSupportedStereoModes); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| INT_ERROR("%d:%s: kAudioConfigs is NULL and kConfig_size_local is -1\n", __LINE__, __func__); | ||
| } | ||
| if(config->pKPorts != NULL && *(config->pKPortSize) != -1) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add null check for pKPortSize since it is pointer variable
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
| { | ||
| /* | ||
| * set up ports based on kPorts[] | ||
| */ | ||
| for (size_t i = 0; i < *(config->pKPortSize); i++) { | ||
| const dsAudioPortConfig_t *port = &(config->pKPorts[i]); | ||
| INT_INFO("%d:%s: port->id.type = %d\n", __LINE__, __func__, port->id.type); | ||
| INT_INFO("%d:%s: port->id.index = %d\n", __LINE__, __func__, port->id.index); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| INT_ERROR("%d:%s: kAudioPorts is NULL and kPort_size_local is -1\n", __LINE__, __func__); | ||
| } | ||
| INT_INFO("\n\n=========================================================================================================================\n\n"); | ||
| #endif | ||
| if(config->pKConfigs == NULL || *(config->pKConfigSize) == -1 || config->pKPorts == NULL || *(config->pKPortSize) == -1) | ||
| { | ||
| printf("Either kAudioConfigs or kAudioPorts is NULL and pKConfigSize is -1, pKPortSize is -1\n"); | ||
| return false; | ||
| } | ||
| else | ||
| { | ||
| printf("Both kAudioConfigs and kAudioPorts, pKConfigSize, pKPortSize are valid\n"); | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| #if 0 | ||
| bool searchConfigs() | ||
| { | ||
| pthread_mutex_lock(&dsLock); | ||
|
|
||
| void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY); | ||
| if (dllib) { | ||
| kConfigs1 = (dsAudioTypeConfig_t *) dlsym(dllib, "kAudioConfigs"); | ||
| if (kConfigs1) { | ||
| INT_INFO("kAudioConfigs is defined and loaded kConfigs1 = %p\r\n", kConfigs1); | ||
| printf("%d:%s: kAudioConfigs is defined and loaded kConfigs1 = %p\n", __LINE__, __func__, kConfigs1); | ||
| } | ||
| else { | ||
| INT_ERROR("kAudioConfigs is not defined\r\n"); | ||
|
||
| INT_ERROR("%d:%s: kAudioConfigs is not defined\n", __LINE__, __func__); | ||
| } | ||
santoshcomcast marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| pKConSize = (int *) dlsym(dllib, "kAudioConfigs_size"); | ||
| if(pKConSize) | ||
| { | ||
| kConfig_size_local = *pKConSize; | ||
| INT_INFO("%d:%s: kAudioConfigs_size is defined and loaded kConfig_size_local = %d\n", __LINE__, __func__, kConfig_size_local); | ||
| } | ||
| else | ||
| { | ||
| INT_ERROR("%d:%s: kAudioConfigs_size is not defined\n", __LINE__, __func__); | ||
| kConfig_size_local = -1; | ||
| } | ||
|
|
||
| kPorts1 = (dsAudioPortConfig_t *) dlsym(dllib, "kAudioPorts"); | ||
| if (kPorts1) { | ||
| INT_INFO("kAudioPorts is defined and loaded kPorts1 = %p\r\n", kPorts1); | ||
| INT_INFO("%d:%s: kAudioPorts is defined and loaded kPorts1 = %p\n", __LINE__, __func__, kPorts1); | ||
| } | ||
| else { | ||
| INT_ERROR("kAudioPorts is not defined\r\n"); | ||
| INT_ERROR("%d:%s: kAudioPorts is not defined\n", __LINE__, __func__); | ||
| } | ||
|
|
||
| pKPortSize = (int *) dlsym(dllib, "kAudioPorts_size"); | ||
| if(pKPortSize) | ||
| { | ||
| kPort_size_local = *pKPortSize; | ||
| INT_INFO("%d:%s: kAudioPorts_size is defined and loaded kPort_size_local = %d\n", __LINE__, __func__, kPort_size_local); | ||
| } | ||
| else | ||
| { | ||
| INT_ERROR("%d:%s: kAudioPorts_size is not defined\n", __LINE__, __func__); | ||
| kPort_size_local = -1; | ||
| } | ||
| dlclose(dllib); | ||
| } | ||
| else { | ||
| INT_ERROR("%d:%s: Opening libds-hal.so failed\n", __LINE__, __func__); | ||
| } | ||
| pthread_mutex_unlock(&dsLock); | ||
| #if DEBUG | ||
| INT_INFO("\n\n=========================================================================================================================\n\n"); | ||
| INT_INFO("\n%d:%s print configs using extern\n", __LINE__, __func__); | ||
| //printf("%d:%s: size of(kConfig_audio) = %d size of(kPort_audio) = %d\n", __LINE__, __func__, kConfig_size, kPort_size); | ||
| //kConfig_size_local = kConfig_size; | ||
| //kPort_size_local = kPort_size; | ||
|
|
||
| if(kConfigs1 != NULL && kConfig_size_local != -1) | ||
| { | ||
| for (size_t i = 0; i < kConfig_size_local; i++) { | ||
| const dsAudioTypeConfig_t *typeCfg = &kConfigs1[i]; | ||
| //AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); | ||
| //aPortType.enable(); | ||
| INT_INFO("%d:%s: typeCfg->typeId = %d\n", __LINE__, __func__, typeCfg->typeId); | ||
| INT_INFO("%d:%s: typeCfg->name = %s\n", __LINE__, __func__, typeCfg->name); | ||
| INT_INFO("%d:%s: typeCfg->numSupportedEncodings = %zu\n", __LINE__, __func__, typeCfg->numSupportedEncodings); | ||
| INT_INFO("%d:%s: typeCfg->numSupportedCompressions = %zu\n", __LINE__, __func__, typeCfg->numSupportedCompressions); | ||
| INT_INFO("%d:%s: typeCfg->numSupportedStereoModes = %zu\n", __LINE__, __func__, typeCfg->numSupportedStereoModes); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| INT_ERROR("%d:%s: kAudioConfigs is NULL and kConfig_size_local is -1\n", __LINE__, __func__); | ||
| } | ||
| if(kPorts1 != NULL && kPort_size_local != -1) | ||
| { | ||
| /* | ||
| * set up ports based on kPorts[] | ||
| */ | ||
| for (size_t i = 0; i < kPort_size_local; i++) { | ||
| const dsAudioPortConfig_t *port = &kPorts1[i]; | ||
| INT_INFO("%d:%s: port->id.type = %d\n", __LINE__, __func__, port->id.type); | ||
| INT_INFO("%d:%s: port->id.index = %d\n", __LINE__, __func__, port->id.index); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| INT_ERROR("%d:%s: kAudioPorts is NULL and kPort_size_local is -1\n", __LINE__, __func__); | ||
| } | ||
| INT_INFO("\n\n=========================================================================================================================\n\n"); | ||
| #endif | ||
| if(kConfigs1 == NULL || kConfig_size_local == -1 || kPorts1 == NULL || kPort_size_local == -1) | ||
| { | ||
| printf("Either kAudioConfigs or kAudioPorts is NULL and kConfig_size_local is -1, kPort_size_local is -1\n"); | ||
| return false; | ||
| } | ||
| else | ||
| { | ||
| printf("Both kAudioConfigs and kAudioPorts, kConfig_size_local, kPort_size_local are valid\n"); | ||
| return true; | ||
| } | ||
| //return (kConfigs1 && kPorts1); | ||
| } | ||
| #endif | ||
|
|
||
| void AudioOutputPortConfig::load() | ||
| { | ||
| dsAudioTypeConfig_t *pKConfigs = NULL; | ||
| dsAudioPortConfig_t *pKPorts = NULL; | ||
| int *pKConfigSize, *pKPortSize; | ||
| Configs_t configuration = {0}; | ||
| const char* searchVaribles[] = { | ||
| "kAudioConfigs", | ||
| "kAudioPorts", | ||
| "kAudioConfigs_size", | ||
| "kAudioPorts_size" | ||
| }; | ||
| bool ret = false; | ||
|
|
||
| try { | ||
| /* | ||
| * Load Constants First. | ||
|
|
@@ -133,6 +378,93 @@ | |
|
|
||
| } | ||
|
|
||
| ret = searchConfigs(&configuration, searchVaribles); | ||
|
||
| if (ret == true) | ||
| { | ||
| INT_INFO("Both kAudioConfigs and kAudioPorts, kConfig_size_local, kPort_size_local are valid\n"); | ||
| } | ||
| else | ||
| { | ||
| INT_ERROR("Invalid kAudioConfigs or kAudioPorts, kConfig_size_local, kPort_size_local\n"); | ||
| configuration.pKConfigs = kConfigs; | ||
| *(configuration.pKConfigSize) = dsUTL_DIM(kConfigs); | ||
|
||
| configuration.pKPorts = kPorts; | ||
| *(configuration.pKPortSize) = dsUTL_DIM(kPorts); | ||
| INT_INFO("configuration.pKConfigs =%p, configuration.pKPorts =%p, *(configuration.pKConfigSize) = %d, *(configuration.pKPortSize) = %d\n", configuration.pKConfigs, configuration.pKPorts, *(configuration.pKConfigSize), *(configuration.pKPortSize)); | ||
| } | ||
| /* | ||
| * Initialize Audio portTypes (encodings, compressions etc.) | ||
| * and its port instances (db, level etc) | ||
| */ | ||
| for (size_t i = 0; i < *(configuration.pKConfigSize); i++) { | ||
| const dsAudioTypeConfig_t *typeCfg = &(configuration.pKConfigs[i]); | ||
| AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); | ||
| aPortType.enable(); | ||
| for (size_t j = 0; j < typeCfg->numSupportedEncodings; j++) { | ||
| aPortType.addEncoding(AudioEncoding::getInstance(typeCfg->encodings[j])); | ||
| _aEncodings.at(typeCfg->encodings[j]).enable(); | ||
| } | ||
| for (size_t j = 0; j < typeCfg->numSupportedCompressions; j++) { | ||
| aPortType.addCompression(typeCfg->compressions[j]); | ||
| _aCompressions.at(typeCfg->compressions[j]).enable(); | ||
| } | ||
| for (size_t j = 0; j < typeCfg->numSupportedStereoModes; j++) { | ||
| aPortType.addStereoMode(typeCfg->stereoModes[j]); | ||
| _aStereoModes.at(typeCfg->stereoModes[j]).enable(); | ||
| } | ||
| } | ||
|
|
||
| /* | ||
| * set up ports based on kPorts[] | ||
| */ | ||
| for (size_t i = 0; i < *(configuration.pKPortSize); i++) { | ||
| const dsAudioPortConfig_t *port = &configuration.pKPorts[i]; | ||
| _aPorts.push_back(AudioOutputPort((port->id.type), port->id.index, i)); | ||
| _aPortTypes.at(port->id.type).addPort(_aPorts.at(i)); | ||
| } | ||
|
|
||
| #if 0 | ||
| if(searchConfigs() == true) | ||
| { | ||
| /* | ||
| * Initialize Audio portTypes (encodings, compressions etc.) | ||
| * and its port instances (db, level etc) | ||
| */ | ||
| if(kConfigs1 != NULL) | ||
| { | ||
| for (size_t i = 0; i < kConfig_size_local; i++) { | ||
| const dsAudioTypeConfig_t *typeCfg = &kConfigs1[i]; | ||
| AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); | ||
| aPortType.enable(); | ||
| for (size_t j = 0; j < typeCfg->numSupportedEncodings; j++) { | ||
| aPortType.addEncoding(AudioEncoding::getInstance(typeCfg->encodings[j])); | ||
| _aEncodings.at(typeCfg->encodings[j]).enable(); | ||
| } | ||
| for (size_t j = 0; j < typeCfg->numSupportedCompressions; j++) { | ||
| aPortType.addCompression(typeCfg->compressions[j]); | ||
| _aCompressions.at(typeCfg->compressions[j]).enable(); | ||
| } | ||
| for (size_t j = 0; j < typeCfg->numSupportedStereoModes; j++) { | ||
| aPortType.addStereoMode(typeCfg->stereoModes[j]); | ||
| _aStereoModes.at(typeCfg->stereoModes[j]).enable(); | ||
| } | ||
| } | ||
|
|
||
| /* | ||
| * set up ports based on kPorts[] | ||
| */ | ||
| if(kPorts1 != NULL) | ||
| { | ||
| for (size_t i = 0; i < kPort_size_local; i++) { | ||
| const dsAudioPortConfig_t *port = &kPorts1[i]; | ||
| _aPorts.push_back(AudioOutputPort((port->id.type), port->id.index, i)); | ||
| _aPortTypes.at(port->id.type).addPort(_aPorts.at(i)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
| else{ | ||
| /* | ||
| * Initialize Audio portTypes (encodings, compressions etc.) | ||
| * and its port instances (db, level etc) | ||
|
|
@@ -165,6 +497,8 @@ | |
| _aPorts.push_back(AudioOutputPort((port->id.type), port->id.index, i)); | ||
| _aPortTypes.at(port->id.type).addPort(_aPorts.at(i)); | ||
| } | ||
| } | ||
| #endif | ||
|
|
||
| } | ||
| catch(const Exception &e) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of using INT_INFO and creating macro for "#define DEBUG 1 /" use INT_DEBUG and remove macro
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will do change to INT_DEBUG in final review before merge since debug logs are not coming.