1036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie/*
2036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie * Copyright (C) 2015 The Android Open Source Project
3036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie *
4036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie * Licensed under the Apache License, Version 2.0 (the "License");
5036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie * you may not use this file except in compliance with the License.
6036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie * You may obtain a copy of the License at
7036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie *
8036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie *      http://www.apache.org/licenses/LICENSE-2.0
9036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie *
10036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie * Unless required by applicable law or agreed to in writing, software
11036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie * distributed under the License is distributed on an "AS IS" BASIS,
12036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie * See the License for the specific language governing permissions and
14036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie * limitations under the License.
15036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie */
16036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie
17036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie#pragma once
18036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie
19036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie#include <utils/RefBase.h>
20036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie#include <media/AudioPolicy.h>
21036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie#include <utils/KeyedVector.h>
22036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie#include <hardware/audio.h>
23036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie#include <utils/String8.h>
24036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie
25036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffienamespace android {
26036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie
27c75307b73d324d590d0dbc05b44bce9aa89b7145Eric Laurentclass SwAudioOutputDescriptor;
28036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie
29036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie/**
30036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie * custom mix entry in mPolicyMixes
31036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie */
32036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffieclass AudioPolicyMix : public RefBase {
33036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffiepublic:
34036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie    AudioPolicyMix() {}
35036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie
36c75307b73d324d590d0dbc05b44bce9aa89b7145Eric Laurent    const sp<SwAudioOutputDescriptor> &getOutput() const;
37036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie
38c75307b73d324d590d0dbc05b44bce9aa89b7145Eric Laurent    void setOutput(sp<SwAudioOutputDescriptor> &output);
39036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie
40036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie    void clearOutput();
41036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie
42dacc06f5e8d00ace9d16a149fc41ff65323ffbb3Jean-Michel Trivi    android::AudioMix *getMix();
43036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie
44036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie    void setMix(AudioMix &mix);
45036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie
46036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffieprivate:
47036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie    AudioMix    mMix;                   // Audio policy mix descriptor
48c75307b73d324d590d0dbc05b44bce9aa89b7145Eric Laurent    sp<SwAudioOutputDescriptor> mOutput;  // Corresponding output stream
49036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie};
50036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie
51036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie
52036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffieclass AudioPolicyMixCollection : public DefaultKeyedVector<String8, sp<AudioPolicyMix> >
53036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie{
54036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffiepublic:
55036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie    status_t getAudioPolicyMix(String8 address, sp<AudioPolicyMix> &policyMix) const;
56036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie
577638ca29e8400a19524adb982e9d22c02786de82Jean-Michel Trivi    status_t registerMix(String8 address, AudioMix mix, sp<SwAudioOutputDescriptor> desc);
58036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie
59036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie    status_t unregisterMix(String8 address);
60036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie
61c75307b73d324d590d0dbc05b44bce9aa89b7145Eric Laurent    void closeOutput(sp<SwAudioOutputDescriptor> &desc);
62036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie
63036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie    /**
64036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie     * Try to find an output descriptor for the given attributes.
65036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie     *
66c75307b73d324d590d0dbc05b44bce9aa89b7145Eric Laurent     * @param[in] attributes to consider fowr the research of output descriptor.
67036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie     * @param[out] desc to return if an output could be found.
68036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie     *
69036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie     * @return NO_ERROR if an output was found for the given attribute (in this case, the
70036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie     *                  descriptor output param is initialized), error code otherwise.
71036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie     */
72e8decedb429ed76dfa84cdb3e80ab3b969e77298Jean-Michel Trivi    status_t getOutputForAttr(audio_attributes_t attributes, uid_t uid,
73e8decedb429ed76dfa84cdb3e80ab3b969e77298Jean-Michel Trivi            sp<SwAudioOutputDescriptor> &desc);
74036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie
75036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie    audio_devices_t getDeviceAndMixForInputSource(audio_source_t inputSource,
76036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie                                                  audio_devices_t availableDeviceTypes,
77036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie                                                  AudioMix **policyMix);
78036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie
79dacc06f5e8d00ace9d16a149fc41ff65323ffbb3Jean-Michel Trivi    status_t getInputMixForAttr(audio_attributes_t attr, AudioMix **policyMix);
80036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie};
81036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie
82036e1e9126dcd496203434aa69e52115d8e730ccFrançois Gaffie}; // namespace android
83