• 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 <utils/RefBase.h>
20 #include <media/AudioPolicy.h>
21 #include <utils/KeyedVector.h>
22 #include <hardware/audio.h>
23 #include <utils/String8.h>
24 
25 namespace android {
26 
27 class SwAudioOutputDescriptor;
28 
29 /**
30  * custom mix entry in mPolicyMixes
31  */
32 class AudioPolicyMix : public RefBase {
33 public:
AudioPolicyMix()34     AudioPolicyMix() {}
35 
36     const sp<SwAudioOutputDescriptor> &getOutput() const;
37 
38     void setOutput(sp<SwAudioOutputDescriptor> &output);
39 
40     void clearOutput();
41 
42     android::AudioMix *getMix();
43 
44     void setMix(AudioMix &mix);
45 
46 private:
47     AudioMix    mMix;                   // Audio policy mix descriptor
48     sp<SwAudioOutputDescriptor> mOutput;  // Corresponding output stream
49 };
50 
51 
52 class AudioPolicyMixCollection : public DefaultKeyedVector<String8, sp<AudioPolicyMix> >
53 {
54 public:
55     status_t getAudioPolicyMix(String8 address, sp<AudioPolicyMix> &policyMix) const;
56 
57     status_t registerMix(String8 address, AudioMix mix, sp<SwAudioOutputDescriptor> desc);
58 
59     status_t unregisterMix(String8 address);
60 
61     void closeOutput(sp<SwAudioOutputDescriptor> &desc);
62 
63     /**
64      * Try to find an output descriptor for the given attributes.
65      *
66      * @param[in] attributes to consider fowr the research of output descriptor.
67      * @param[out] desc to return if an output could be found.
68      *
69      * @return NO_ERROR if an output was found for the given attribute (in this case, the
70      *                  descriptor output param is initialized), error code otherwise.
71      */
72     status_t getOutputForAttr(audio_attributes_t attributes, uid_t uid,
73             sp<SwAudioOutputDescriptor> &desc);
74 
75     audio_devices_t getDeviceAndMixForInputSource(audio_source_t inputSource,
76                                                   audio_devices_t availableDeviceTypes,
77                                                   AudioMix **policyMix);
78 
79     status_t getInputMixForAttr(audio_attributes_t attr, AudioMix **policyMix);
80 };
81 
82 }; // namespace android
83