• 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 <system/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 AudioMix, public RefBase {
33 public:
34     AudioPolicyMix(const AudioMix &mix);
35     AudioPolicyMix(const AudioPolicyMix&) = delete;
36     AudioPolicyMix& operator=(const AudioPolicyMix&) = delete;
37 
38     const sp<SwAudioOutputDescriptor> &getOutput() const;
39 
40     void setOutput(sp<SwAudioOutputDescriptor> &output);
41 
42     void clearOutput();
43 
44     status_t dump(int fd, int spaces, int index) const;
45 
46 private:
47     sp<SwAudioOutputDescriptor> mOutput;  // Corresponding output stream
48 };
49 
50 
51 class AudioPolicyMixCollection : public DefaultKeyedVector<String8, sp<AudioPolicyMix> >
52 {
53 public:
54     status_t getAudioPolicyMix(const String8& address, sp<AudioPolicyMix> &policyMix) const;
55 
56     status_t registerMix(const String8& address, AudioMix mix, sp<SwAudioOutputDescriptor> desc);
57 
58     status_t unregisterMix(const String8& address);
59 
60     void closeOutput(sp<SwAudioOutputDescriptor> &desc);
61 
62     /**
63      * Try to find an output descriptor for the given attributes.
64      *
65      * @param[in] attributes to consider fowr the research of output descriptor.
66      * @param[out] desc to return if an output could be found.
67      *
68      * @return NO_ERROR if an output was found for the given attribute (in this case, the
69      *                  descriptor output param is initialized), error code otherwise.
70      */
71     status_t getOutputForAttr(audio_attributes_t attributes, uid_t uid,
72             sp<SwAudioOutputDescriptor> &desc);
73 
74     audio_devices_t getDeviceAndMixForInputSource(audio_source_t inputSource,
75                                                   audio_devices_t availableDeviceTypes,
76                                                   sp<AudioPolicyMix> *policyMix);
77 
78     status_t getInputMixForAttr(audio_attributes_t attr, sp<AudioPolicyMix> *policyMix);
79 
80     status_t dump(int fd) const;
81 };
82 
83 } // namespace android
84