EffectVisualizer: Fix aliasing violations
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
diff --git a/media/libeffects/visualizer/EffectVisualizer.cpp b/media/libeffects/visualizer/EffectVisualizer.cpp
index e7eccf1..07c0e44 100644
--- a/media/libeffects/visualizer/EffectVisualizer.cpp
+++ b/media/libeffects/visualizer/EffectVisualizer.cpp
@@ -404,22 +404,27 @@
}
memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + sizeof(uint32_t));
effect_param_t *p = (effect_param_t *)pReplyData;
+ union {
+ char *data;
+ uint32_t *data32;
+ };
+ data = p->data;
p->status = 0;
*replySize = sizeof(effect_param_t) + sizeof(uint32_t);
if (p->psize != sizeof(uint32_t)) {
p->status = -EINVAL;
break;
}
- switch (*(uint32_t *)p->data) {
+ switch (data32[0]) {
case VISUALIZER_PARAM_CAPTURE_SIZE:
ALOGV("get mCaptureSize = %d", pContext->mCaptureSize);
- *((uint32_t *)p->data + 1) = pContext->mCaptureSize;
+ data[1] = pContext->mCaptureSize;
p->vsize = sizeof(uint32_t);
*replySize += sizeof(uint32_t);
break;
case VISUALIZER_PARAM_SCALING_MODE:
ALOGV("get mScalingMode = %d", pContext->mScalingMode);
- *((uint32_t *)p->data + 1) = pContext->mScalingMode;
+ data[1] = pContext->mScalingMode;
p->vsize = sizeof(uint32_t);
*replySize += sizeof(uint32_t);
break;
@@ -435,21 +440,26 @@
}
*(int32_t *)pReplyData = 0;
effect_param_t *p = (effect_param_t *)pCmdData;
+ union {
+ char *data;
+ uint32_t *data32;
+ };
+ data = p->data;
if (p->psize != sizeof(uint32_t) || p->vsize != sizeof(uint32_t)) {
*(int32_t *)pReplyData = -EINVAL;
break;
}
- switch (*(uint32_t *)p->data) {
+ switch (data32[0]) {
case VISUALIZER_PARAM_CAPTURE_SIZE:
- pContext->mCaptureSize = *((uint32_t *)p->data + 1);
+ pContext->mCaptureSize = data[1];
ALOGV("set mCaptureSize = %d", pContext->mCaptureSize);
break;
case VISUALIZER_PARAM_SCALING_MODE:
- pContext->mScalingMode = *((uint32_t *)p->data + 1);
+ pContext->mScalingMode = data[1];
ALOGV("set mScalingMode = %d", pContext->mScalingMode);
break;
case VISUALIZER_PARAM_LATENCY:
- pContext->mLatency = *((uint32_t *)p->data + 1);
+ pContext->mLatency = data[1];
ALOGV("set mLatency = %d", pContext->mLatency);
break;
default: