summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2012-01-06 16:47:31 -0800
committerGlenn Kasten <gkasten@google.com>2012-01-10 15:42:32 -0800
commit930f4caa1e311ef7ff538c421a324396157eb24f (patch)
treeac544b75a8964ac7759355fd0659d246070bcc57
parentc1dc1cb1d1eaf84e88669f1a5f22579a0d9237c2 (diff)
downloadframeworks_av-930f4caa1e311ef7ff538c421a324396157eb24f.zip
frameworks_av-930f4caa1e311ef7ff538c421a324396157eb24f.tar.gz
frameworks_av-930f4caa1e311ef7ff538c421a324396157eb24f.tar.bz2
Simplify range check for audio_mode_t
AudioSystem::setMode previously allowed negative modes, but these were then rejected by AudioFlinger. Now negative modes (including AUDIO_MODE_INVALID and AUDIO_MODE_CURRENT) are explicitly disallowed. Change-Id: I0bac8fea737c8eb1f5b6afbb893e48739f88d745
-rw-r--r--media/libmedia/AudioSystem.cpp2
-rw-r--r--services/audioflinger/AudioFlinger.cpp2
-rw-r--r--services/audioflinger/AudioPolicyService.cpp2
3 files changed, 3 insertions, 3 deletions
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index f7f129c..84f6b7c 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -158,7 +158,7 @@ status_t AudioSystem::getStreamMute(int stream, bool* mute)
status_t AudioSystem::setMode(int mode)
{
- if (mode >= AUDIO_MODE_CNT) return BAD_VALUE;
+ if (uint32_t(mode) >= AUDIO_MODE_CNT) return BAD_VALUE;
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
if (af == 0) return PERMISSION_DENIED;
return af->setMode(mode);
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 4ddefdb..3b5b1b1 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -574,7 +574,7 @@ status_t AudioFlinger::setMode(int mode)
if (!settingsAllowed()) {
return PERMISSION_DENIED;
}
- if ((mode < 0) || (mode >= AUDIO_MODE_CNT)) {
+ if (uint32_t(mode) >= AUDIO_MODE_CNT) {
ALOGW("Illegal value: setMode(%d)", mode);
return BAD_VALUE;
}
diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp
index f572fce..3f86d58 100644
--- a/services/audioflinger/AudioPolicyService.cpp
+++ b/services/audioflinger/AudioPolicyService.cpp
@@ -193,7 +193,7 @@ status_t AudioPolicyService::setPhoneState(int state)
if (!checkPermission()) {
return PERMISSION_DENIED;
}
- if (state < 0 || state >= AUDIO_MODE_CNT) {
+ if (uint32_t(state) >= AUDIO_MODE_CNT) {
return BAD_VALUE;
}