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

Commit 90033d19 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "audiopolicy: fix preferred device selection" into pi-dev

parents 354a89b3 2157f5bc
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ public:

    void log(const char* prefix);

    bool isActive() {
    bool isActiveOrChanged() {
        return (mDeviceDescriptor != 0) && (mChanged || (mActivityCount > 0));
    }

@@ -96,7 +96,7 @@ public:

    int incRouteActivity(audio_session_t session);
    int decRouteActivity(audio_session_t session);
    bool hasRouteChanged(audio_session_t session); // also clears the changed flag
    bool getAndClearRouteChanged(audio_session_t session); // also clears the changed flag
    void log(const char* caption);

    // Specify an Output(Sink) route by passing SessionRoute::SOURCE_TYPE_NA in the
+3 −5
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ bool SessionRouteMap::hasRoute(audio_session_t session)
    return indexOfKey(session) >= 0 && valueFor(session)->mDeviceDescriptor != 0;
}

bool SessionRouteMap::hasRouteChanged(audio_session_t session)
bool SessionRouteMap::getAndClearRouteChanged(audio_session_t session)
{
    if (indexOfKey(session) >= 0) {
        if (valueFor(session)->mChanged) {
@@ -104,9 +104,7 @@ void SessionRouteMap::addRoute(audio_session_t session,
    sp<SessionRoute> route = indexOfKey(session) >= 0 ? valueFor(session) : 0;

    if (route != 0) {
        if (((route->mDeviceDescriptor == 0) && (descriptor != 0)) ||
                ((route->mDeviceDescriptor != 0) &&
                 ((descriptor == 0) || (!route->mDeviceDescriptor->equals(descriptor))))) {
        if (descriptor != 0 || route->mDeviceDescriptor != 0) {
            route->mChanged = true;
        }
        route->mRefCount++;
@@ -114,10 +112,10 @@ void SessionRouteMap::addRoute(audio_session_t session,
    } else {
        route = new SessionRoute(session, streamType, source, descriptor, uid);
        route->mRefCount++;
        add(session, route);
        if (descriptor != 0) {
            route->mChanged = true;
        }
        add(session, route);
    }
}

+4 −4
Original line number Diff line number Diff line
@@ -1116,7 +1116,7 @@ status_t AudioPolicyManager::startOutput(audio_io_handle_t output,
        } else {
            newDevice = AUDIO_DEVICE_OUT_REMOTE_SUBMIX;
        }
    } else if (mOutputRoutes.hasRouteChanged(session)) {
    } else if (mOutputRoutes.getAndClearRouteChanged(session)) {
        newDevice = getNewOutputDevice(outputDesc, false /*fromCache*/);
        checkStrategyRoute(getStrategy(stream), output);
    } else {
@@ -1980,7 +1980,7 @@ status_t AudioPolicyManager::startInput(audio_io_handle_t input,
    // Routing?
    mInputRoutes.incRouteActivity(session);

    if (audioSession->activeCount() == 1 || mInputRoutes.hasRouteChanged(session)) {
    if (audioSession->activeCount() == 1 || mInputRoutes.getAndClearRouteChanged(session)) {
        // indicate active capture to sound trigger service if starting capture from a mic on
        // primary HW module
        audio_devices_t device = getNewInputDevice(inputDesc);
@@ -4707,7 +4707,7 @@ audio_devices_t AudioPolicyManager::getDeviceForStrategy(routing_strategy strate
    for (size_t routeIndex = 0; routeIndex < mOutputRoutes.size(); routeIndex++) {
        sp<SessionRoute> route = mOutputRoutes.valueAt(routeIndex);
        routing_strategy routeStrategy = getStrategy(route->mStreamType);
        if ((routeStrategy == strategy) && route->isActive() &&
        if ((routeStrategy == strategy) && route->isActiveOrChanged() &&
                (mAvailableOutputDevices.indexOf(route->mDeviceDescriptor) >= 0)) {
            return route->mDeviceDescriptor->type();
        }
@@ -5139,7 +5139,7 @@ audio_devices_t AudioPolicyManager::getDeviceForInputSource(audio_source_t input
    // then select this device.
    for (size_t routeIndex = 0; routeIndex < mInputRoutes.size(); routeIndex++) {
         sp<SessionRoute> route = mInputRoutes.valueAt(routeIndex);
         if ((inputSource == route->mSource) && route->isActive() &&
         if ((inputSource == route->mSource) && route->isActiveOrChanged() &&
                 (mAvailableInputDevices.indexOf(route->mDeviceDescriptor) >= 0)) {
             return route->mDeviceDescriptor->type();
         }