-
Notifications
You must be signed in to change notification settings - Fork 4
[poc]Cpesp 7136 extern #143
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 3 commits
bec9c03
a1ce0dd
34ef765
7deaac8
adf06cc
eb49b4a
1de2bef
4e473dd
1211fad
0521d96
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 | ||
| * | ||
|
|
@@ -35,6 +35,20 @@ | |
| #include "stdlib.h" | ||
| #include "dslogger.h" | ||
|
|
||
| #include <dlfcn.h> | ||
| #include "libIARM.h" | ||
| #include "libIBus.h" | ||
| #include "iarmUtil.h" | ||
|
|
||
| #define IARM_BUS_Lock(lock) pthread_mutex_lock(&dsLock) | ||
| #define IARM_BUS_Unlock(lock) pthread_mutex_unlock(&dsLock) | ||
| extern dsAudioTypeConfig_t *kConfig_audio; | ||
| extern dsAudioPortConfig_t *kPort_audio; | ||
| static dsAudioTypeConfig_t *kConfigs1 = NULL; | ||
| static dsAudioPortConfig_t *kPorts1 = NULL; | ||
|
|
||
| static pthread_mutex_t dsLock = PTHREAD_MUTEX_INITIALIZER; | ||
|
|
||
| namespace device { | ||
|
|
||
| //To Make the instance as thread-safe, using = default, that can request special methods from the compiler. They are Special because only compiler can create them. | ||
|
|
@@ -108,6 +122,110 @@ | |
| return supportedTypes; | ||
| } | ||
|
|
||
| bool searchConfigs() | ||
| { | ||
| //static dsAudioTypeConfig_t *kConfigs1 = NULL; | ||
| //static dsAudioPortConfig_t *kPorts1 = NULL; | ||
|
|
||
| //if ( kConfigs1 == NULL) | ||
| { | ||
| void *dllib = dlopen("libdshalsrv.so", RTLD_LAZY); | ||
| if (dllib) { | ||
| kConfigs1 = (dsAudioTypeConfig_t *) dlsym(dllib, "kConfig_audio"); | ||
| if (kConfigs1) { | ||
| INT_DEBUG("kConfig_audio is defined and loaded kConfigs1 = %p\r\n", kConfigs1); | ||
| printf("%d:%s: kConfig_audio is defined and loaded kConfigs1 = %p\n", __LINE__, __func__, kConfigs1); | ||
| } | ||
| else { | ||
| INT_INFO("kConfig_audio is not defined\r\n"); | ||
| printf("%d:%s: kConfig_audio is not defined\n", __LINE__, __func__); | ||
| //IARM_BUS_Unlock(lock); | ||
| dlclose(dllib); | ||
| return IARM_RESULT_INVALID_STATE; | ||
| } | ||
| dlclose(dllib); | ||
| } | ||
| else { | ||
| INT_ERROR("Opening libdshalsrv.so failed\r\n"); | ||
| printf("%d:%s: Opening libdshalsrv.so failed\n", __LINE__, __func__); | ||
| } | ||
| } | ||
|
|
||
| //if ( kPorts1 == NULL) | ||
| { | ||
| void *dllib = dlopen("libdshalsrv.so", RTLD_LAZY); | ||
| if (dllib) { | ||
| kPorts1 = (dsAudioPortConfig_t *) dlsym(dllib, "kPort_audio"); | ||
| if (kPorts1) { | ||
| INT_DEBUG("kPort_audio is defined and loaded kPorts1 = %p\r\n", kPorts1); | ||
| printf("%d:%s: kPort_audio is defined and loaded kPorts1 = %p\n", __LINE__, __func__, kPorts1); | ||
| } | ||
| else { | ||
| INT_INFO("kPort_audio is not defined\r\n"); | ||
| printf("%d:%s: kPort_audio is not defined\n", __LINE__, __func__); | ||
| //IARM_BUS_Unlock(lock); | ||
| dlclose(dllib); | ||
| return IARM_RESULT_INVALID_STATE; | ||
| } | ||
| dlclose(dllib); | ||
| } | ||
| else { | ||
| INT_ERROR("Opening libdshalsrv.so failed\r\n"); | ||
| printf("%d:%s: Opening libdshalsrv.so failed\n", __LINE__, __func__); | ||
| } | ||
| } | ||
| printf("\n\n=========================================================================================================================\n\n"); | ||
| printf("\n%d:%s print configs\n", __LINE__, __func__); | ||
| for (size_t i = 0; i < dsUTL_DIM(kConfigs1); i++) { | ||
|
||
| const dsAudioTypeConfig_t *typeCfg = &kConfigs1[i]; | ||
|
||
| AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); | ||
| aPortType.enable(); | ||
| printf("%d:%s: typeCfg->typeId = %d\n", __LINE__, __func__, typeCfg->typeId); | ||
| printf("%d:%s: typeCfg->name = %s\n", __LINE__, __func__, typeCfg->name); | ||
| printf("%d:%s: typeCfg->numSupportedEncodings = %zu\n", __LINE__, __func__, typeCfg->numSupportedEncodings); | ||
| printf("%d:%s: typeCfg->numSupportedCompressions = %zu\n", __LINE__, __func__, typeCfg->numSupportedCompressions); | ||
| printf("%d:%s: typeCfg->numSupportedStereoModes = %zu\n", __LINE__, __func__, typeCfg->numSupportedStereoModes); | ||
| } | ||
|
|
||
|
|
||
| /* | ||
| * set up ports based on kPorts[] | ||
| */ | ||
| for (size_t i = 0; i < dsUTL_DIM(kPorts1); i++) { | ||
|
||
| const dsAudioPortConfig_t *port = &kPorts1[i]; | ||
| printf("%d:%s: port->id.type = %d\n", __LINE__, __func__, port->id.type); | ||
| printf("%d:%s: port->id.index = %d\n", __LINE__, __func__, port->id.index); | ||
| } | ||
| printf("\n\n=========================================================================================================================\n\n"); | ||
|
|
||
| printf("\n\n=========================================================================================================================\n\n"); | ||
| printf("\n%d:%s print configs using extern\n", __LINE__, __func__); | ||
| for (size_t i = 0; i < dsUTL_DIM(kConfig_audio); i++) { | ||
|
||
| const dsAudioTypeConfig_t *typeCfg = &kConfig_audio[i]; | ||
| AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); | ||
| aPortType.enable(); | ||
| printf("%d:%s: typeCfg->typeId = %d\n", __LINE__, __func__, typeCfg->typeId); | ||
| printf("%d:%s: typeCfg->name = %s\n", __LINE__, __func__, typeCfg->name); | ||
| printf("%d:%s: typeCfg->numSupportedEncodings = %zu\n", __LINE__, __func__, typeCfg->numSupportedEncodings); | ||
| printf("%d:%s: typeCfg->numSupportedCompressions = %zu\n", __LINE__, __func__, typeCfg->numSupportedCompressions); | ||
| printf("%d:%s: typeCfg->numSupportedStereoModes = %zu\n", __LINE__, __func__, typeCfg->numSupportedStereoModes); | ||
| } | ||
|
|
||
|
|
||
| /* | ||
| * set up ports based on kPorts[] | ||
| */ | ||
| for (size_t i = 0; i < dsUTL_DIM(kPort_audio); i++) { | ||
|
||
| const dsAudioPortConfig_t *port = &kPort_audio[i]; | ||
| printf("%d:%s: port->id.type = %d\n", __LINE__, __func__, port->id.type); | ||
| printf("%d:%s: port->id.index = %d\n", __LINE__, __func__, port->id.index); | ||
| } | ||
| printf("\n\n=========================================================================================================================\n\n"); | ||
|
|
||
|
|
||
| return (kConfigs1 || kPorts1); | ||
| } | ||
|
|
||
| void AudioOutputPortConfig::load() | ||
| { | ||
| try { | ||
|
|
@@ -132,7 +250,7 @@ | |
| _aPortTypes.push_back(AudioOutputPortType(i)); | ||
|
|
||
| } | ||
|
|
||
| #if 1 | ||
| /* | ||
| * Initialize Audio portTypes (encodings, compressions etc.) | ||
| * and its port instances (db, level etc) | ||
|
|
@@ -165,6 +283,54 @@ | |
| _aPorts.push_back(AudioOutputPort((port->id.type), port->id.index, i)); | ||
| _aPortTypes.at(port->id.type).addPort(_aPorts.at(i)); | ||
| } | ||
| searchConfigs(); | ||
| #else //gsk | ||
| if(searchConfigs()) | ||
| { | ||
| /*if(kConfig_audio == NULL || kPort_audio == NULL) { | ||
| throw IllegalArgumentException(); | ||
| }*/ | ||
| //dsAudioTypeConfig_t *kConfigs = kConfig_audio; | ||
| //dsAudioPortConfig_t *kPorts = kPort_audio; | ||
| /* | ||
| * Initialize Audio portTypes (encodings, compressions etc.) | ||
| * and its port instances (db, level etc) | ||
| */ | ||
| for (size_t i = 0; i < dsUTL_DIM(kConfigs1); 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[] | ||
| */ | ||
| for (size_t i = 0; i < dsUTL_DIM(kPorts1); 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 | ||
| { | ||
| printf("%d:%s: kConfig and kPorts are not available\n", __LINE__, __func__); | ||
| } | ||
| #endif | ||
|
|
||
| } | ||
| catch(const Exception &e) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
Coverity issue no longer present as of: undefined
Show issue
Coverity Issue - Incorrect sizeof expression
The expression "sizeof (kConfigs1) / sizeof (kConfigs1[0])" is suspicious. Note that "kConfigs1" is a pointer and therefore the division will not return the number of array elements which may have been the intent.
Medium Impact, CWE-467
BAD_SIZEOF