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

Commit a7335639 authored by Glenn Kasten's avatar Glenn Kasten
Browse files

getPrimary APIs now examine all non-duplicating output threads

and return the value corresponding to the thread with minimum frame count,
with a preference for a thread with fast mixer if there are multiple
output threads with the same minimum frame count.
This is in keeping with the expectation by apps that the getPrimary APIs
will return a value for the lowest available latency path.

Bug: 29164107
Change-Id: I8ae9bcad2d48185d7717ccf96085834c0ce00e37
parent e8a984e4
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -1694,14 +1694,14 @@ audio_module_handle_t AudioFlinger::loadHwModule_l(const char *name)
uint32_t AudioFlinger::getPrimaryOutputSamplingRate()
{
    Mutex::Autolock _l(mLock);
    PlaybackThread *thread = primaryPlaybackThread_l();
    PlaybackThread *thread = fastPlaybackThread_l();
    return thread != NULL ? thread->sampleRate() : 0;
}

size_t AudioFlinger::getPrimaryOutputFrameCount()
{
    Mutex::Autolock _l(mLock);
    PlaybackThread *thread = primaryPlaybackThread_l();
    PlaybackThread *thread = fastPlaybackThread_l();
    return thread != NULL ? thread->frameCountHAL() : 0;
}

@@ -2528,6 +2528,25 @@ audio_devices_t AudioFlinger::primaryOutputDevice_l() const
    return thread->outDevice();
}

AudioFlinger::PlaybackThread *AudioFlinger::fastPlaybackThread_l() const
{
    size_t minFrameCount = 0;
    PlaybackThread *minThread = NULL;
    for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
        PlaybackThread *thread = mPlaybackThreads.valueAt(i).get();
        if (!thread->isDuplicating()) {
            size_t frameCount = thread->frameCountHAL();
            if (frameCount != 0 && (minFrameCount == 0 || frameCount < minFrameCount ||
                    (frameCount == minFrameCount && thread->hasFastMixer() &&
                    /*minThread != NULL &&*/ !minThread->hasFastMixer()))) {
                minFrameCount = frameCount;
                minThread = thread;
            }
        }
    }
    return minThread;
}

sp<AudioFlinger::SyncEvent> AudioFlinger::createSyncEvent(AudioSystem::sync_event_t type,
                                    audio_session_t triggerSession,
                                    audio_session_t listenerSession,
+3 −0
Original line number Diff line number Diff line
@@ -575,6 +575,9 @@ private:
              PlaybackThread *primaryPlaybackThread_l() const;
              audio_devices_t primaryOutputDevice_l() const;

              // return the playback thread with smallest HAL buffer size, and prefer fast
              PlaybackThread *fastPlaybackThread_l() const;

              sp<PlaybackThread> getEffectThread_l(audio_session_t sessionId, int EffectId);