summaryrefslogtreecommitdiffstats
path: root/audio/compat.h
blob: 83813e2ffc24235ed08ae14c82224992ccb28e7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
 * Copyright (C) 2011 The Android Open Source Project
 * Copyright (C) 2013 Denis 'GNUtoo' Carikli <GNUtoo@no-log.org>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef __COMPAT_H__
#define __COMPAT_H__

#include <system/audio.h>

#ifndef ALOGE
#define ALOGE LOGE
#endif

#ifndef ALOGI
#define ALOGI LOGI
#endif

#ifndef ALOGD
#define ALOGD LOGD
#endif

#ifndef ALOGV
#define ALOGV LOGV
#endif

#ifndef audio_channel_mask_t
typedef uint32_t audio_channel_mask_t;
#endif

#ifndef audio_channel_mask_from_count
/* Derive a channel mask from a channel count.
 * This is to be used when the content channel mask is unknown. The 1, 2, 4, 5, 6, 7 and 8 channel
 * cases are mapped to the standard game/home-theater layouts, but note that 4 is mapped to quad,
 * and not stereo + FC + mono surround. A channel count of 3 is arbitrarily mapped to stereo + FC
 * for continuity with stereo.
 * Returns the matching channel mask, or 0 if the number of channels exceeds that of the
 * configurations for which a default channel mask is defined.
 */
static inline audio_channel_mask_t audio_channel_mask_from_count(uint32_t channel_count)
{
    switch(channel_count) {
    case 1:
        return AUDIO_CHANNEL_OUT_MONO;
    case 2:
        return AUDIO_CHANNEL_OUT_STEREO;
    case 3:
        return (AUDIO_CHANNEL_OUT_STEREO | AUDIO_CHANNEL_OUT_FRONT_CENTER);
    case 4: // 4.0
        return AUDIO_CHANNEL_OUT_QUAD;
    case 5: // 5.0
        return (AUDIO_CHANNEL_OUT_QUAD | AUDIO_CHANNEL_OUT_FRONT_CENTER);
    case 6: // 5.1
        return AUDIO_CHANNEL_OUT_5POINT1;
    case 7: // 6.1
        return (AUDIO_CHANNEL_OUT_5POINT1 | AUDIO_CHANNEL_OUT_BACK_CENTER);
    case 8:
        return AUDIO_CHANNEL_OUT_7POINT1;
    default:
        return 0;
    }
}
#endif

#ifndef channel_config_s
// EFFECT_FEATURE_AUX_CHANNELS feature configuration descriptor. Describe a combinatio
// of main and auxiliary channels supported
typedef struct channel_config_s {
    uint32_t   main_channels;   // channel mask for main channels
    uint32_t   aux_channels;    // channel mask for auxiliary channels
} channel_config_t;
#endif

#endif