Loading include/private/media/AudioTrackShared.h +14 −1 Original line number Diff line number Diff line Loading @@ -76,7 +76,9 @@ struct audio_track_cblk_t // Left channel is in [0:15], right channel is in [16:31]. // Always read and write the combined pair atomically. // For AudioTrack only, not used by AudioRecord. uint32_t volumeLR; private: uint32_t mVolumeLR; public: uint32_t sampleRate; // NOTE: audio_track_cblk_t::frameSize is not equal to AudioTrack::frameSize() for Loading Loading @@ -116,6 +118,17 @@ public: uint16_t getSendLevel_U4_12() const { return mSendLevel; } // for AudioTrack client only, caller must limit to 0 <= volumeLR <= 0x10001000 void setVolumeLR(uint32_t volumeLR) { mVolumeLR = volumeLR; } // for AudioFlinger only; the return value must be validated by the caller uint32_t getVolumeLR() const { return mVolumeLR; } }; Loading media/libmedia/AudioTrack.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -501,7 +501,7 @@ status_t AudioTrack::setVolume(float left, float right) mVolume[LEFT] = left; mVolume[RIGHT] = right; mCblk->volumeLR = (uint32_t(uint16_t(right * 0x1000)) << 16) | uint16_t(left * 0x1000); mCblk->setVolumeLR((uint32_t(uint16_t(right * 0x1000)) << 16) | uint16_t(left * 0x1000)); return NO_ERROR; } Loading Loading @@ -837,7 +837,7 @@ status_t AudioTrack::createTrack_l( mCblk->stepUser(mCblk->frameCount); } mCblk->volumeLR = (uint32_t(uint16_t(mVolume[RIGHT] * 0x1000)) << 16) | uint16_t(mVolume[LEFT] * 0x1000); mCblk->setVolumeLR((uint32_t(uint16_t(mVolume[RIGHT] * 0x1000)) << 16) | uint16_t(mVolume[LEFT] * 0x1000)); mCblk->setSendLevel(mSendLevel); mAudioTrack->attachAuxEffect(mAuxEffectId); mCblk->bufferTimeoutMs = MAX_STARTUP_TIMEOUT_MS; Loading Loading @@ -1320,7 +1320,7 @@ void AudioTrack::AudioTrackThread::onFirstRef() audio_track_cblk_t::audio_track_cblk_t() : lock(Mutex::SHARED), cv(Condition::SHARED), user(0), server(0), userBase(0), serverBase(0), buffers(0), frameCount(0), loopStart(UINT_MAX), loopEnd(UINT_MAX), loopCount(0), volumeLR(0), loopStart(UINT_MAX), loopEnd(UINT_MAX), loopCount(0), mVolumeLR(0x10001000), mSendLevel(0), flags(0) { } Loading services/audioflinger/AudioFlinger.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -2193,7 +2193,7 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac // read original volumes with volume control float typeVolume = mStreamTypes[track->type()].volume; float v = masterVolume * typeVolume; uint32_t vlr = cblk->volumeLR; uint32_t vlr = cblk->getVolumeLR(); vl = vlr & 0xFFFF; vr = vlr >> 16; // track volumes come from shared memory, so can't be trusted and must be clamped Loading Loading @@ -2731,7 +2731,7 @@ bool AudioFlinger::DirectOutputThread::threadLoop() } else { float typeVolume = mStreamTypes[track->type()].volume; float v = mMasterVolume * typeVolume; uint32_t vlr = cblk->volumeLR; uint32_t vlr = cblk->getVolumeLR(); float v_clamped = v * (vlr & 0xFFFF); if (v_clamped > MAX_GAIN) v_clamped = MAX_GAIN; left = v_clamped/MAX_GAIN; Loading Loading @@ -3470,7 +3470,7 @@ void AudioFlinger::PlaybackThread::Track::destroy() void AudioFlinger::PlaybackThread::Track::dump(char* buffer, size_t size) { uint32_t vlr = mCblk->volumeLR; uint32_t vlr = mCblk->getVolumeLR(); snprintf(buffer, size, " %05d %05d %03u %03u 0x%08x %05u %04u %1d %1d %1d %05u %05u %05u 0x%08x 0x%08x 0x%08x 0x%08x\n", mName - AudioMixer::TRACK0, (mClient == NULL) ? getpid() : mClient->pid(), Loading Loading @@ -3829,7 +3829,6 @@ AudioFlinger::PlaybackThread::OutputTrack::OutputTrack( if (mCblk != NULL) { mCblk->flags |= CBLK_DIRECTION_OUT; mCblk->buffers = (char*)mCblk + sizeof(audio_track_cblk_t); mCblk->volumeLR = (MAX_GAIN_INT << 16) | MAX_GAIN_INT; mOutBuffer.frameCount = 0; playbackThread->mTracks.add(this); ALOGV("OutputTrack constructor mCblk %p, mBuffer %p, mCblk->buffers %p, " \ Loading Loading
include/private/media/AudioTrackShared.h +14 −1 Original line number Diff line number Diff line Loading @@ -76,7 +76,9 @@ struct audio_track_cblk_t // Left channel is in [0:15], right channel is in [16:31]. // Always read and write the combined pair atomically. // For AudioTrack only, not used by AudioRecord. uint32_t volumeLR; private: uint32_t mVolumeLR; public: uint32_t sampleRate; // NOTE: audio_track_cblk_t::frameSize is not equal to AudioTrack::frameSize() for Loading Loading @@ -116,6 +118,17 @@ public: uint16_t getSendLevel_U4_12() const { return mSendLevel; } // for AudioTrack client only, caller must limit to 0 <= volumeLR <= 0x10001000 void setVolumeLR(uint32_t volumeLR) { mVolumeLR = volumeLR; } // for AudioFlinger only; the return value must be validated by the caller uint32_t getVolumeLR() const { return mVolumeLR; } }; Loading
media/libmedia/AudioTrack.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -501,7 +501,7 @@ status_t AudioTrack::setVolume(float left, float right) mVolume[LEFT] = left; mVolume[RIGHT] = right; mCblk->volumeLR = (uint32_t(uint16_t(right * 0x1000)) << 16) | uint16_t(left * 0x1000); mCblk->setVolumeLR((uint32_t(uint16_t(right * 0x1000)) << 16) | uint16_t(left * 0x1000)); return NO_ERROR; } Loading Loading @@ -837,7 +837,7 @@ status_t AudioTrack::createTrack_l( mCblk->stepUser(mCblk->frameCount); } mCblk->volumeLR = (uint32_t(uint16_t(mVolume[RIGHT] * 0x1000)) << 16) | uint16_t(mVolume[LEFT] * 0x1000); mCblk->setVolumeLR((uint32_t(uint16_t(mVolume[RIGHT] * 0x1000)) << 16) | uint16_t(mVolume[LEFT] * 0x1000)); mCblk->setSendLevel(mSendLevel); mAudioTrack->attachAuxEffect(mAuxEffectId); mCblk->bufferTimeoutMs = MAX_STARTUP_TIMEOUT_MS; Loading Loading @@ -1320,7 +1320,7 @@ void AudioTrack::AudioTrackThread::onFirstRef() audio_track_cblk_t::audio_track_cblk_t() : lock(Mutex::SHARED), cv(Condition::SHARED), user(0), server(0), userBase(0), serverBase(0), buffers(0), frameCount(0), loopStart(UINT_MAX), loopEnd(UINT_MAX), loopCount(0), volumeLR(0), loopStart(UINT_MAX), loopEnd(UINT_MAX), loopCount(0), mVolumeLR(0x10001000), mSendLevel(0), flags(0) { } Loading
services/audioflinger/AudioFlinger.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -2193,7 +2193,7 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac // read original volumes with volume control float typeVolume = mStreamTypes[track->type()].volume; float v = masterVolume * typeVolume; uint32_t vlr = cblk->volumeLR; uint32_t vlr = cblk->getVolumeLR(); vl = vlr & 0xFFFF; vr = vlr >> 16; // track volumes come from shared memory, so can't be trusted and must be clamped Loading Loading @@ -2731,7 +2731,7 @@ bool AudioFlinger::DirectOutputThread::threadLoop() } else { float typeVolume = mStreamTypes[track->type()].volume; float v = mMasterVolume * typeVolume; uint32_t vlr = cblk->volumeLR; uint32_t vlr = cblk->getVolumeLR(); float v_clamped = v * (vlr & 0xFFFF); if (v_clamped > MAX_GAIN) v_clamped = MAX_GAIN; left = v_clamped/MAX_GAIN; Loading Loading @@ -3470,7 +3470,7 @@ void AudioFlinger::PlaybackThread::Track::destroy() void AudioFlinger::PlaybackThread::Track::dump(char* buffer, size_t size) { uint32_t vlr = mCblk->volumeLR; uint32_t vlr = mCblk->getVolumeLR(); snprintf(buffer, size, " %05d %05d %03u %03u 0x%08x %05u %04u %1d %1d %1d %05u %05u %05u 0x%08x 0x%08x 0x%08x 0x%08x\n", mName - AudioMixer::TRACK0, (mClient == NULL) ? getpid() : mClient->pid(), Loading Loading @@ -3829,7 +3829,6 @@ AudioFlinger::PlaybackThread::OutputTrack::OutputTrack( if (mCblk != NULL) { mCblk->flags |= CBLK_DIRECTION_OUT; mCblk->buffers = (char*)mCblk + sizeof(audio_track_cblk_t); mCblk->volumeLR = (MAX_GAIN_INT << 16) | MAX_GAIN_INT; mOutBuffer.frameCount = 0; playbackThread->mTracks.add(this); ALOGV("OutputTrack constructor mCblk %p, mBuffer %p, mCblk->buffers %p, " \ Loading