From 390e2b19c3bdbacfdf59afdbad1a6818c5f1ed0c Mon Sep 17 00:00:00 2001 From: Amal Paul Date: Fri, 15 Feb 2013 12:25:45 -0800 Subject: audioflinger: Fix to set correct volume in Tunnel playback - After a pause and resume, tunnel playback volume is always set to maximum irrespective of the volume value before pause. - The cause for this is, the stream volume is not used to set the volume in directaudiotrack. - Fix is to use the stream volume to set volume during tunnel playback. Change-Id: I59cda146ed88bd5c4186aeb9ae5d165f4a27493f CRs-fixed: 452285 --- services/audioflinger/AudioFlinger.cpp | 6 +++++- services/audioflinger/AudioFlinger.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index 0a0529a..e4c055a 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -1051,6 +1051,7 @@ status_t AudioFlinger::setStreamVolume(audio_stream_type_t stream, float value, ALOGV("setStreamVolume for mAudioTracks size %d desc %p",mDirectAudioTracks.size(),desc); if (desc->mStreamType == stream) { mStreamTypes[stream].volume = value; + desc->mVolumeScale = value; desc->stream->set_volume(desc->stream, desc->mVolumeLeft * mStreamTypes[stream].volume, desc->mVolumeRight* mStreamTypes[stream].volume); @@ -6163,6 +6164,7 @@ AudioFlinger::DirectAudioTrack::DirectAudioTrack(const sp& audioFl allocateBufPool(); } + outputDesc->mVolumeScale = 1.0; mDeathRecipient = new PMDeathRecipient(this); acquireWakeLock(); } @@ -6247,7 +6249,9 @@ void AudioFlinger::DirectAudioTrack::mute(bool muted) { void AudioFlinger::DirectAudioTrack::setVolume(float left, float right) { mOutputDesc->mVolumeLeft = left; mOutputDesc->mVolumeRight = right; - mOutputDesc->stream->set_volume(mOutputDesc->stream,left,right); + mOutputDesc->stream->set_volume(mOutputDesc->stream, + left * mOutputDesc->mVolumeScale, + right* mOutputDesc->mVolumeScale); } int64_t AudioFlinger::DirectAudioTrack::getTimeStamp() { diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h index dcdc55c..cbda3fe 100644 --- a/services/audioflinger/AudioFlinger.h +++ b/services/audioflinger/AudioFlinger.h @@ -2160,6 +2160,7 @@ mutable Mutex mLock; // mutex for process, commands and handl int mStreamType; float mVolumeLeft; float mVolumeRight; + float mVolumeScale; audio_hw_device_t *hwDev; audio_stream_out_t *stream; audio_output_flags_t flag; -- cgit v1.1