status_t lStatus;
int lSessionId;
- if (streamType >= AUDIO_STREAM_CNT) {
+ // client AudioTrack::set already implements AUDIO_STREAM_DEFAULT => AUDIO_STREAM_MUSIC,
+ // but if someone uses binder directly they could bypass that and cause us to crash
+ if (uint32_t(streamType) >= AUDIO_STREAM_CNT) {
ALOGE("createTrack() invalid stream type %d", streamType);
lStatus = BAD_VALUE;
goto Exit;
return PERMISSION_DENIED;
}
- if (stream < 0 || uint32_t(stream) >= AUDIO_STREAM_CNT) {
+ if (uint32_t(stream) >= AUDIO_STREAM_CNT) {
ALOGE("setStreamVolume() invalid stream %d", stream);
return BAD_VALUE;
}
return PERMISSION_DENIED;
}
- if (stream < 0 || uint32_t(stream) >= AUDIO_STREAM_CNT ||
+ if (uint32_t(stream) >= AUDIO_STREAM_CNT ||
uint32_t(stream) == AUDIO_STREAM_ENFORCED_AUDIBLE) {
ALOGE("setStreamMute() invalid stream %d", stream);
return BAD_VALUE;
float AudioFlinger::streamVolume(audio_stream_type_t stream, int output) const
{
- if (stream < 0 || uint32_t(stream) >= AUDIO_STREAM_CNT) {
+ if (uint32_t(stream) >= AUDIO_STREAM_CNT) {
return 0.0f;
}
bool AudioFlinger::streamMute(audio_stream_type_t stream) const
{
- if (stream < 0 || stream >= (int)AUDIO_STREAM_CNT) {
+ if (uint32_t(stream) >= AUDIO_STREAM_CNT) {
return true;
}
mMasterVolume = mAudioFlinger->masterVolume_l();
mMasterMute = mAudioFlinger->masterMute_l();
+ // mStreamTypes[AUDIO_STREAM_CNT] is initialized by stream_type_t default constructor
// There is no AUDIO_STREAM_MIN, and ++ operator does not compile
for (audio_stream_type_t stream = (audio_stream_type_t) 0; stream < AUDIO_STREAM_CNT;
stream = (audio_stream_type_t) (stream + 1)) {
mStreamTypes[stream].volume = mAudioFlinger->streamVolumeInternal(stream);
mStreamTypes[stream].mute = mAudioFlinger->streamMute(stream);
- mStreamTypes[stream].valid = true;
+ // initialized by stream_type_t default constructor
+ // mStreamTypes[stream].valid = true;
}
}
if (!checkPermission()) {
return PERMISSION_DENIED;
}
- if (stream < 0 || stream >= AUDIO_STREAM_CNT) {
+ if (uint32_t(stream) >= AUDIO_STREAM_CNT) {
return BAD_VALUE;
}
mpAudioPolicy->init_stream_volume(mpAudioPolicy, stream, indexMin, indexMax);
if (!checkPermission()) {
return PERMISSION_DENIED;
}
- if (stream < 0 || stream >= AUDIO_STREAM_CNT) {
+ if (uint32_t(stream) >= AUDIO_STREAM_CNT) {
return BAD_VALUE;
}
if (mpAudioPolicy == NULL) {
return NO_INIT;
}
- if (stream < 0 || stream >= AUDIO_STREAM_CNT) {
+ if (uint32_t(stream) >= AUDIO_STREAM_CNT) {
return BAD_VALUE;
}
return mpAudioPolicy->get_stream_volume_index(mpAudioPolicy, stream, index);