Fix multichannel downmix pause bug on video player
Pausing a video player will cause the track audio mixer to be
disabled, which causes the downmixer to be deleted. When reenabled,
the track channel mask hasn't changed but the downmixer is there
anymore.
Fixed by:
- instanciating a downmixer when the AudioMixer track
gets initialized (in getTrackName(), now taking a channel mask
as input), and deleted when in deleteTrackName().
- when the channel changes on a track, check whether it
needs a downmixer or not. Preparing a track for downmix
automatically removes the old downmixer if there was one.
Also: initialize the track downmixerBufferProvider field
when AudioMixer is instanciated, so we can safely call
delete on it in AudioMixer's destructor, in case
deleteTrackName() wasn't called before the mixer was
destroyed.
Change-Id: I589b0781cda5b3c82f85b561c52b08546cac21f8
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index c674c24..99dcf45 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -2664,13 +2664,7 @@
// getTrackName_l() must be called with ThreadBase::mLock held
int AudioFlinger::MixerThread::getTrackName_l(audio_channel_mask_t channelMask)
{
- int name = mAudioMixer->getTrackName();
- if (name >= 0) {
- mAudioMixer->setParameter(name,
- AudioMixer::TRACK,
- AudioMixer::CHANNEL_MASK, (void *)channelMask);
- }
- return name;
+ return mAudioMixer->getTrackName(channelMask);
}
// deleteTrackName_l() must be called with ThreadBase::mLock held