Loading media/libmedia/AudioTrack.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -285,7 +285,7 @@ status_t AudioTrack::set( } if (pAttributes == NULL) { if (uint32_t(streamType) >= AUDIO_STREAM_CNT) { if (uint32_t(streamType) >= AUDIO_STREAM_PUBLIC_CNT) { ALOGE("Invalid stream type %d", streamType); return BAD_VALUE; } Loading services/audioflinger/AudioFlinger.cpp +30 −7 Original line number Diff line number Diff line Loading @@ -891,6 +891,21 @@ bool AudioFlinger::masterMute_l() const return mMasterMute; } status_t AudioFlinger::checkStreamType(audio_stream_type_t stream) const { if (uint32_t(stream) >= AUDIO_STREAM_CNT) { ALOGW("setStreamVolume() invalid stream %d", stream); return BAD_VALUE; } pid_t caller = IPCThreadState::self()->getCallingPid(); if (uint32_t(stream) >= AUDIO_STREAM_PUBLIC_CNT && caller != getpid_cached) { ALOGW("setStreamVolume() pid %d cannot use internal stream type %d", caller, stream); return PERMISSION_DENIED; } return NO_ERROR; } status_t AudioFlinger::setStreamVolume(audio_stream_type_t stream, float value, audio_io_handle_t output) { Loading @@ -899,10 +914,11 @@ status_t AudioFlinger::setStreamVolume(audio_stream_type_t stream, float value, return PERMISSION_DENIED; } if (uint32_t(stream) >= AUDIO_STREAM_CNT) { ALOGE("setStreamVolume() invalid stream %d", stream); return BAD_VALUE; status_t status = checkStreamType(stream); if (status != NO_ERROR) { return status; } ALOG_ASSERT(stream != AUDIO_STREAM_PATCH, "attempt to change AUDIO_STREAM_PATCH volume"); AutoMutex lock(mLock); PlaybackThread *thread = NULL; Loading Loading @@ -933,8 +949,13 @@ status_t AudioFlinger::setStreamMute(audio_stream_type_t stream, bool muted) return PERMISSION_DENIED; } if (uint32_t(stream) >= AUDIO_STREAM_CNT || uint32_t(stream) == AUDIO_STREAM_ENFORCED_AUDIBLE) { status_t status = checkStreamType(stream); if (status != NO_ERROR) { return status; } ALOG_ASSERT(stream != AUDIO_STREAM_PATCH, "attempt to mute AUDIO_STREAM_PATCH"); if (uint32_t(stream) == AUDIO_STREAM_ENFORCED_AUDIBLE) { ALOGE("setStreamMute() invalid stream %d", stream); return BAD_VALUE; } Loading @@ -949,7 +970,8 @@ status_t AudioFlinger::setStreamMute(audio_stream_type_t stream, bool muted) float AudioFlinger::streamVolume(audio_stream_type_t stream, audio_io_handle_t output) const { if (uint32_t(stream) >= AUDIO_STREAM_CNT) { status_t status = checkStreamType(stream); if (status != NO_ERROR) { return 0.0f; } Loading @@ -970,7 +992,8 @@ float AudioFlinger::streamVolume(audio_stream_type_t stream, audio_io_handle_t o bool AudioFlinger::streamMute(audio_stream_type_t stream) const { if (uint32_t(stream) >= AUDIO_STREAM_CNT) { status_t status = checkStreamType(stream); if (status != NO_ERROR) { return true; } Loading services/audioflinger/AudioFlinger.h +2 −0 Original line number Diff line number Diff line Loading @@ -745,6 +745,8 @@ private: void closeInputInternal_l(sp<RecordThread> thread); void setAudioHwSyncForSession_l(PlaybackThread *thread, audio_session_t sessionId); status_t checkStreamType(audio_stream_type_t stream) const; #ifdef TEE_SINK // all record threads serially share a common tee sink, which is re-created on format change sp<NBAIO_Sink> mRecordTeeSink; Loading services/audioflinger/Threads.cpp +2 −5 Original line number Diff line number Diff line Loading @@ -1224,15 +1224,12 @@ AudioFlinger::PlaybackThread::PlaybackThread(const sp<AudioFlinger>& audioFlinge readOutputParameters_l(); // mStreamTypes[AUDIO_STREAM_CNT] is initialized by stream_type_t default constructor // There is no AUDIO_STREAM_MIN, and ++ operator does not compile // ++ operator does not compile for (audio_stream_type_t stream = AUDIO_STREAM_MIN; stream < AUDIO_STREAM_CNT; stream = (audio_stream_type_t) (stream + 1)) { mStreamTypes[stream].volume = mAudioFlinger->streamVolume_l(stream); mStreamTypes[stream].mute = mAudioFlinger->streamMute_l(stream); } // mStreamTypes[AUDIO_STREAM_CNT] exists but isn't explicitly initialized here, // because mAudioFlinger doesn't have one to copy from } AudioFlinger::PlaybackThread::~PlaybackThread() Loading Loading @@ -4746,7 +4743,7 @@ void AudioFlinger::DuplicatingThread::addOutputTrack(MixerThread *thread) frameCount, IPCThreadState::self()->getCallingUid()); if (outputTrack->cblk() != NULL) { thread->setStreamVolume(AUDIO_STREAM_CNT, 1.0f); thread->setStreamVolume(AUDIO_STREAM_PATCH, 1.0f); mOutputTracks.add(outputTrack); ALOGV("addOutputTrack() track %p, on thread %p", outputTrack, thread); updateWaitTime_l(); Loading services/audioflinger/Threads.h +1 −3 Original line number Diff line number Diff line Loading @@ -727,9 +727,7 @@ private: void dumpTracks(int fd, const Vector<String16>& args); SortedVector< sp<Track> > mTracks; // mStreamTypes[] uses 1 additional stream type internally for the OutputTrack used by // DuplicatingThread stream_type_t mStreamTypes[AUDIO_STREAM_CNT + 1]; stream_type_t mStreamTypes[AUDIO_STREAM_CNT]; AudioStreamOut *mOutput; float mMasterVolume; Loading Loading
media/libmedia/AudioTrack.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -285,7 +285,7 @@ status_t AudioTrack::set( } if (pAttributes == NULL) { if (uint32_t(streamType) >= AUDIO_STREAM_CNT) { if (uint32_t(streamType) >= AUDIO_STREAM_PUBLIC_CNT) { ALOGE("Invalid stream type %d", streamType); return BAD_VALUE; } Loading
services/audioflinger/AudioFlinger.cpp +30 −7 Original line number Diff line number Diff line Loading @@ -891,6 +891,21 @@ bool AudioFlinger::masterMute_l() const return mMasterMute; } status_t AudioFlinger::checkStreamType(audio_stream_type_t stream) const { if (uint32_t(stream) >= AUDIO_STREAM_CNT) { ALOGW("setStreamVolume() invalid stream %d", stream); return BAD_VALUE; } pid_t caller = IPCThreadState::self()->getCallingPid(); if (uint32_t(stream) >= AUDIO_STREAM_PUBLIC_CNT && caller != getpid_cached) { ALOGW("setStreamVolume() pid %d cannot use internal stream type %d", caller, stream); return PERMISSION_DENIED; } return NO_ERROR; } status_t AudioFlinger::setStreamVolume(audio_stream_type_t stream, float value, audio_io_handle_t output) { Loading @@ -899,10 +914,11 @@ status_t AudioFlinger::setStreamVolume(audio_stream_type_t stream, float value, return PERMISSION_DENIED; } if (uint32_t(stream) >= AUDIO_STREAM_CNT) { ALOGE("setStreamVolume() invalid stream %d", stream); return BAD_VALUE; status_t status = checkStreamType(stream); if (status != NO_ERROR) { return status; } ALOG_ASSERT(stream != AUDIO_STREAM_PATCH, "attempt to change AUDIO_STREAM_PATCH volume"); AutoMutex lock(mLock); PlaybackThread *thread = NULL; Loading Loading @@ -933,8 +949,13 @@ status_t AudioFlinger::setStreamMute(audio_stream_type_t stream, bool muted) return PERMISSION_DENIED; } if (uint32_t(stream) >= AUDIO_STREAM_CNT || uint32_t(stream) == AUDIO_STREAM_ENFORCED_AUDIBLE) { status_t status = checkStreamType(stream); if (status != NO_ERROR) { return status; } ALOG_ASSERT(stream != AUDIO_STREAM_PATCH, "attempt to mute AUDIO_STREAM_PATCH"); if (uint32_t(stream) == AUDIO_STREAM_ENFORCED_AUDIBLE) { ALOGE("setStreamMute() invalid stream %d", stream); return BAD_VALUE; } Loading @@ -949,7 +970,8 @@ status_t AudioFlinger::setStreamMute(audio_stream_type_t stream, bool muted) float AudioFlinger::streamVolume(audio_stream_type_t stream, audio_io_handle_t output) const { if (uint32_t(stream) >= AUDIO_STREAM_CNT) { status_t status = checkStreamType(stream); if (status != NO_ERROR) { return 0.0f; } Loading @@ -970,7 +992,8 @@ float AudioFlinger::streamVolume(audio_stream_type_t stream, audio_io_handle_t o bool AudioFlinger::streamMute(audio_stream_type_t stream) const { if (uint32_t(stream) >= AUDIO_STREAM_CNT) { status_t status = checkStreamType(stream); if (status != NO_ERROR) { return true; } Loading
services/audioflinger/AudioFlinger.h +2 −0 Original line number Diff line number Diff line Loading @@ -745,6 +745,8 @@ private: void closeInputInternal_l(sp<RecordThread> thread); void setAudioHwSyncForSession_l(PlaybackThread *thread, audio_session_t sessionId); status_t checkStreamType(audio_stream_type_t stream) const; #ifdef TEE_SINK // all record threads serially share a common tee sink, which is re-created on format change sp<NBAIO_Sink> mRecordTeeSink; Loading
services/audioflinger/Threads.cpp +2 −5 Original line number Diff line number Diff line Loading @@ -1224,15 +1224,12 @@ AudioFlinger::PlaybackThread::PlaybackThread(const sp<AudioFlinger>& audioFlinge readOutputParameters_l(); // mStreamTypes[AUDIO_STREAM_CNT] is initialized by stream_type_t default constructor // There is no AUDIO_STREAM_MIN, and ++ operator does not compile // ++ operator does not compile for (audio_stream_type_t stream = AUDIO_STREAM_MIN; stream < AUDIO_STREAM_CNT; stream = (audio_stream_type_t) (stream + 1)) { mStreamTypes[stream].volume = mAudioFlinger->streamVolume_l(stream); mStreamTypes[stream].mute = mAudioFlinger->streamMute_l(stream); } // mStreamTypes[AUDIO_STREAM_CNT] exists but isn't explicitly initialized here, // because mAudioFlinger doesn't have one to copy from } AudioFlinger::PlaybackThread::~PlaybackThread() Loading Loading @@ -4746,7 +4743,7 @@ void AudioFlinger::DuplicatingThread::addOutputTrack(MixerThread *thread) frameCount, IPCThreadState::self()->getCallingUid()); if (outputTrack->cblk() != NULL) { thread->setStreamVolume(AUDIO_STREAM_CNT, 1.0f); thread->setStreamVolume(AUDIO_STREAM_PATCH, 1.0f); mOutputTracks.add(outputTrack); ALOGV("addOutputTrack() track %p, on thread %p", outputTrack, thread); updateWaitTime_l(); Loading
services/audioflinger/Threads.h +1 −3 Original line number Diff line number Diff line Loading @@ -727,9 +727,7 @@ private: void dumpTracks(int fd, const Vector<String16>& args); SortedVector< sp<Track> > mTracks; // mStreamTypes[] uses 1 additional stream type internally for the OutputTrack used by // DuplicatingThread stream_type_t mStreamTypes[AUDIO_STREAM_CNT + 1]; stream_type_t mStreamTypes[AUDIO_STREAM_CNT]; AudioStreamOut *mOutput; float mMasterVolume; Loading