ALSA:PCM チャンネルマップ

snd_pcm_chmap_tチャンネルマップ構造体
snd_pcm_chmap_query_tチャンネルマップ情報
enum snd_pcm_chmap_positionチャンネルマップ位置
チャンネルマップ
snd_pcm_query_chmaps有効なチャンネルマップを取得(PCM)
snd_pcm_query_chmaps_from_hw有効なチャンネルマップを取得(指定)
snd_pcm_free_chmapsチャンネルマップを解放
snd_pcm_get_chmap現在のチャンネルマップを取得
snd_pcm_set_chmap現在のチャンネルマップをセット
文字列
snd_pcm_chmap_type_nameチャンネルマップタイプから名前を取得
snd_pcm_chmap_nameチャンネルマップ位置から名前を取得
snd_pcm_chmap_long_nameチャンネルマップ位置から長い名前を取得
snd_pcm_chmap_printチャンネルマップから文字列を出力
snd_pcm_chmap_from_string名前からチャンネルマップ位置を取得
snd_pcm_chmap_parse_string文字列からチャンネルマップを解析
typedef struct snd_pcm_chmap {
    unsigned int channels;
    unsigned int pos[0];
} snd_pcm_chmap_t;
チャンネルマップ構造体
channels
チャンネル数
pos
各チャンネルの位置
typedef struct snd_pcm_chmap_query {
    enum snd_pcm_chmap_type type;
    snd_pcm_chmap_t map;
} snd_pcm_chmap_query_t;
チャンネルマップ情報
type
チャンネルマップタイプ。

SND_CHMAP_TYPE_NONE未指定
SND_CHMAP_TYPE_FIXED固定
SND_CHMAP_TYPE_VAR自由に交換可能
SND_CHMAP_TYPE_PAIREDペアで交換可能
enum snd_pcm_chmap_position {
    SND_CHMAP_UNKNOWN = 0, //未定義
    SND_CHMAP_NA,   //無音
    SND_CHMAP_MONO,
    SND_CHMAP_FL,   //Front left
    SND_CHMAP_FR,
    SND_CHMAP_RL,   //Rear left
    SND_CHMAP_RR,
    SND_CHMAP_FC,   //Front center
    SND_CHMAP_LFE,  //LFE
    SND_CHMAP_SL,   //Side left
    SND_CHMAP_SR,
    SND_CHMAP_RC,   //Rear center
    SND_CHMAP_FLC,  //Front left center
    SND_CHMAP_FRC,
    SND_CHMAP_RLC,
    SND_CHMAP_RRC,
    SND_CHMAP_FLW,  //front left wide
    SND_CHMAP_FRW,
    SND_CHMAP_FLH,  //front left high
    SND_CHMAP_FCH,
    SND_CHMAP_FRH,
    SND_CHMAP_TC,   //top center
    SND_CHMAP_TFL,
    SND_CHMAP_TFR,
    SND_CHMAP_TFC,
    SND_CHMAP_TRL,
    SND_CHMAP_TRR,
    SND_CHMAP_TRC,
    SND_CHMAP_TFLC,
    SND_CHMAP_TFRC,
    SND_CHMAP_TSL,
    SND_CHMAP_TSR,
    SND_CHMAP_LLFE,
    SND_CHMAP_RLFE,
    SND_CHMAP_BC,   //bottom center
    SND_CHMAP_BLC,
    SND_CHMAP_BRC,
    SND_CHMAP_LAST = SND_CHMAP_BRC,
};
チャンネルマップ位置
チャンネルマップ
snd_pcm_chmap_query_t **snd_pcm_query_chmaps(snd_pcm_t *pcm);
有効なチャンネルマップを取得(PCM)
戻り値
NULL で終了する配列。エラー時は NULL。
snd_pcm_free_chmaps() で解放する。

各ポインタには、チャンネルマップが含まれる。
チャンネルマップは、チャンネルマップタイプで始まり、チャネル数、各チャネルの位置が、続く整数配列で表される。
snd_pcm_chmap_query_t **snd_pcm_query_chmaps_from_hw(int card, int dev, int subdev, snd_pcm_stream_t stream);
有効なチャンネルマップを取得する。

この関数は snd_pcm_query_chmaps() と同様に動作するが、snd_pcm_t ではなく、カード、デバイス、サブデバイス、ストリームタイプを指定する。
そのため、PCM を開く前に、使用可能なチャンネルマップを照会できる。

パラメータがそのままの場合、照会はハードウェア PCM デバイスに対してのみ実行され、alsa-lib 内の抽象化された PCM オブジェクトに対しては実行されない。
void snd_pcm_free_chmaps(snd_pcm_chmap_query_t **maps);
チャンネルマップを解放
snd_pcm_chmap_t *snd_pcm_get_chmap(snd_pcm_t *pcm);
現在のチャンネルマップを取得
戻り値
エラー時は NULL。
free() で解放する。
int snd_pcm_set_chmap(snd_pcm_t *pcm, const snd_pcm_chmap_t *map);
現在のチャンネルマップをセット
戻り値
0 で成功、負の値でエラーコード
文字列
const char *snd_pcm_chmap_type_name(enum snd_pcm_chmap_type val);
チャンネルマップタイプから名前を取得
戻り値
名前または NULL
const char *snd_pcm_chmap_name(enum snd_pcm_chmap_position val);
チャンネルマップ位置から名前を取得
戻り値
名前または NULL
const char *snd_pcm_chmap_long_name(enum snd_pcm_chmap_position val);
チャンネルマップ位置から長い名前を取得
戻り値
名前または NULL
int snd_pcm_chmap_print(const snd_pcm_chmap_t *map, size_t maxlen, char *buf);
チャンネルマップから文字列を出力
maxlen
バッファのサイズ (NULL 文字含む)
buf
書き込まれるバッファ
戻り値
実際の文字列の長さ。負の値でエラーコード
unsigned int snd_pcm_chmap_from_string(const char *str);
名前からチャンネルマップ位置を取得
戻り値
-1 でエラー
snd_pcm_chmap_t *snd_pcm_chmap_parse_string(const char *str);
文字列からチャンネルマップを解析
戻り値
free() で解放する