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

Commit 22167855 authored by Eric Laurent's avatar Eric Laurent
Browse files

audioflinger: fix setStreamOutput()

AudioFlinger::setStreamOutput() should also work for direct outputs.
Also ignore the destination output specified to match the expected
behavior which is to invalidate all tracks using the specified stream
type so that they can be re created on the correct ouput thread.

Do not send STREAM_CONFIG_CHANGED event wich is ignored by AudioSystem
anyway since the stream to output cache has been removed.

Change-Id: I13d9d47922923b630dd755717875424c16be4637
parent 5f121362
Loading
Loading
Loading
Loading
+2 −12
Original line number Diff line number Diff line
@@ -3359,7 +3359,7 @@ void AudioFlinger::PlaybackThread::cacheParameters_l()
    idleSleepTime = idleSleepTimeUs();
}

void AudioFlinger::MixerThread::invalidateTracks(audio_stream_type_t streamType)
void AudioFlinger::PlaybackThread::invalidateTracks(audio_stream_type_t streamType)
{
    ALOGV ("MixerThread::invalidateTracks() mixer %p, streamType %d, mTracks.size %d",
            this,  streamType, mTracks.size());
@@ -7026,21 +7026,11 @@ status_t AudioFlinger::closeInput(audio_io_handle_t input)
status_t AudioFlinger::setStreamOutput(audio_stream_type_t stream, audio_io_handle_t output)
{
    Mutex::Autolock _l(mLock);
    MixerThread *dstThread = checkMixerThread_l(output);
    if (dstThread == NULL) {
        ALOGW("setStreamOutput() bad output id %d", output);
        return BAD_VALUE;
    }

    ALOGV("setStreamOutput() stream %d to output %d", stream, output);
    audioConfigChanged_l(AudioSystem::STREAM_CONFIG_CHANGED, output, &stream);

    for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
        PlaybackThread *thread = mPlaybackThreads.valueAt(i).get();
        if (thread != dstThread && thread->type() != ThreadBase::DIRECT) {
            MixerThread *srcThread = (MixerThread *)thread;
            srcThread->invalidateTracks(stream);
        }
        thread->invalidateTracks(stream);
    }

    return NO_ERROR;
+2 −1
Original line number Diff line number Diff line
@@ -1016,6 +1016,8 @@ public:

                    virtual status_t setSyncEvent(const sp<SyncEvent>& event);
                    virtual bool     isValidSyncEvent(const sp<SyncEvent>& event);
                            void     invalidateTracks(audio_stream_type_t streamType);


    protected:
        int16_t*                        mMixBuffer;
@@ -1143,7 +1145,6 @@ public:

        // Thread virtuals

                    void        invalidateTracks(audio_stream_type_t streamType);
        virtual     bool        checkForNewParameters_l();
        virtual     status_t    dumpInternals(int fd, const Vector<String16>& args);