• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include "AudioCollections.h"
20 #include <utils/String8.h>
21 #include <utils/Vector.h>
22 #include <utils/RefBase.h>
23 #include <utils/Errors.h>
24 
25 namespace android
26 {
27 
28 class PolicyAudioPort;
29 class DeviceDescriptor;
30 
31 typedef enum {
32     AUDIO_ROUTE_MUX = 0,
33     AUDIO_ROUTE_MIX = 1
34 } audio_route_type_t;
35 
36 class AudioRoute  : public virtual RefBase
37 {
38 public:
AudioRoute(audio_route_type_t type)39     explicit AudioRoute(audio_route_type_t type) : mType(type) {}
40 
setSources(const PolicyAudioPortVector & sources)41     void setSources(const PolicyAudioPortVector &sources) { mSources = sources; }
getSources()42     const PolicyAudioPortVector &getSources() const { return mSources; }
43 
setSink(const sp<PolicyAudioPort> & sink)44     void setSink(const sp<PolicyAudioPort> &sink) { mSink = sink; }
getSink()45     const sp<PolicyAudioPort> &getSink() const { return mSink; }
46 
getType()47     audio_route_type_t getType() const { return mType; }
48 
49     /**
50      * @brief supportsPatch checks if an audio patch is supported by a Route declared in
51      * the audio_policy_configuration.xml file.
52      * If the patch is supported natively by an AudioHAL (which supports of course Routing API 3.0),
53      * audiopolicy will not request AudioFlinger to use a software bridge to realize a patch
54      * between 2 ports.
55      * @param srcPort (aka the source) to be considered
56      * @param dstPort (aka the sink) to be considered
57      * @return true if the audio route supports the connection between the sink and the source,
58      * false otherwise
59      */
60     bool supportsPatch(const sp<PolicyAudioPort> &srcPort,
61                        const sp<PolicyAudioPort> &dstPort) const;
62 
63     void dump(String8 *dst, int spaces) const;
64 
65 private:
66     PolicyAudioPortVector mSources;
67     sp<PolicyAudioPort> mSink;
68     audio_route_type_t mType;
69 
70 };
71 
72 } // namespace android
73