summaryrefslogtreecommitdiffstats
path: root/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp')
-rw-r--r--media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp130
1 files changed, 40 insertions, 90 deletions
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
index d706c2d..35c7966 100644
--- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
@@ -2787,7 +2787,7 @@ int Effect_command(effect_handle_t self,
switch (cmdCode){
case EFFECT_CMD_INIT:
- if (pReplyData == NULL || *replySize != sizeof(int)){
+ if (pReplyData == NULL || replySize == NULL || *replySize != sizeof(int)){
ALOGV("\tLVM_ERROR, EFFECT_CMD_INIT: ERROR for effect type %d",
pContext->EffectType);
return -EINVAL;
@@ -2814,10 +2814,8 @@ int Effect_command(effect_handle_t self,
case EFFECT_CMD_SET_CONFIG:
//ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_CONFIG start");
- if (pCmdData == NULL||
- cmdSize != sizeof(effect_config_t)||
- pReplyData == NULL||
- *replySize != sizeof(int)){
+ if (pCmdData == NULL || cmdSize != sizeof(effect_config_t) ||
+ pReplyData == NULL || replySize == NULL || *replySize != sizeof(int)) {
ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: "
"EFFECT_CMD_SET_CONFIG: ERROR");
return -EINVAL;
@@ -2827,8 +2825,7 @@ int Effect_command(effect_handle_t self,
break;
case EFFECT_CMD_GET_CONFIG:
- if (pReplyData == NULL ||
- *replySize != sizeof(effect_config_t)) {
+ if (pReplyData == NULL || replySize == NULL || *replySize != sizeof(effect_config_t)) {
ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: "
"EFFECT_CMD_GET_CONFIG: ERROR");
return -EINVAL;
@@ -2845,31 +2842,28 @@ int Effect_command(effect_handle_t self,
case EFFECT_CMD_GET_PARAM:{
//ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_GET_PARAM start");
+ effect_param_t *p = (effect_param_t *)pCmdData;
- if(pContext->EffectType == LVM_BASS_BOOST){
- if (pCmdData == NULL ||
- cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
- pReplyData == NULL ||
- *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){
- ALOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: "
- "EFFECT_CMD_GET_PARAM: ERROR");
- return -EINVAL;
- }
- effect_param_t *p = (effect_param_t *)pCmdData;
+ if (pCmdData == NULL || cmdSize < sizeof(effect_param_t) ||
+ cmdSize < (sizeof(effect_param_t) + p->psize) ||
+ pReplyData == NULL || replySize == NULL ||
+ *replySize < (sizeof(effect_param_t) + p->psize)) {
+ ALOGV("\tLVM_ERROR : EFFECT_CMD_GET_PARAM: ERROR");
+ return -EINVAL;
+ }
- memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize);
+ memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize);
- p = (effect_param_t *)pReplyData;
+ p = (effect_param_t *)pReplyData;
- int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t);
+ int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t);
+ if(pContext->EffectType == LVM_BASS_BOOST){
p->status = android::BassBoost_getParameter(pContext,
p->data,
(size_t *)&p->vsize,
p->data + voffset);
- *replySize = sizeof(effect_param_t) + voffset + p->vsize;
-
//ALOGV("\tBassBoost_command EFFECT_CMD_GET_PARAM "
// "*pCmdData %d, *replySize %d, *pReplyData %d ",
// *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)),
@@ -2878,29 +2872,12 @@ int Effect_command(effect_handle_t self,
}
if(pContext->EffectType == LVM_VIRTUALIZER){
- if (pCmdData == NULL ||
- cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
- pReplyData == NULL ||
- *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){
- ALOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: "
- "EFFECT_CMD_GET_PARAM: ERROR");
- return -EINVAL;
- }
- effect_param_t *p = (effect_param_t *)pCmdData;
-
- memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize);
-
- p = (effect_param_t *)pReplyData;
-
- int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t);
p->status = android::Virtualizer_getParameter(pContext,
(void *)p->data,
(size_t *)&p->vsize,
p->data + voffset);
- *replySize = sizeof(effect_param_t) + voffset + p->vsize;
-
//ALOGV("\tVirtualizer_command EFFECT_CMD_GET_PARAM "
// "*pCmdData %d, *replySize %d, *pReplyData %d ",
// *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)),
@@ -2910,29 +2887,12 @@ int Effect_command(effect_handle_t self,
if(pContext->EffectType == LVM_EQUALIZER){
//ALOGV("\tEqualizer_command cmdCode Case: "
// "EFFECT_CMD_GET_PARAM start");
- if (pCmdData == NULL ||
- cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
- pReplyData == NULL ||
- *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))) {
- ALOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: "
- "EFFECT_CMD_GET_PARAM");
- return -EINVAL;
- }
- effect_param_t *p = (effect_param_t *)pCmdData;
-
- memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize);
-
- p = (effect_param_t *)pReplyData;
-
- int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t);
p->status = android::Equalizer_getParameter(pContext,
p->data,
&p->vsize,
p->data + voffset);
- *replySize = sizeof(effect_param_t) + voffset + p->vsize;
-
//ALOGV("\tEqualizer_command EFFECT_CMD_GET_PARAM *pCmdData %d, *replySize %d, "
// "*pReplyData %08x %08x",
// *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), *replySize,
@@ -2942,35 +2902,20 @@ int Effect_command(effect_handle_t self,
}
if(pContext->EffectType == LVM_VOLUME){
//ALOGV("\tVolume_command cmdCode Case: EFFECT_CMD_GET_PARAM start");
- if (pCmdData == NULL ||
- cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
- pReplyData == NULL ||
- *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){
- ALOGV("\tLVM_ERROR : Volume_command cmdCode Case: "
- "EFFECT_CMD_GET_PARAM: ERROR");
- return -EINVAL;
- }
- effect_param_t *p = (effect_param_t *)pCmdData;
-
- memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize);
-
- p = (effect_param_t *)pReplyData;
-
- int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t);
p->status = android::Volume_getParameter(pContext,
(void *)p->data,
(size_t *)&p->vsize,
p->data + voffset);
- *replySize = sizeof(effect_param_t) + voffset + p->vsize;
-
//ALOGV("\tVolume_command EFFECT_CMD_GET_PARAM "
// "*pCmdData %d, *replySize %d, *pReplyData %d ",
// *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)),
// *replySize,
// *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset));
}
+ *replySize = sizeof(effect_param_t) + voffset + p->vsize;
+
//ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_GET_PARAM end");
} break;
case EFFECT_CMD_SET_PARAM:{
@@ -2981,10 +2926,9 @@ int Effect_command(effect_handle_t self,
// *replySize,
// *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t)));
- if (pCmdData == NULL||
- cmdSize != (int)(sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int16_t))||
- pReplyData == NULL||
- *replySize != sizeof(int32_t)){
+ if (pCmdData == NULL ||
+ cmdSize != (sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int16_t)) ||
+ pReplyData == NULL || replySize == NULL || *replySize != sizeof(int32_t)) {
ALOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: "
"EFFECT_CMD_SET_PARAM: ERROR");
return -EINVAL;
@@ -3014,10 +2958,11 @@ int Effect_command(effect_handle_t self,
// *replySize,
// *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t)));
- if (pCmdData == NULL||
- cmdSize != (int)(sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int16_t))||
- pReplyData == NULL||
- *replySize != sizeof(int32_t)){
+ if (pCmdData == NULL ||
+ // legal parameters are int16_t or int32_t
+ cmdSize > (sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int32_t)) ||
+ cmdSize < (sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int16_t)) ||
+ pReplyData == NULL || replySize == NULL || *replySize != sizeof(int32_t)) {
ALOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: "
"EFFECT_CMD_SET_PARAM: ERROR");
return -EINVAL;
@@ -3050,7 +2995,7 @@ int Effect_command(effect_handle_t self,
// *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t)));
if (pCmdData == NULL || cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
- pReplyData == NULL || *replySize != sizeof(int32_t)) {
+ pReplyData == NULL || replySize == NULL || *replySize != sizeof(int32_t)) {
ALOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: "
"EFFECT_CMD_SET_PARAM: ERROR");
return -EINVAL;
@@ -3068,10 +3013,10 @@ int Effect_command(effect_handle_t self,
// *replySize,
// *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) +sizeof(int32_t)));
- if ( pCmdData == NULL||
- cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t))||
- pReplyData == NULL||
- *replySize != sizeof(int32_t)){
+ if (pCmdData == NULL ||
+ cmdSize < (sizeof(effect_param_t) + sizeof(int32_t)) ||
+ pReplyData == NULL || replySize == NULL ||
+ *replySize != sizeof(int32_t)) {
ALOGV("\tLVM_ERROR : Volume_command cmdCode Case: "
"EFFECT_CMD_SET_PARAM: ERROR");
return -EINVAL;
@@ -3087,7 +3032,7 @@ int Effect_command(effect_handle_t self,
case EFFECT_CMD_ENABLE:
ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE start");
- if (pReplyData == NULL || *replySize != sizeof(int)){
+ if (pReplyData == NULL || replySize == NULL || *replySize != sizeof(int)) {
ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_ENABLE: ERROR");
return -EINVAL;
}
@@ -3097,7 +3042,7 @@ int Effect_command(effect_handle_t self,
case EFFECT_CMD_DISABLE:
//ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE start");
- if (pReplyData == NULL || *replySize != sizeof(int)){
+ if (pReplyData == NULL || replySize == NULL || *replySize != sizeof(int)) {
ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_DISABLE: ERROR");
return -EINVAL;
}
@@ -3107,6 +3052,11 @@ int Effect_command(effect_handle_t self,
case EFFECT_CMD_SET_DEVICE:
{
ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_DEVICE start");
+ if (pCmdData == NULL){
+ ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_SET_DEVICE: ERROR");
+ return -EINVAL;
+ }
+
uint32_t device = *(uint32_t *)pCmdData;
if (pContext->EffectType == LVM_BASS_BOOST) {
@@ -3193,8 +3143,8 @@ int Effect_command(effect_handle_t self,
break;
}
- if (pCmdData == NULL ||
- cmdSize != 2 * sizeof(uint32_t)) {
+ if (pCmdData == NULL || cmdSize != 2 * sizeof(uint32_t) || pReplyData == NULL ||
+ replySize == NULL || *replySize < 2*sizeof(int32_t)) {
ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: "
"EFFECT_CMD_SET_VOLUME: ERROR");
return -EINVAL;