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

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

audio policy: introduce audio route concept



As a preambule of introduction of topology concept within
audio policy configuration file, this patch introduces the notion
of audio route, i.e. a link between one sink and one or more sources.
This link may be shareable (mix) or mutual exclusive (mux).

From this route concept, and in order to keep backward compatibility,
the supported device of ioprofile (what will become AudioMixPort) must
be updated.

Change-Id: If078830dbe74b003be4a64c584521df481101294
Signed-off-by: default avatarFrançois Gaffie <francois.gaffie@intel.com>
parent 53e142a0
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -10,10 +10,12 @@ LOCAL_SRC_FILES:= \
    src/IOProfile.cpp \
    src/AudioPort.cpp \
    src/AudioProfile.cpp \
    src/AudioRoute.cpp \
    src/AudioPolicyMix.cpp \
    src/AudioPatch.cpp \
    src/AudioInputDescriptor.cpp \
    src/AudioOutputDescriptor.cpp \
    src/AudioCollections.cpp \
    src/EffectDescriptor.cpp \
    src/ConfigParsingUtils.cpp \
    src/SoundTriggerSession.cpp \
+44 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <utils/String8.h>
#include <utils/Vector.h>
#include <utils/RefBase.h>
#include <utils/Errors.h>
#include <system/audio.h>
#include <cutils/config_utils.h>

namespace android {

class AudioPort;
class AudioRoute;

class AudioPortVector : public Vector<sp<AudioPort> >
{
public:
    sp<AudioPort> findByTagName(const String8 &tagName) const;
};


class AudioRouteVector : public Vector<sp<AudioRoute> >
{
public:
    status_t dump(int fd) const;
};

}; // namespace android
+9 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

#pragma once

#include "AudioCollections.h"
#include "AudioProfile.h"
#include <utils/String8.h>
#include <utils/Vector.h>
@@ -28,6 +29,7 @@ namespace android {

class HwModule;
class AudioGain;
class AudioRoute;
typedef Vector<sp<AudioGain> > AudioGainCollection;

class AudioPort : public virtual RefBase
@@ -44,6 +46,8 @@ public:
    audio_port_type_t getType() const { return mType; }
    audio_port_role_t getRole() const { return mRole; }

    virtual const String8 getTagName() const = 0;

    void setGains(const AudioGainCollection &gains) { mGains = gains; }
    const AudioGainCollection &getGains() const { return mGains; }

@@ -114,6 +118,9 @@ public:
                (mFlags & (AUDIO_OUTPUT_FLAG_DIRECT | AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD));
    }

    void addRoute(const sp<AudioRoute> &route) { mRoutes.add(route); }
    const AudioRouteVector &getRoutes() const { return mRoutes; }

    void dump(int fd, int spaces, bool verbose = true) const;
    void log(const char* indent) const;

@@ -129,6 +136,7 @@ private:
    audio_port_role_t mRole;
    uint32_t mFlags; // attribute flags mask (e.g primary output, direct output...).
    AudioProfileVector mProfiles; // AudioProfiles supported by this port (format, Rates, Channels)
    AudioRouteVector mRoutes; // Routes involving this port
    static volatile int32_t mNextUniqueId;
};

+58 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include "AudioCollections.h"
#include <utils/String8.h>
#include <utils/Vector.h>
#include <utils/RefBase.h>
#include <utils/Errors.h>

namespace android
{

class AudioPort;
class DeviceDescriptor;

typedef enum {
    AUDIO_ROUTE_MUX = 0,
    AUDIO_ROUTE_MIX = 1
} audio_route_type_t;

class AudioRoute  : public virtual RefBase
{
public:
    AudioRoute(audio_route_type_t type) : mType(type) {}

    void setSources(const AudioPortVector &sources) { mSources = sources; }
    const AudioPortVector &getSources() const { return mSources; }

    void setSink(const sp<AudioPort> &sink) { mSink = sink; }
    const sp<AudioPort> &getSink() const { return mSink; }

    audio_route_type_t getType() const { return mType; }

    void dump(int fd, int spaces) const;

private:
    AudioPortVector mSources;
    sp<AudioPort> mSink;
    audio_route_type_t mType;

};

}; // namespace android
+3 −2
Original line number Diff line number Diff line
@@ -34,8 +34,9 @@ public:

    virtual ~DeviceDescriptor() {}

    virtual const String8 getTagName() const { return mTagName; }

    audio_devices_t type() const { return mDeviceType; }
    const String8 getTagName() const { return mTagName; }

    bool equals(const sp<DeviceDescriptor>& other) const;

@@ -56,7 +57,7 @@ public:
    String8 mAddress;

private:
    String8 mTagName;
    String8 mTagName; // Unique human readable identifier for a device port found in conf file.
    audio_devices_t     mDeviceType;
    audio_port_handle_t mId;

Loading