Home | History | Annotate | Download | only in system
      1 /*
      2  * Copyright (C) 2011 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 
     18 #ifndef ANDROID_AUDIO_CORE_H
     19 #define ANDROID_AUDIO_CORE_H
     20 
     21 #include <stdbool.h>
     22 #include <stdint.h>
     23 #include <sys/cdefs.h>
     24 #include <sys/types.h>
     25 
     26 #include <cutils/bitops.h>
     27 
     28 __BEGIN_DECLS
     29 
     30 /* The enums were moved here mostly from
     31  * frameworks/base/include/media/AudioSystem.h
     32  */
     33 
     34 typedef int audio_io_handle_t;
     35 
     36 /* Audio stream types */
     37 typedef enum {
     38     AUDIO_STREAM_DEFAULT          = -1,
     39     AUDIO_STREAM_VOICE_CALL       = 0,
     40     AUDIO_STREAM_SYSTEM           = 1,
     41     AUDIO_STREAM_RING             = 2,
     42     AUDIO_STREAM_MUSIC            = 3,
     43     AUDIO_STREAM_ALARM            = 4,
     44     AUDIO_STREAM_NOTIFICATION     = 5,
     45     AUDIO_STREAM_BLUETOOTH_SCO    = 6,
     46     AUDIO_STREAM_ENFORCED_AUDIBLE = 7, /* Sounds that cannot be muted by user and must be routed to speaker */
     47     AUDIO_STREAM_DTMF             = 8,
     48     AUDIO_STREAM_TTS              = 9,
     49 
     50     AUDIO_STREAM_CNT,
     51     AUDIO_STREAM_MAX              = AUDIO_STREAM_CNT - 1,
     52 } audio_stream_type_t;
     53 
     54 /* Do not change these values without updating their counterparts
     55  * in media/java/android/media/MediaRecorder.java!
     56  */
     57 typedef enum {
     58     AUDIO_SOURCE_DEFAULT             = 0,
     59     AUDIO_SOURCE_MIC                 = 1,
     60     AUDIO_SOURCE_VOICE_UPLINK        = 2,
     61     AUDIO_SOURCE_VOICE_DOWNLINK      = 3,
     62     AUDIO_SOURCE_VOICE_CALL          = 4,
     63     AUDIO_SOURCE_CAMCORDER           = 5,
     64     AUDIO_SOURCE_VOICE_RECOGNITION   = 6,
     65     AUDIO_SOURCE_VOICE_COMMUNICATION = 7,
     66 
     67     AUDIO_SOURCE_CNT,
     68     AUDIO_SOURCE_MAX                 = AUDIO_SOURCE_CNT - 1,
     69 } audio_source_t;
     70 
     71 /* special audio session values
     72  * (XXX: should this be living in the audio effects land?)
     73  */
     74 typedef enum {
     75     /* session for effects attached to a particular output stream
     76      * (value must be less than 0)
     77      */
     78     AUDIO_SESSION_OUTPUT_STAGE = -1,
     79 
     80     /* session for effects applied to output mix. These effects can
     81      * be moved by audio policy manager to another output stream
     82      * (value must be 0)
     83      */
     84     AUDIO_SESSION_OUTPUT_MIX = 0,
     85 } audio_session_t;
     86 
     87 /* Audio sub formats (see enum audio_format). */
     88 
     89 /* PCM sub formats */
     90 typedef enum {
     91     AUDIO_FORMAT_PCM_SUB_16_BIT          = 0x1, /* DO NOT CHANGE - PCM signed 16 bits */
     92     AUDIO_FORMAT_PCM_SUB_8_BIT           = 0x2, /* DO NOT CHANGE - PCM unsigned 8 bits */
     93     AUDIO_FORMAT_PCM_SUB_32_BIT          = 0x3, /* PCM signed .31 fixed point */
     94     AUDIO_FORMAT_PCM_SUB_8_24_BIT        = 0x4, /* PCM signed 7.24 fixed point */
     95 } audio_format_pcm_sub_fmt_t;
     96 
     97 /* MP3 sub format field definition : can use 11 LSBs in the same way as MP3
     98  * frame header to specify bit rate, stereo mode, version...
     99  */
    100 typedef enum {
    101     AUDIO_FORMAT_MP3_SUB_NONE            = 0x0,
    102 } audio_format_mp3_sub_fmt_t;
    103 
    104 /* AMR NB/WB sub format field definition: specify frame block interleaving,
    105  * bandwidth efficient or octet aligned, encoding mode for recording...
    106  */
    107 typedef enum {
    108     AUDIO_FORMAT_AMR_SUB_NONE            = 0x0,
    109 } audio_format_amr_sub_fmt_t;
    110 
    111 /* AAC sub format field definition: specify profile or bitrate for recording... */
    112 typedef enum {
    113     AUDIO_FORMAT_AAC_SUB_NONE            = 0x0,
    114 } audio_format_aac_sub_fmt_t;
    115 
    116 /* VORBIS sub format field definition: specify quality for recording... */
    117 typedef enum {
    118     AUDIO_FORMAT_VORBIS_SUB_NONE         = 0x0,
    119 } audio_format_vorbis_sub_fmt_t;
    120 
    121 /* Audio format consists in a main format field (upper 8 bits) and a sub format
    122  * field (lower 24 bits).
    123  *
    124  * The main format indicates the main codec type. The sub format field
    125  * indicates options and parameters for each format. The sub format is mainly
    126  * used for record to indicate for instance the requested bitrate or profile.
    127  * It can also be used for certain formats to give informations not present in
    128  * the encoded audio stream (e.g. octet alignement for AMR).
    129  */
    130 typedef enum {
    131     AUDIO_FORMAT_INVALID             = 0xFFFFFFFFUL,
    132     AUDIO_FORMAT_DEFAULT             = 0,
    133     AUDIO_FORMAT_PCM                 = 0x00000000UL, /* DO NOT CHANGE */
    134     AUDIO_FORMAT_MP3                 = 0x01000000UL,
    135     AUDIO_FORMAT_AMR_NB              = 0x02000000UL,
    136     AUDIO_FORMAT_AMR_WB              = 0x03000000UL,
    137     AUDIO_FORMAT_AAC                 = 0x04000000UL,
    138     AUDIO_FORMAT_HE_AAC_V1           = 0x05000000UL,
    139     AUDIO_FORMAT_HE_AAC_V2           = 0x06000000UL,
    140     AUDIO_FORMAT_VORBIS              = 0x07000000UL,
    141     AUDIO_FORMAT_MAIN_MASK           = 0xFF000000UL,
    142     AUDIO_FORMAT_SUB_MASK            = 0x00FFFFFFUL,
    143 
    144     /* Aliases */
    145     AUDIO_FORMAT_PCM_16_BIT          = (AUDIO_FORMAT_PCM |
    146                                         AUDIO_FORMAT_PCM_SUB_16_BIT),
    147     AUDIO_FORMAT_PCM_8_BIT           = (AUDIO_FORMAT_PCM |
    148                                         AUDIO_FORMAT_PCM_SUB_8_BIT),
    149     AUDIO_FORMAT_PCM_32_BIT          = (AUDIO_FORMAT_PCM |
    150                                         AUDIO_FORMAT_PCM_SUB_32_BIT),
    151     AUDIO_FORMAT_PCM_8_24_BIT        = (AUDIO_FORMAT_PCM |
    152                                         AUDIO_FORMAT_PCM_SUB_8_24_BIT),
    153 } audio_format_t;
    154 
    155 typedef enum {
    156     /* output channels */
    157     AUDIO_CHANNEL_OUT_FRONT_LEFT            = 0x1,
    158     AUDIO_CHANNEL_OUT_FRONT_RIGHT           = 0x2,
    159     AUDIO_CHANNEL_OUT_FRONT_CENTER          = 0x4,
    160     AUDIO_CHANNEL_OUT_LOW_FREQUENCY         = 0x8,
    161     AUDIO_CHANNEL_OUT_BACK_LEFT             = 0x10,
    162     AUDIO_CHANNEL_OUT_BACK_RIGHT            = 0x20,
    163     AUDIO_CHANNEL_OUT_FRONT_LEFT_OF_CENTER  = 0x40,
    164     AUDIO_CHANNEL_OUT_FRONT_RIGHT_OF_CENTER = 0x80,
    165     AUDIO_CHANNEL_OUT_BACK_CENTER           = 0x100,
    166     AUDIO_CHANNEL_OUT_SIDE_LEFT             = 0x200,
    167     AUDIO_CHANNEL_OUT_SIDE_RIGHT            = 0x400,
    168     AUDIO_CHANNEL_OUT_TOP_CENTER            = 0x800,
    169     AUDIO_CHANNEL_OUT_TOP_FRONT_LEFT        = 0x1000,
    170     AUDIO_CHANNEL_OUT_TOP_FRONT_CENTER      = 0x2000,
    171     AUDIO_CHANNEL_OUT_TOP_FRONT_RIGHT       = 0x4000,
    172     AUDIO_CHANNEL_OUT_TOP_BACK_LEFT         = 0x8000,
    173     AUDIO_CHANNEL_OUT_TOP_BACK_CENTER       = 0x10000,
    174     AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT        = 0x20000,
    175 
    176     AUDIO_CHANNEL_OUT_MONO     = AUDIO_CHANNEL_OUT_FRONT_LEFT,
    177     AUDIO_CHANNEL_OUT_STEREO   = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
    178                                   AUDIO_CHANNEL_OUT_FRONT_RIGHT),
    179     AUDIO_CHANNEL_OUT_QUAD     = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
    180                                   AUDIO_CHANNEL_OUT_FRONT_RIGHT |
    181                                   AUDIO_CHANNEL_OUT_BACK_LEFT |
    182                                   AUDIO_CHANNEL_OUT_BACK_RIGHT),
    183     AUDIO_CHANNEL_OUT_SURROUND = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
    184                                   AUDIO_CHANNEL_OUT_FRONT_RIGHT |
    185                                   AUDIO_CHANNEL_OUT_FRONT_CENTER |
    186                                   AUDIO_CHANNEL_OUT_BACK_CENTER),
    187     AUDIO_CHANNEL_OUT_5POINT1  = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
    188                                   AUDIO_CHANNEL_OUT_FRONT_RIGHT |
    189                                   AUDIO_CHANNEL_OUT_FRONT_CENTER |
    190                                   AUDIO_CHANNEL_OUT_LOW_FREQUENCY |
    191                                   AUDIO_CHANNEL_OUT_BACK_LEFT |
    192                                   AUDIO_CHANNEL_OUT_BACK_RIGHT),
    193     // matches the correct AudioFormat.CHANNEL_OUT_7POINT1_SURROUND definition for 7.1
    194     AUDIO_CHANNEL_OUT_7POINT1  = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
    195                                   AUDIO_CHANNEL_OUT_FRONT_RIGHT |
    196                                   AUDIO_CHANNEL_OUT_FRONT_CENTER |
    197                                   AUDIO_CHANNEL_OUT_LOW_FREQUENCY |
    198                                   AUDIO_CHANNEL_OUT_BACK_LEFT |
    199                                   AUDIO_CHANNEL_OUT_BACK_RIGHT |
    200                                   AUDIO_CHANNEL_OUT_SIDE_LEFT |
    201                                   AUDIO_CHANNEL_OUT_SIDE_RIGHT),
    202     AUDIO_CHANNEL_OUT_ALL      = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
    203                                   AUDIO_CHANNEL_OUT_FRONT_RIGHT |
    204                                   AUDIO_CHANNEL_OUT_FRONT_CENTER |
    205                                   AUDIO_CHANNEL_OUT_LOW_FREQUENCY |
    206                                   AUDIO_CHANNEL_OUT_BACK_LEFT |
    207                                   AUDIO_CHANNEL_OUT_BACK_RIGHT |
    208                                   AUDIO_CHANNEL_OUT_FRONT_LEFT_OF_CENTER |
    209                                   AUDIO_CHANNEL_OUT_FRONT_RIGHT_OF_CENTER |
    210                                   AUDIO_CHANNEL_OUT_BACK_CENTER|
    211                                   AUDIO_CHANNEL_OUT_SIDE_LEFT|
    212                                   AUDIO_CHANNEL_OUT_SIDE_RIGHT|
    213                                   AUDIO_CHANNEL_OUT_TOP_CENTER|
    214                                   AUDIO_CHANNEL_OUT_TOP_FRONT_LEFT|
    215                                   AUDIO_CHANNEL_OUT_TOP_FRONT_CENTER|
    216                                   AUDIO_CHANNEL_OUT_TOP_FRONT_RIGHT|
    217                                   AUDIO_CHANNEL_OUT_TOP_BACK_LEFT|
    218                                   AUDIO_CHANNEL_OUT_TOP_BACK_CENTER|
    219                                   AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT),
    220 
    221     /* input channels */
    222     AUDIO_CHANNEL_IN_LEFT            = 0x4,
    223     AUDIO_CHANNEL_IN_RIGHT           = 0x8,
    224     AUDIO_CHANNEL_IN_FRONT           = 0x10,
    225     AUDIO_CHANNEL_IN_BACK            = 0x20,
    226     AUDIO_CHANNEL_IN_LEFT_PROCESSED  = 0x40,
    227     AUDIO_CHANNEL_IN_RIGHT_PROCESSED = 0x80,
    228     AUDIO_CHANNEL_IN_FRONT_PROCESSED = 0x100,
    229     AUDIO_CHANNEL_IN_BACK_PROCESSED  = 0x200,
    230     AUDIO_CHANNEL_IN_PRESSURE        = 0x400,
    231     AUDIO_CHANNEL_IN_X_AXIS          = 0x800,
    232     AUDIO_CHANNEL_IN_Y_AXIS          = 0x1000,
    233     AUDIO_CHANNEL_IN_Z_AXIS          = 0x2000,
    234     AUDIO_CHANNEL_IN_VOICE_UPLINK    = 0x4000,
    235     AUDIO_CHANNEL_IN_VOICE_DNLINK    = 0x8000,
    236 
    237     AUDIO_CHANNEL_IN_MONO   = AUDIO_CHANNEL_IN_FRONT,
    238     AUDIO_CHANNEL_IN_STEREO = (AUDIO_CHANNEL_IN_LEFT | AUDIO_CHANNEL_IN_RIGHT),
    239     AUDIO_CHANNEL_IN_ALL    = (AUDIO_CHANNEL_IN_LEFT |
    240                                AUDIO_CHANNEL_IN_RIGHT |
    241                                AUDIO_CHANNEL_IN_FRONT |
    242                                AUDIO_CHANNEL_IN_BACK|
    243                                AUDIO_CHANNEL_IN_LEFT_PROCESSED |
    244                                AUDIO_CHANNEL_IN_RIGHT_PROCESSED |
    245                                AUDIO_CHANNEL_IN_FRONT_PROCESSED |
    246                                AUDIO_CHANNEL_IN_BACK_PROCESSED|
    247                                AUDIO_CHANNEL_IN_PRESSURE |
    248                                AUDIO_CHANNEL_IN_X_AXIS |
    249                                AUDIO_CHANNEL_IN_Y_AXIS |
    250                                AUDIO_CHANNEL_IN_Z_AXIS |
    251                                AUDIO_CHANNEL_IN_VOICE_UPLINK |
    252                                AUDIO_CHANNEL_IN_VOICE_DNLINK),
    253 } audio_channels_t;
    254 
    255 typedef enum {
    256     AUDIO_MODE_INVALID          = -2,
    257     AUDIO_MODE_CURRENT          = -1,
    258     AUDIO_MODE_NORMAL           = 0,
    259     AUDIO_MODE_RINGTONE         = 1,
    260     AUDIO_MODE_IN_CALL          = 2,
    261     AUDIO_MODE_IN_COMMUNICATION = 3,
    262 
    263     AUDIO_MODE_CNT,
    264     AUDIO_MODE_MAX              = AUDIO_MODE_CNT - 1,
    265 } audio_mode_t;
    266 
    267 typedef enum {
    268     AUDIO_IN_ACOUSTICS_AGC_ENABLE    = 0x0001,
    269     AUDIO_IN_ACOUSTICS_AGC_DISABLE   = 0,
    270     AUDIO_IN_ACOUSTICS_NS_ENABLE     = 0x0002,
    271     AUDIO_IN_ACOUSTICS_NS_DISABLE    = 0,
    272     AUDIO_IN_ACOUSTICS_TX_IIR_ENABLE = 0x0004,
    273     AUDIO_IN_ACOUSTICS_TX_DISABLE    = 0,
    274 } audio_in_acoustics_t;
    275 
    276 typedef enum {
    277     /* output devices */
    278     AUDIO_DEVICE_OUT_EARPIECE                  = 0x1,
    279     AUDIO_DEVICE_OUT_SPEAKER                   = 0x2,
    280     AUDIO_DEVICE_OUT_WIRED_HEADSET             = 0x4,
    281     AUDIO_DEVICE_OUT_WIRED_HEADPHONE           = 0x8,
    282     AUDIO_DEVICE_OUT_BLUETOOTH_SCO             = 0x10,
    283     AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET     = 0x20,
    284     AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT      = 0x40,
    285     AUDIO_DEVICE_OUT_BLUETOOTH_A2DP            = 0x80,
    286     AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100,
    287     AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER    = 0x200,
    288     AUDIO_DEVICE_OUT_AUX_DIGITAL               = 0x400,
    289     AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET         = 0x800,
    290     AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET         = 0x1000,
    291     AUDIO_DEVICE_OUT_DEFAULT                   = 0x8000,
    292     AUDIO_DEVICE_OUT_ALL      = (AUDIO_DEVICE_OUT_EARPIECE |
    293                                  AUDIO_DEVICE_OUT_SPEAKER |
    294                                  AUDIO_DEVICE_OUT_WIRED_HEADSET |
    295                                  AUDIO_DEVICE_OUT_WIRED_HEADPHONE |
    296                                  AUDIO_DEVICE_OUT_BLUETOOTH_SCO |
    297                                  AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
    298                                  AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT |
    299                                  AUDIO_DEVICE_OUT_BLUETOOTH_A2DP |
    300                                  AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
    301                                  AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER |
    302                                  AUDIO_DEVICE_OUT_AUX_DIGITAL |
    303                                  AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET |
    304                                  AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET |
    305                                  AUDIO_DEVICE_OUT_DEFAULT),
    306     AUDIO_DEVICE_OUT_ALL_A2DP = (AUDIO_DEVICE_OUT_BLUETOOTH_A2DP |
    307                                  AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
    308                                  AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER),
    309     AUDIO_DEVICE_OUT_ALL_SCO  = (AUDIO_DEVICE_OUT_BLUETOOTH_SCO |
    310                                  AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
    311                                  AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT),
    312 
    313     /* input devices */
    314     AUDIO_DEVICE_IN_COMMUNICATION         = 0x10000,
    315     AUDIO_DEVICE_IN_AMBIENT               = 0x20000,
    316     AUDIO_DEVICE_IN_BUILTIN_MIC           = 0x40000,
    317     AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET = 0x80000,
    318     AUDIO_DEVICE_IN_WIRED_HEADSET         = 0x100000,
    319     AUDIO_DEVICE_IN_AUX_DIGITAL           = 0x200000,
    320     AUDIO_DEVICE_IN_VOICE_CALL            = 0x400000,
    321     AUDIO_DEVICE_IN_BACK_MIC              = 0x800000,
    322     AUDIO_DEVICE_IN_DEFAULT               = 0x80000000,
    323 
    324     AUDIO_DEVICE_IN_ALL     = (AUDIO_DEVICE_IN_COMMUNICATION |
    325                                AUDIO_DEVICE_IN_AMBIENT |
    326                                AUDIO_DEVICE_IN_BUILTIN_MIC |
    327                                AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET |
    328                                AUDIO_DEVICE_IN_WIRED_HEADSET |
    329                                AUDIO_DEVICE_IN_AUX_DIGITAL |
    330                                AUDIO_DEVICE_IN_VOICE_CALL |
    331                                AUDIO_DEVICE_IN_BACK_MIC |
    332                                AUDIO_DEVICE_IN_DEFAULT),
    333     AUDIO_DEVICE_IN_ALL_SCO = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET,
    334 } audio_devices_t;
    335 
    336 static inline bool audio_is_output_device(audio_devices_t device)
    337 {
    338     if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_OUT_ALL) == 0))
    339         return true;
    340     else
    341         return false;
    342 }
    343 
    344 static inline bool audio_is_input_device(audio_devices_t device)
    345 {
    346     if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_IN_ALL) == 0))
    347         return true;
    348     else
    349         return false;
    350 }
    351 
    352 static inline bool audio_is_a2dp_device(audio_devices_t device)
    353 {
    354     if ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_ALL_A2DP))
    355         return true;
    356     else
    357         return false;
    358 }
    359 
    360 static inline bool audio_is_bluetooth_sco_device(audio_devices_t device)
    361 {
    362     if ((popcount(device) == 1) && (device & (AUDIO_DEVICE_OUT_ALL_SCO |
    363                    AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET)))
    364         return true;
    365     else
    366         return false;
    367 }
    368 
    369 static inline bool audio_is_input_channel(uint32_t channel)
    370 {
    371     if ((channel & ~AUDIO_CHANNEL_IN_ALL) == 0)
    372         return true;
    373     else
    374         return false;
    375 }
    376 
    377 static inline bool audio_is_output_channel(uint32_t channel)
    378 {
    379     if ((channel & ~AUDIO_CHANNEL_OUT_ALL) == 0)
    380         return true;
    381     else
    382         return false;
    383 }
    384 
    385 static inline bool audio_is_valid_format(uint32_t format)
    386 {
    387     switch (format & AUDIO_FORMAT_MAIN_MASK) {
    388     case AUDIO_FORMAT_PCM:
    389         if (format != AUDIO_FORMAT_PCM_16_BIT &&
    390                 format != AUDIO_FORMAT_PCM_8_BIT) {
    391             return false;
    392         }
    393     case AUDIO_FORMAT_MP3:
    394     case AUDIO_FORMAT_AMR_NB:
    395     case AUDIO_FORMAT_AMR_WB:
    396     case AUDIO_FORMAT_AAC:
    397     case AUDIO_FORMAT_HE_AAC_V1:
    398     case AUDIO_FORMAT_HE_AAC_V2:
    399     case AUDIO_FORMAT_VORBIS:
    400         return true;
    401     default:
    402         return false;
    403     }
    404 }
    405 
    406 static inline bool audio_is_linear_pcm(uint32_t format)
    407 {
    408     return ((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_PCM);
    409 }
    410 
    411 static inline size_t audio_bytes_per_sample(uint32_t format)
    412 {
    413     size_t size = 0;
    414 
    415     switch (format) {
    416         case AUDIO_FORMAT_PCM_32_BIT:
    417         case AUDIO_FORMAT_PCM_8_24_BIT:
    418             size = sizeof(int32_t);
    419             break;
    420         case AUDIO_FORMAT_PCM_16_BIT:
    421             size = sizeof(int16_t);
    422             break;
    423         case AUDIO_FORMAT_PCM_8_BIT:
    424             size = sizeof(uint8_t);
    425             break;
    426         default:
    427             break;
    428     }
    429     return size;
    430 }
    431 
    432 __END_DECLS
    433 
    434 #endif  // ANDROID_AUDIO_CORE_H
    435