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

Commit c005e569 authored by François Gaffie's avatar François Gaffie Committed by Eric Laurent
Browse files

audiopolicy: apm: switch to new Engine APIs



Test: make
Change-Id: Iedc2268852ee0bce32b67cfd324395c48cb33424
Signed-off-by: default avatarFrançois Gaffie <francois.gaffie@renault.com>
parent d0ba9ed0
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -414,7 +414,7 @@ public:
        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
        data.writeInt32(static_cast <uint32_t>(stream));
        remote()->transact(GET_STRATEGY_FOR_STREAM, data, &reply);
        return reply.readInt32();
        return reply.readUint32();
    }

    virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream)
@@ -1126,7 +1126,6 @@ status_t BnAudioPolicyService::onTransact(
        case START_INPUT:
        case STOP_INPUT:
        case RELEASE_INPUT:
        case GET_STRATEGY_FOR_STREAM:
        case GET_OUTPUT_FOR_EFFECT:
        case REGISTER_EFFECT:
        case UNREGISTER_EFFECT:
@@ -1422,7 +1421,7 @@ status_t BnAudioPolicyService::onTransact(
            CHECK_INTERFACE(IAudioPolicyService, data, reply);
            audio_stream_type_t stream =
                    static_cast <audio_stream_type_t>(data.readInt32());
            reply->writeInt32(getStrategyForStream(stream));
            reply->writeUint32(getStrategyForStream(stream));
            return NO_ERROR;
        } break;

+4 −1
Original line number Diff line number Diff line
@@ -34,6 +34,9 @@ constexpr bool operator==(const audio_attributes_t &lhs, const audio_attributes_
    return lhs.usage == rhs.usage && lhs.content_type == rhs.content_type &&
            lhs.flags == rhs.flags && (std::strcmp(lhs.tags, rhs.tags) == 0);
}

constexpr bool operator!=(const audio_attributes_t &lhs, const audio_attributes_t &rhs)
{
    return !(lhs==rhs);
}
} // namespace android
+6 −6
Original line number Diff line number Diff line
@@ -11,10 +11,10 @@ LOCAL_SRC_FILES:= \
LOCAL_C_INCLUDES := \
    frameworks/av/services/audioflinger \
    $(call include-path-for, audio-utils) \
    frameworks/av/services/audiopolicy/engine/interface \

LOCAL_HEADER_LIBRARIES := \
    libaudiopolicycommon
    libaudiopolicycommon \
    libaudiopolicyengine_interface_headers \

LOCAL_SHARED_LIBRARIES := \
    libcutils \
@@ -78,11 +78,11 @@ LOCAL_SHARED_LIBRARIES += libaudiopolicyenginedefault
endif # ifeq ($(USE_CONFIGURABLE_AUDIO_POLICY), 1)

LOCAL_C_INCLUDES += \
    frameworks/av/services/audiopolicy/engine/interface \
    $(call include-path-for, audio-utils) \

LOCAL_HEADER_LIBRARIES := \
    libaudiopolicycommon
    libaudiopolicycommon \
    libaudiopolicyengine_interface_headers

LOCAL_STATIC_LIBRARIES := \
    libaudiopolicycomponents
@@ -118,11 +118,11 @@ LOCAL_STATIC_LIBRARIES := \
    libaudiopolicycomponents

LOCAL_C_INCLUDES += \
    frameworks/av/services/audiopolicy/engine/interface \
    $(call include-path-for, audio-utils) \

LOCAL_HEADER_LIBRARIES := \
    libaudiopolicycommon
    libaudiopolicycommon \
    libaudiopolicyengine_interface_headers

LOCAL_CFLAGS := -Wall -Werror

+22 −1
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ namespace android {

using StreamTypeVector = std::vector<audio_stream_type_t>;


static const audio_attributes_t defaultAttr = AUDIO_ATTRIBUTES_INITIALIZER;

} // namespace android
@@ -163,3 +162,25 @@ static inline bool audio_formats_match(audio_format_t format1,
    }
    return format1 == format2;
}

/**
 * @brief hasStream checks if a given stream type is found in the list of streams
 * @param streams collection of stream types to consider.
 * @param streamType to consider
 * @return true if voice stream is found in the given streams, false otherwise
 */
static inline bool hasStream(const android::StreamTypeVector &streams,
                             audio_stream_type_t streamType)
{
    return std::find(begin(streams), end(streams), streamType) != end(streams);
}

/**
 * @brief hasVoiceStream checks if a voice stream is found in the list of streams
 * @param streams collection to consider.
 * @return true if voice stream is found in the given streams, false otherwise
 */
static inline bool hasVoiceStream(const android::StreamTypeVector &streams)
{
    return hasStream(streams, AUDIO_STREAM_VOICE_CALL);
}
+34 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

#pragma once

#include "DeviceDescriptor.h"

namespace android {

/**
@@ -34,4 +36,36 @@ public:
    virtual void setPatchHandle(audio_patch_handle_t handle) = 0;
};

template <class IoDescriptor, class Filter>
sp<DeviceDescriptor> findPreferredDevice(
        IoDescriptor& desc, Filter filter, bool& active, const DeviceVector& devices)
{
    auto activeClients = desc->clientsList(true /*activeOnly*/);
    auto activeClientsWithRoute =
        desc->clientsList(true /*activeOnly*/, filter, true /*preferredDevice*/);
    active = activeClients.size() > 0;
    if (active && activeClients.size() == activeClientsWithRoute.size()) {
        return devices.getDeviceFromId(activeClientsWithRoute[0]->preferredDeviceId());
    }
    return nullptr;
}

template <class IoCollection, class Filter>
sp<DeviceDescriptor> findPreferredDevice(
        IoCollection& ioCollection, Filter filter, const DeviceVector& devices)
{
    sp<DeviceDescriptor> device;
    for (size_t i = 0; i < ioCollection.size(); i++) {
        auto desc = ioCollection.valueAt(i);
        bool active;
        sp<DeviceDescriptor> curDevice = findPreferredDevice(desc, filter, active, devices);
        if (active && curDevice == nullptr) {
            return nullptr;
        } else if (curDevice != nullptr) {
            device = curDevice;
        }
    }
    return device;
}

} // namespace android
Loading