Path: blob/master/thirdparty/linuxbsd_headers/pulse/channelmap.h
9905 views
#ifndef foochannelmaphfoo1#define foochannelmaphfoo23/***4This file is part of PulseAudio.56Copyright 2005-2006 Lennart Poettering7Copyright 2006 Pierre Ossman <[email protected]> for Cendio AB89PulseAudio is free software; you can redistribute it and/or modify10it under the terms of the GNU Lesser General Public License as published11by the Free Software Foundation; either version 2.1 of the License,12or (at your option) any later version.1314PulseAudio is distributed in the hope that it will be useful, but15WITHOUT ANY WARRANTY; without even the implied warranty of16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU17General Public License for more details.1819You should have received a copy of the GNU Lesser General Public License20along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.21***/2223#include <pulse/sample.h>24#include <pulse/cdecl.h>25#include <pulse/gccmacro.h>26#include <pulse/version.h>2728/** \page channelmap Channel Maps29*30* \section overv_sec Overview31*32* Channel maps provide a way to associate channels in a stream with a33* specific speaker position. This relieves applications of having to34* make sure their channel order is identical to the final output.35*36* \section init_sec Initialisation37*38* A channel map consists of an array of \ref pa_channel_position values,39* one for each channel. This array is stored together with a channel count40* in a pa_channel_map structure.41*42* Before filling the structure, the application must initialise it using43* pa_channel_map_init(). There are also a number of convenience functions44* for standard channel mappings:45*46* \li pa_channel_map_init_mono() - Create a channel map with only mono audio.47* \li pa_channel_map_init_stereo() - Create a standard stereo mapping.48* \li pa_channel_map_init_auto() - Create a standard channel map for a specific number of channels49* \li pa_channel_map_init_extend() - Similar to50* pa_channel_map_init_auto() but synthesize a channel map if no51* predefined one is known for the specified number of channels.52*53* \section conv_sec Convenience Functions54*55* The library contains a number of convenience functions for dealing with56* channel maps:57*58* \li pa_channel_map_valid() - Tests if a channel map is valid.59* \li pa_channel_map_equal() - Tests if two channel maps are identical.60* \li pa_channel_map_snprint() - Creates a textual description of a channel61* map.62*/6364/** \file65* Constants and routines for channel mapping handling66*67* See also \subpage channelmap68*/6970PA_C_DECL_BEGIN7172/** A list of channel labels */73typedef enum pa_channel_position {74PA_CHANNEL_POSITION_INVALID = -1,75PA_CHANNEL_POSITION_MONO = 0,7677PA_CHANNEL_POSITION_FRONT_LEFT, /**< Apple, Dolby call this 'Left' */78PA_CHANNEL_POSITION_FRONT_RIGHT, /**< Apple, Dolby call this 'Right' */79PA_CHANNEL_POSITION_FRONT_CENTER, /**< Apple, Dolby call this 'Center' */8081/** \cond fulldocs */82PA_CHANNEL_POSITION_LEFT = PA_CHANNEL_POSITION_FRONT_LEFT,83PA_CHANNEL_POSITION_RIGHT = PA_CHANNEL_POSITION_FRONT_RIGHT,84PA_CHANNEL_POSITION_CENTER = PA_CHANNEL_POSITION_FRONT_CENTER,85/** \endcond */8687PA_CHANNEL_POSITION_REAR_CENTER, /**< Microsoft calls this 'Back Center', Apple calls this 'Center Surround', Dolby calls this 'Surround Rear Center' */88PA_CHANNEL_POSITION_REAR_LEFT, /**< Microsoft calls this 'Back Left', Apple calls this 'Left Surround' (!), Dolby calls this 'Surround Rear Left' */89PA_CHANNEL_POSITION_REAR_RIGHT, /**< Microsoft calls this 'Back Right', Apple calls this 'Right Surround' (!), Dolby calls this 'Surround Rear Right' */9091PA_CHANNEL_POSITION_LFE, /**< Microsoft calls this 'Low Frequency', Apple calls this 'LFEScreen' */92/** \cond fulldocs */93PA_CHANNEL_POSITION_SUBWOOFER = PA_CHANNEL_POSITION_LFE,94/** \endcond */9596PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER, /**< Apple, Dolby call this 'Left Center' */97PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER, /**< Apple, Dolby call this 'Right Center */9899PA_CHANNEL_POSITION_SIDE_LEFT, /**< Apple calls this 'Left Surround Direct', Dolby calls this 'Surround Left' (!) */100PA_CHANNEL_POSITION_SIDE_RIGHT, /**< Apple calls this 'Right Surround Direct', Dolby calls this 'Surround Right' (!) */101102PA_CHANNEL_POSITION_AUX0,103PA_CHANNEL_POSITION_AUX1,104PA_CHANNEL_POSITION_AUX2,105PA_CHANNEL_POSITION_AUX3,106PA_CHANNEL_POSITION_AUX4,107PA_CHANNEL_POSITION_AUX5,108PA_CHANNEL_POSITION_AUX6,109PA_CHANNEL_POSITION_AUX7,110PA_CHANNEL_POSITION_AUX8,111PA_CHANNEL_POSITION_AUX9,112PA_CHANNEL_POSITION_AUX10,113PA_CHANNEL_POSITION_AUX11,114PA_CHANNEL_POSITION_AUX12,115PA_CHANNEL_POSITION_AUX13,116PA_CHANNEL_POSITION_AUX14,117PA_CHANNEL_POSITION_AUX15,118PA_CHANNEL_POSITION_AUX16,119PA_CHANNEL_POSITION_AUX17,120PA_CHANNEL_POSITION_AUX18,121PA_CHANNEL_POSITION_AUX19,122PA_CHANNEL_POSITION_AUX20,123PA_CHANNEL_POSITION_AUX21,124PA_CHANNEL_POSITION_AUX22,125PA_CHANNEL_POSITION_AUX23,126PA_CHANNEL_POSITION_AUX24,127PA_CHANNEL_POSITION_AUX25,128PA_CHANNEL_POSITION_AUX26,129PA_CHANNEL_POSITION_AUX27,130PA_CHANNEL_POSITION_AUX28,131PA_CHANNEL_POSITION_AUX29,132PA_CHANNEL_POSITION_AUX30,133PA_CHANNEL_POSITION_AUX31,134135PA_CHANNEL_POSITION_TOP_CENTER, /**< Apple calls this 'Top Center Surround' */136137PA_CHANNEL_POSITION_TOP_FRONT_LEFT, /**< Apple calls this 'Vertical Height Left' */138PA_CHANNEL_POSITION_TOP_FRONT_RIGHT, /**< Apple calls this 'Vertical Height Right' */139PA_CHANNEL_POSITION_TOP_FRONT_CENTER, /**< Apple calls this 'Vertical Height Center' */140141PA_CHANNEL_POSITION_TOP_REAR_LEFT, /**< Microsoft and Apple call this 'Top Back Left' */142PA_CHANNEL_POSITION_TOP_REAR_RIGHT, /**< Microsoft and Apple call this 'Top Back Right' */143PA_CHANNEL_POSITION_TOP_REAR_CENTER, /**< Microsoft and Apple call this 'Top Back Center' */144145PA_CHANNEL_POSITION_MAX146} pa_channel_position_t;147148/** \cond fulldocs */149#define PA_CHANNEL_POSITION_INVALID PA_CHANNEL_POSITION_INVALID150#define PA_CHANNEL_POSITION_MONO PA_CHANNEL_POSITION_MONO151#define PA_CHANNEL_POSITION_LEFT PA_CHANNEL_POSITION_LEFT152#define PA_CHANNEL_POSITION_RIGHT PA_CHANNEL_POSITION_RIGHT153#define PA_CHANNEL_POSITION_CENTER PA_CHANNEL_POSITION_CENTER154#define PA_CHANNEL_POSITION_FRONT_LEFT PA_CHANNEL_POSITION_FRONT_LEFT155#define PA_CHANNEL_POSITION_FRONT_RIGHT PA_CHANNEL_POSITION_FRONT_RIGHT156#define PA_CHANNEL_POSITION_FRONT_CENTER PA_CHANNEL_POSITION_FRONT_CENTER157#define PA_CHANNEL_POSITION_REAR_CENTER PA_CHANNEL_POSITION_REAR_CENTER158#define PA_CHANNEL_POSITION_REAR_LEFT PA_CHANNEL_POSITION_REAR_LEFT159#define PA_CHANNEL_POSITION_REAR_RIGHT PA_CHANNEL_POSITION_REAR_RIGHT160#define PA_CHANNEL_POSITION_LFE PA_CHANNEL_POSITION_LFE161#define PA_CHANNEL_POSITION_SUBWOOFER PA_CHANNEL_POSITION_SUBWOOFER162#define PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER163#define PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER164#define PA_CHANNEL_POSITION_SIDE_LEFT PA_CHANNEL_POSITION_SIDE_LEFT165#define PA_CHANNEL_POSITION_SIDE_RIGHT PA_CHANNEL_POSITION_SIDE_RIGHT166#define PA_CHANNEL_POSITION_AUX0 PA_CHANNEL_POSITION_AUX0167#define PA_CHANNEL_POSITION_AUX1 PA_CHANNEL_POSITION_AUX1168#define PA_CHANNEL_POSITION_AUX2 PA_CHANNEL_POSITION_AUX2169#define PA_CHANNEL_POSITION_AUX3 PA_CHANNEL_POSITION_AUX3170#define PA_CHANNEL_POSITION_AUX4 PA_CHANNEL_POSITION_AUX4171#define PA_CHANNEL_POSITION_AUX5 PA_CHANNEL_POSITION_AUX5172#define PA_CHANNEL_POSITION_AUX6 PA_CHANNEL_POSITION_AUX6173#define PA_CHANNEL_POSITION_AUX7 PA_CHANNEL_POSITION_AUX7174#define PA_CHANNEL_POSITION_AUX8 PA_CHANNEL_POSITION_AUX8175#define PA_CHANNEL_POSITION_AUX9 PA_CHANNEL_POSITION_AUX9176#define PA_CHANNEL_POSITION_AUX10 PA_CHANNEL_POSITION_AUX10177#define PA_CHANNEL_POSITION_AUX11 PA_CHANNEL_POSITION_AUX11178#define PA_CHANNEL_POSITION_AUX12 PA_CHANNEL_POSITION_AUX12179#define PA_CHANNEL_POSITION_AUX13 PA_CHANNEL_POSITION_AUX13180#define PA_CHANNEL_POSITION_AUX14 PA_CHANNEL_POSITION_AUX14181#define PA_CHANNEL_POSITION_AUX15 PA_CHANNEL_POSITION_AUX15182#define PA_CHANNEL_POSITION_AUX16 PA_CHANNEL_POSITION_AUX16183#define PA_CHANNEL_POSITION_AUX17 PA_CHANNEL_POSITION_AUX17184#define PA_CHANNEL_POSITION_AUX18 PA_CHANNEL_POSITION_AUX18185#define PA_CHANNEL_POSITION_AUX19 PA_CHANNEL_POSITION_AUX19186#define PA_CHANNEL_POSITION_AUX20 PA_CHANNEL_POSITION_AUX20187#define PA_CHANNEL_POSITION_AUX21 PA_CHANNEL_POSITION_AUX21188#define PA_CHANNEL_POSITION_AUX22 PA_CHANNEL_POSITION_AUX22189#define PA_CHANNEL_POSITION_AUX23 PA_CHANNEL_POSITION_AUX23190#define PA_CHANNEL_POSITION_AUX24 PA_CHANNEL_POSITION_AUX24191#define PA_CHANNEL_POSITION_AUX25 PA_CHANNEL_POSITION_AUX25192#define PA_CHANNEL_POSITION_AUX26 PA_CHANNEL_POSITION_AUX26193#define PA_CHANNEL_POSITION_AUX27 PA_CHANNEL_POSITION_AUX27194#define PA_CHANNEL_POSITION_AUX28 PA_CHANNEL_POSITION_AUX28195#define PA_CHANNEL_POSITION_AUX29 PA_CHANNEL_POSITION_AUX29196#define PA_CHANNEL_POSITION_AUX30 PA_CHANNEL_POSITION_AUX30197#define PA_CHANNEL_POSITION_AUX31 PA_CHANNEL_POSITION_AUX31198#define PA_CHANNEL_POSITION_TOP_CENTER PA_CHANNEL_POSITION_TOP_CENTER199#define PA_CHANNEL_POSITION_TOP_FRONT_LEFT PA_CHANNEL_POSITION_TOP_FRONT_LEFT200#define PA_CHANNEL_POSITION_TOP_FRONT_RIGHT PA_CHANNEL_POSITION_TOP_FRONT_RIGHT201#define PA_CHANNEL_POSITION_TOP_FRONT_CENTER PA_CHANNEL_POSITION_TOP_FRONT_CENTER202#define PA_CHANNEL_POSITION_TOP_REAR_LEFT PA_CHANNEL_POSITION_TOP_REAR_LEFT203#define PA_CHANNEL_POSITION_TOP_REAR_RIGHT PA_CHANNEL_POSITION_TOP_REAR_RIGHT204#define PA_CHANNEL_POSITION_TOP_REAR_CENTER PA_CHANNEL_POSITION_TOP_REAR_CENTER205#define PA_CHANNEL_POSITION_MAX PA_CHANNEL_POSITION_MAX206/** \endcond */207208/** A mask of channel positions. \since 0.9.16 */209typedef uint64_t pa_channel_position_mask_t;210211/** Makes a bit mask from a channel position. \since 0.9.16 */212#define PA_CHANNEL_POSITION_MASK(f) ((pa_channel_position_mask_t) (1ULL << (f)))213214/** A list of channel mapping definitions for pa_channel_map_init_auto() */215typedef enum pa_channel_map_def {216PA_CHANNEL_MAP_AIFF,217/**< The mapping from RFC3551, which is based on AIFF-C */218219/** \cond fulldocs */220PA_CHANNEL_MAP_ALSA,221/**< The default mapping used by ALSA. This mapping is probably222* not too useful since ALSA's default channel mapping depends on223* the device string used. */224/** \endcond */225226PA_CHANNEL_MAP_AUX,227/**< Only aux channels */228229PA_CHANNEL_MAP_WAVEEX,230/**< Microsoft's WAVEFORMATEXTENSIBLE mapping. This mapping works231* as if all LSBs of dwChannelMask are set. */232233/** \cond fulldocs */234PA_CHANNEL_MAP_OSS,235/**< The default channel mapping used by OSS as defined in the OSS236* 4.0 API specs. This mapping is probably not too useful since237* the OSS API has changed in this respect and no longer knows a238* default channel mapping based on the number of channels. */239/** \endcond */240241/**< Upper limit of valid channel mapping definitions */242PA_CHANNEL_MAP_DEF_MAX,243244PA_CHANNEL_MAP_DEFAULT = PA_CHANNEL_MAP_AIFF245/**< The default channel map */246} pa_channel_map_def_t;247248/** \cond fulldocs */249#define PA_CHANNEL_MAP_AIFF PA_CHANNEL_MAP_AIFF250#define PA_CHANNEL_MAP_ALSA PA_CHANNEL_MAP_ALSA251#define PA_CHANNEL_MAP_AUX PA_CHANNEL_MAP_AUX252#define PA_CHANNEL_MAP_WAVEEX PA_CHANNEL_MAP_WAVEEX253#define PA_CHANNEL_MAP_OSS PA_CHANNEL_MAP_OSS254#define PA_CHANNEL_MAP_DEF_MAX PA_CHANNEL_MAP_DEF_MAX255#define PA_CHANNEL_MAP_DEFAULT PA_CHANNEL_MAP_DEFAULT256/** \endcond */257258/** A channel map which can be used to attach labels to specific259* channels of a stream. These values are relevant for conversion and260* mixing of streams */261typedef struct pa_channel_map {262uint8_t channels;263/**< Number of channels */264265pa_channel_position_t map[PA_CHANNELS_MAX];266/**< Channel labels */267} pa_channel_map;268269/** Initialize the specified channel map and return a pointer to270* it. The channel map will have a defined state but271* pa_channel_map_valid() will fail for it. */272pa_channel_map* pa_channel_map_init(pa_channel_map *m);273274/** Initialize the specified channel map for monaural audio and return a pointer to it */275pa_channel_map* pa_channel_map_init_mono(pa_channel_map *m);276277/** Initialize the specified channel map for stereophonic audio and return a pointer to it */278pa_channel_map* pa_channel_map_init_stereo(pa_channel_map *m);279280/** Initialize the specified channel map for the specified number of281* channels using default labels and return a pointer to it. This call282* will fail (return NULL) if there is no default channel map known for this283* specific number of channels and mapping. */284pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, pa_channel_map_def_t def);285286/** Similar to pa_channel_map_init_auto() but instead of failing if no287* default mapping is known with the specified parameters it will288* synthesize a mapping based on a known mapping with fewer channels289* and fill up the rest with AUX0...AUX31 channels \since 0.9.11 */290pa_channel_map* pa_channel_map_init_extend(pa_channel_map *m, unsigned channels, pa_channel_map_def_t def);291292/** Return a text label for the specified channel position */293const char* pa_channel_position_to_string(pa_channel_position_t pos) PA_GCC_PURE;294295/** The inverse of pa_channel_position_to_string(). \since 0.9.16 */296pa_channel_position_t pa_channel_position_from_string(const char *s) PA_GCC_PURE;297298/** Return a human readable text label for the specified channel position. \since 0.9.7 */299const char* pa_channel_position_to_pretty_string(pa_channel_position_t pos);300301/** The maximum length of strings returned by302* pa_channel_map_snprint(). Please note that this value can change303* with any release without warning and without being considered API304* or ABI breakage. You should not use this definition anywhere where305* it might become part of an ABI. */306#define PA_CHANNEL_MAP_SNPRINT_MAX 336307308/** Make a human readable string from the specified channel map */309char* pa_channel_map_snprint(char *s, size_t l, const pa_channel_map *map);310311/** Parse a channel position list or well-known mapping name into a312* channel map structure. This turns the output of313* pa_channel_map_snprint() and pa_channel_map_to_name() back into a314* pa_channel_map */315pa_channel_map *pa_channel_map_parse(pa_channel_map *map, const char *s);316317/** Compare two channel maps. Return 1 if both match. */318int pa_channel_map_equal(const pa_channel_map *a, const pa_channel_map *b) PA_GCC_PURE;319320/** Return non-zero if the specified channel map is considered valid */321int pa_channel_map_valid(const pa_channel_map *map) PA_GCC_PURE;322323/** Return non-zero if the specified channel map is compatible with324* the specified sample spec. \since 0.9.12 */325int pa_channel_map_compatible(const pa_channel_map *map, const pa_sample_spec *ss) PA_GCC_PURE;326327/** Returns non-zero if every channel defined in b is also defined in a. \since 0.9.15 */328int pa_channel_map_superset(const pa_channel_map *a, const pa_channel_map *b) PA_GCC_PURE;329330/** Returns non-zero if it makes sense to apply a volume 'balance'331* with this mapping, i.e.\ if there are left/right channels332* available. \since 0.9.15 */333int pa_channel_map_can_balance(const pa_channel_map *map) PA_GCC_PURE;334335/** Returns non-zero if it makes sense to apply a volume 'fade'336* (i.e.\ 'balance' between front and rear) with this mapping, i.e.\ if337* there are front/rear channels available. \since 0.9.15 */338int pa_channel_map_can_fade(const pa_channel_map *map) PA_GCC_PURE;339340/** Returns non-zero if it makes sense to apply a volume 'lfe balance'341* (i.e.\ 'balance' between LFE and non-LFE channels) with this mapping,342* i.e.\ if there are LFE and non-LFE channels available. \since 8.0 */343int pa_channel_map_can_lfe_balance(const pa_channel_map *map) PA_GCC_PURE;344345/** Tries to find a well-known channel mapping name for this channel346* mapping, i.e.\ "stereo", "surround-71" and so on. If the channel347* mapping is unknown NULL will be returned. This name can be parsed348* with pa_channel_map_parse() \since 0.9.15 */349const char* pa_channel_map_to_name(const pa_channel_map *map) PA_GCC_PURE;350351/** Tries to find a human readable text label for this channel352mapping, i.e.\ "Stereo", "Surround 7.1" and so on. If the channel353mapping is unknown NULL will be returned. \since 0.9.15 */354const char* pa_channel_map_to_pretty_name(const pa_channel_map *map) PA_GCC_PURE;355356/** Returns non-zero if the specified channel position is available at357* least once in the channel map. \since 0.9.16 */358int pa_channel_map_has_position(const pa_channel_map *map, pa_channel_position_t p) PA_GCC_PURE;359360/** Generates a bit mask from a channel map. \since 0.9.16 */361pa_channel_position_mask_t pa_channel_map_mask(const pa_channel_map *map) PA_GCC_PURE;362363PA_C_DECL_END364365#endif366367368