Loading services/audioflinger/Threads.cpp +26 −7 Original line number Diff line number Diff line Loading @@ -1668,7 +1668,8 @@ AudioFlinger::PlaybackThread::PlaybackThread(const sp<AudioFlinger>& audioFlinge mScreenState(AudioFlinger::mScreenState), // index 0 is reserved for normal mixer's submix mFastTrackAvailMask(((1 << FastMixerState::sMaxFastTracks) - 1) & ~1), mHwSupportsPause(false), mHwPaused(false), mFlushPending(false) mHwSupportsPause(false), mHwPaused(false), mFlushPending(false), mLeftVolFloat(-1.0), mRightVolFloat(-1.0) { snprintf(mThreadName, kThreadNameLength, "AudioOut_%X", id); mNBLogWriter = audioFlinger->newWriter_l(kLogSize, mThreadName); Loading Loading @@ -4295,6 +4296,7 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac param = AudioMixer::RAMP_VOLUME; } mAudioMixer->setParameter(name, AudioMixer::RESAMPLE, AudioMixer::RESET, NULL); mLeftVolFloat = -1.0; // FIXME should not make a decision based on mServer } else if (cblk->mServer != 0) { // If the track is stopped before the first frame was mixed, Loading @@ -4305,6 +4307,10 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac // compute volume for this track uint32_t vl, vr; // in U8.24 integer format float vlf, vrf, vaf; // in [0.0, 1.0] float format // read original volumes with volume control float typeVolume = mStreamTypes[track->streamType()].volume; float v = masterVolume * typeVolume; if (track->isPausing() || mStreamTypes[track->streamType()].mute) { vl = vr = 0; vlf = vrf = vaf = 0.; Loading @@ -4312,10 +4318,6 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac track->setPaused(); } } else { // read original volumes with volume control float typeVolume = mStreamTypes[track->streamType()].volume; float v = masterVolume * typeVolume; sp<AudioTrackServerProxy> proxy = track->mAudioTrackServerProxy; gain_minifloat_packed_t vlr = proxy->getVolumeLR(); vlf = float_from_gain(gain_minifloat_unpack_left(vlr)); Loading Loading @@ -4367,6 +4369,25 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac track->mHasVolumeController = false; } // For dedicated VoIP outputs, let the HAL apply the stream volume. Track volume is // still applied by the mixer. if ((mOutput->flags & AUDIO_OUTPUT_FLAG_VOIP_RX) != 0) { v = mStreamTypes[track->streamType()].mute ? 0.0f : v; if (v != mLeftVolFloat) { status_t result = mOutput->stream->setVolume(v, v); ALOGE_IF(result != OK, "Error when setting output stream volume: %d", result); if (result == OK) { mLeftVolFloat = v; } } // if stream volume was successfully sent to the HAL, mLeftVolFloat == v here and we // remove stream volume contribution from software volume. if (v != 0.0f && mLeftVolFloat == v) { vlf = min(1.0f, vlf / v); vrf = min(1.0f, vrf / v); vaf = min(1.0f, vaf / v); } } // XXX: these things DON'T need to be done each time mAudioMixer->setBufferProvider(name, track); mAudioMixer->enable(name); Loading Loading @@ -4808,7 +4829,6 @@ void AudioFlinger::MixerThread::cacheParameters_l() AudioFlinger::DirectOutputThread::DirectOutputThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, audio_io_handle_t id, audio_devices_t device, bool systemReady) : PlaybackThread(audioFlinger, output, id, device, DIRECT, systemReady) // mLeftVolFloat, mRightVolFloat { } Loading @@ -4816,7 +4836,6 @@ AudioFlinger::DirectOutputThread::DirectOutputThread(const sp<AudioFlinger>& aud AudioStreamOut* output, audio_io_handle_t id, uint32_t device, ThreadBase::type_t type, bool systemReady) : PlaybackThread(audioFlinger, output, id, device, type, systemReady) // mLeftVolFloat, mRightVolFloat , mVolumeShaperActive(false) { } Loading services/audioflinger/Threads.h +3 −3 Original line number Diff line number Diff line Loading @@ -999,6 +999,9 @@ protected: bool mHwSupportsPause; bool mHwPaused; bool mFlushPending; // volumes last sent to audio HAL with stream->setVolume() float mLeftVolFloat; float mRightVolFloat; }; class MixerThread : public PlaybackThread { Loading Loading @@ -1116,9 +1119,6 @@ protected: virtual void onAddNewTrack_l(); // volumes last sent to audio HAL with stream->set_volume() float mLeftVolFloat; float mRightVolFloat; bool mVolumeShaperActive; DirectOutputThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, Loading Loading
services/audioflinger/Threads.cpp +26 −7 Original line number Diff line number Diff line Loading @@ -1668,7 +1668,8 @@ AudioFlinger::PlaybackThread::PlaybackThread(const sp<AudioFlinger>& audioFlinge mScreenState(AudioFlinger::mScreenState), // index 0 is reserved for normal mixer's submix mFastTrackAvailMask(((1 << FastMixerState::sMaxFastTracks) - 1) & ~1), mHwSupportsPause(false), mHwPaused(false), mFlushPending(false) mHwSupportsPause(false), mHwPaused(false), mFlushPending(false), mLeftVolFloat(-1.0), mRightVolFloat(-1.0) { snprintf(mThreadName, kThreadNameLength, "AudioOut_%X", id); mNBLogWriter = audioFlinger->newWriter_l(kLogSize, mThreadName); Loading Loading @@ -4295,6 +4296,7 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac param = AudioMixer::RAMP_VOLUME; } mAudioMixer->setParameter(name, AudioMixer::RESAMPLE, AudioMixer::RESET, NULL); mLeftVolFloat = -1.0; // FIXME should not make a decision based on mServer } else if (cblk->mServer != 0) { // If the track is stopped before the first frame was mixed, Loading @@ -4305,6 +4307,10 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac // compute volume for this track uint32_t vl, vr; // in U8.24 integer format float vlf, vrf, vaf; // in [0.0, 1.0] float format // read original volumes with volume control float typeVolume = mStreamTypes[track->streamType()].volume; float v = masterVolume * typeVolume; if (track->isPausing() || mStreamTypes[track->streamType()].mute) { vl = vr = 0; vlf = vrf = vaf = 0.; Loading @@ -4312,10 +4318,6 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac track->setPaused(); } } else { // read original volumes with volume control float typeVolume = mStreamTypes[track->streamType()].volume; float v = masterVolume * typeVolume; sp<AudioTrackServerProxy> proxy = track->mAudioTrackServerProxy; gain_minifloat_packed_t vlr = proxy->getVolumeLR(); vlf = float_from_gain(gain_minifloat_unpack_left(vlr)); Loading Loading @@ -4367,6 +4369,25 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac track->mHasVolumeController = false; } // For dedicated VoIP outputs, let the HAL apply the stream volume. Track volume is // still applied by the mixer. if ((mOutput->flags & AUDIO_OUTPUT_FLAG_VOIP_RX) != 0) { v = mStreamTypes[track->streamType()].mute ? 0.0f : v; if (v != mLeftVolFloat) { status_t result = mOutput->stream->setVolume(v, v); ALOGE_IF(result != OK, "Error when setting output stream volume: %d", result); if (result == OK) { mLeftVolFloat = v; } } // if stream volume was successfully sent to the HAL, mLeftVolFloat == v here and we // remove stream volume contribution from software volume. if (v != 0.0f && mLeftVolFloat == v) { vlf = min(1.0f, vlf / v); vrf = min(1.0f, vrf / v); vaf = min(1.0f, vaf / v); } } // XXX: these things DON'T need to be done each time mAudioMixer->setBufferProvider(name, track); mAudioMixer->enable(name); Loading Loading @@ -4808,7 +4829,6 @@ void AudioFlinger::MixerThread::cacheParameters_l() AudioFlinger::DirectOutputThread::DirectOutputThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, audio_io_handle_t id, audio_devices_t device, bool systemReady) : PlaybackThread(audioFlinger, output, id, device, DIRECT, systemReady) // mLeftVolFloat, mRightVolFloat { } Loading @@ -4816,7 +4836,6 @@ AudioFlinger::DirectOutputThread::DirectOutputThread(const sp<AudioFlinger>& aud AudioStreamOut* output, audio_io_handle_t id, uint32_t device, ThreadBase::type_t type, bool systemReady) : PlaybackThread(audioFlinger, output, id, device, type, systemReady) // mLeftVolFloat, mRightVolFloat , mVolumeShaperActive(false) { } Loading
services/audioflinger/Threads.h +3 −3 Original line number Diff line number Diff line Loading @@ -999,6 +999,9 @@ protected: bool mHwSupportsPause; bool mHwPaused; bool mFlushPending; // volumes last sent to audio HAL with stream->setVolume() float mLeftVolFloat; float mRightVolFloat; }; class MixerThread : public PlaybackThread { Loading Loading @@ -1116,9 +1119,6 @@ protected: virtual void onAddNewTrack_l(); // volumes last sent to audio HAL with stream->set_volume() float mLeftVolFloat; float mRightVolFloat; bool mVolumeShaperActive; DirectOutputThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, Loading