blob: e6a767f8dcdde4b9244afb520203a729abf4f13b [file] [log] [blame]
François Gaffie53615e22015-03-19 09:24:12 +01001/*
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 <system/audio.h>
20
21// For mixed output and inputs, the policy will use max mixer sampling rates.
22// Do not limit sampling rate otherwise
23#define MAX_MIXER_SAMPLING_RATE 48000
24
25// For mixed output and inputs, the policy will use max mixer channel count.
26// Do not limit channel count otherwise
27#define MAX_MIXER_CHANNEL_COUNT 8
28
29/**
30 * A device mask for all audio input devices that are considered "virtual" when evaluating
31 * active inputs in getActiveInput()
32 */
33#define APM_AUDIO_IN_DEVICE_VIRTUAL_ALL (AUDIO_DEVICE_IN_REMOTE_SUBMIX|AUDIO_DEVICE_IN_FM_TUNER)
34
35
36/**
37 * A device mask for all audio input and output devices where matching inputs/outputs on device
38 * type alone is not enough: the address must match too
39 */
40#define APM_AUDIO_DEVICE_MATCH_ADDRESS_ALL (AUDIO_DEVICE_IN_REMOTE_SUBMIX | \
41 AUDIO_DEVICE_OUT_REMOTE_SUBMIX)
42
43/**
44 * Check if the state given correspond to an in call state.
45 * @TODO find a better name for widely call state
46 *
47 * @param[in] state to consider
48 *
49 * @return true if given state represents a device in a telephony or VoIP call
50 */
51static inline bool is_state_in_call(int state)
52{
53 return (state == AUDIO_MODE_IN_CALL) || (state == AUDIO_MODE_IN_COMMUNICATION);
54}
55
56/**
57 * Check if the input device given is considered as a virtual device.
58 *
59 * @param[in] device to consider
60 *
61 * @return true if the device is a virtual one, false otherwise.
62 */
Chih-Hung Hsieh5603d282015-05-04 17:14:15 -070063static inline bool is_virtual_input_device(audio_devices_t device)
François Gaffie53615e22015-03-19 09:24:12 +010064{
65 if ((device & AUDIO_DEVICE_BIT_IN) != 0) {
66 device &= ~AUDIO_DEVICE_BIT_IN;
67 if ((popcount(device) == 1) && ((device & ~APM_AUDIO_IN_DEVICE_VIRTUAL_ALL) == 0))
68 return true;
69 }
70 return false;
71}
72
73/**
74 * Check whether the device type is one
75 * where addresses are used to distinguish between one connected device and another
76 *
77 * @param[in] device to consider
78 *
79 * @return true if the device needs distinguish on address, false otherwise..
80 */
Chih-Hung Hsieh5603d282015-05-04 17:14:15 -070081static inline bool device_distinguishes_on_address(audio_devices_t device)
François Gaffie53615e22015-03-19 09:24:12 +010082{
83 return ((device & APM_AUDIO_DEVICE_MATCH_ADDRESS_ALL & ~AUDIO_DEVICE_BIT_IN) != 0);
84}