• 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 "Element.h"
20 
21 namespace android
22 {
23 namespace audio_policy
24 {
25 
26 /**
27  * Specialization of policy base class element for audio_source_t
28  * @tparam audio_source_t Policy Base Element identified by the audio_source_t definition.
29  */
30 template <>
31 class Element<audio_source_t>
32 {
33 public:
Element(const std::string & name)34     Element(const std::string &name)
35         : mName(name),
36           mApplicableDevices(AUDIO_DEVICE_NONE)
37     {}
~Element()38     ~Element() {}
39 
40     /**
41      * Returns identifier of this policy element
42      *
43      * @returns string representing the name of this policy element
44      */
getName()45     const std::string &getName() const { return mName; }
46 
47     /**
48     * Set the unique identifier for this policy element.
49     *
50     * @tparam Key type of the unique identifier.
51     * @param[in] identifier to be set.
52     *
53     * @return NO_ERROR if the identifier is valid and set correctly, error code otherwise.
54     */
55     status_t setIdentifier(audio_source_t identifier);
56 
57     /**
58      * @return the unique identifier of this policy element.
59      */
getIdentifier()60     audio_source_t getIdentifier() const { return mIdentifier; }
61 
62     /**
63      * A Policy element may implement getter/setter function for a given property.
64      * Property may be routing_strategy, audio_stream_type_t, audio_usage_t, audio_source_t
65      * or a string.
66      */
67     template <typename Property>
68     Property get() const;
69 
70     template <typename Property>
71     status_t set(Property property);
72 
73 private:
74     /* Copy facilities are put private to disable copy. */
75     Element(const Element &object);
76     Element &operator=(const Element &object);
77 
78     std::string mName; /**< Unique literal Identifier of a policy base element*/
79     audio_source_t mIdentifier; /**< Unique numerical Identifier of a policy base element*/
80 
81     audio_devices_t mApplicableDevices; /**< Applicable input device for this input source. */
82 };
83 
84 typedef Element<audio_source_t> InputSource;
85 
86 } // namespace audio_policy
87 } // namespace android
88 
89