Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 82001647 authored by Ashish Jain's avatar Ashish Jain Committed by Linux Build Service Account
Browse files

AudioMixer: Clear bufferProviders in correct order

Issue:
 While switching between clips with different track properties, when
earlier track is cleared, postDownMixerBufferProvider
tries to release a buffer to serverProxy instead of the original owner
i.e. downMixBufferProvider. This illegal releaseBuffer call to serverProxy
results in an assert in AudioTrackShared.
-In issue scenario, data flow path in AudioMixer is,
ServerProxy-->-->DownMixer-->PostDownMixer-->Resampler,
- Clear for downMixerBufferProvider ensures that all serverproxy
buffers are returned back.
-This also causes the postDownMixer to get connected with serverProxy.
-Hence on delete of postDownMixer illegal releaseBuffer for
serverProxy gets executed.
Fix:
Clear PostDownMixerBufferProvider before clearing DownMixerBufferProvider
to ensure that buffers are release to right owners.

Change-Id: I982366660d0a1e04be8cca6dabe758221dedf9b1
parent 348d6df5
Loading
Loading
Loading
Loading
+5 −9
Original line number Diff line number Diff line
@@ -306,6 +306,11 @@ bool AudioMixer::setChannelMasks(int name,
void AudioMixer::track_t::unprepareForDownmix() {
    ALOGV("AudioMixer::unprepareForDownmix(%p)", this);

    if (mPostDownmixReformatBufferProvider != NULL) {
        delete mPostDownmixReformatBufferProvider;
        mPostDownmixReformatBufferProvider = NULL;
        reconfigureBufferProviders();
    }
    mDownmixRequiresFormat = AUDIO_FORMAT_INVALID;
    if (downmixerBufferProvider != NULL) {
        // this track had previously been configured with a downmixer, delete it
@@ -361,18 +366,9 @@ status_t AudioMixer::track_t::prepareForDownmix()

void AudioMixer::track_t::unprepareForReformat() {
    ALOGV("AudioMixer::unprepareForReformat(%p)", this);
    bool requiresReconfigure = false;
    if (mReformatBufferProvider != NULL) {
        delete mReformatBufferProvider;
        mReformatBufferProvider = NULL;
        requiresReconfigure = true;
    }
    if (mPostDownmixReformatBufferProvider != NULL) {
        delete mPostDownmixReformatBufferProvider;
        mPostDownmixReformatBufferProvider = NULL;
        requiresReconfigure = true;
    }
    if (requiresReconfigure) {
        reconfigureBufferProviders();
    }
}