diff options
author | Wim Taymans <wtaymans@redhat.com> | 2020-02-04 15:54:57 +0100 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2020-02-04 15:54:57 +0100 |
commit | 8abbf653e6c95e2833ab5080a0bf29fb61e67895 (patch) | |
tree | f332fea413c147e063ebb69fe435887ebe99b368 | |
parent | 25e81d844a74eb113d9c0f2add7dc9331cb159ab (diff) |
pw-cat: Use default channel layout when nothing given
Make channel layout definitions a little more useful. We can now
assign them to a layout_info struct or in the raw_info.
Make some default channel layouts for use in pw-cat
-rw-r--r-- | spa/include/spa/param/audio/layout.h | 261 | ||||
-rw-r--r-- | src/tools/pw-cat.c | 80 |
2 files changed, 195 insertions, 146 deletions
diff --git a/spa/include/spa/param/audio/layout.h b/spa/include/spa/param/audio/layout.h index 41601c3d..3218e00f 100644 --- a/spa/include/spa/param/audio/layout.h +++ b/spa/include/spa/param/audio/layout.h @@ -33,142 +33,149 @@ extern "C" { #include <endian.h> #endif -#define SPA_AUDIO_LAYOUT_Mono 1, SPA_AUDIO_CHANNEL_MONO -#define SPA_AUDIO_LAYOUT_Stereo 2, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR -#define SPA_AUDIO_LAYOUT_Quad 4, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR -#define SPA_AUDIO_LAYOUT_Pentagonal 5, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR, \ - SPA_AUDIO_CHANNEL_FC -#define SPA_AUDIO_LAYOUT_Hexagonal 6, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_RC -#define SPA_AUDIO_LAYOUT_Octagonal 8, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_RC, \ - SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR, -#define SPA_AUDIO_LAYOUT_Cube 8, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR, \ - SPA_AUDIO_CHANNEL_TFL, SPA_AUDIO_CHANNEL_TFR, \ - SPA_AUDIO_CHANNEL_TRL, SPA_AUDIO_CHANNEL_TRR, +#include <spa/param/audio/raw.h> + +struct spa_audio_layout_info { + uint32_t n_channels; + uint32_t position[SPA_AUDIO_MAX_CHANNELS]; +}; + +#define SPA_AUDIO_LAYOUT_Mono 1, { SPA_AUDIO_CHANNEL_MONO, } +#define SPA_AUDIO_LAYOUT_Stereo 2, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, } +#define SPA_AUDIO_LAYOUT_Quad 4, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR, } +#define SPA_AUDIO_LAYOUT_Pentagonal 5, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR, \ + SPA_AUDIO_CHANNEL_FC, } +#define SPA_AUDIO_LAYOUT_Hexagonal 6, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_RC, } +#define SPA_AUDIO_LAYOUT_Octagonal 8, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_RC, \ + SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR, } +#define SPA_AUDIO_LAYOUT_Cube 8, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR }, \ + SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR, \ + SPA_AUDIO_CHANNEL_TFL, SPA_AUDIO_CHANNEL_TFR, \ + SPA_AUDIO_CHANNEL_TRL, SPA_AUDIO_CHANNEL_TRR, } #define SPA_AUDIO_LAYOUT_MPEG_1_0 SPA_AUDIO_LAYOUT_MONO #define SPA_AUDIO_LAYOUT_MPEG_2_0 SPA_AUDIO_LAYOUT_STEREO -#define SPA_AUDIO_LAYOUT_MPEG_3_0A 3, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FC -#define SPA_AUDIO_LAYOUT_MPEG_3_0B 3, SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_FL, \ - SPA_AUDIO_CHANNEL_FR -#define SPA_AUDIO_LAYOUT_MPEG_4_0A 4, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_RC -#define SPA_AUDIO_LAYOUT_MPEG_4_0B 4, SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_FL, \ - SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_RC -#define SPA_AUDIO_LAYOUT_MPEG_5_0A 5, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_SL, \ - SPA_AUDIO_CHANNEL_SR -#define SPA_AUDIO_LAYOUT_MPEG_5_0B 5, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR, \ - SPA_AUDIO_CHANNEL_FC -#define SPA_AUDIO_LAYOUT_MPEG_5_0C 5, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FC, \ - SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_SL, \ - SPA_AUDIO_CHANNEL_SR -#define SPA_AUDIO_LAYOUT_MPEG_5_0D 5, SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_FL, \ - SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_SL, \ - SPA_AUDIO_CHANNEL_SR -#define SPA_AUDIO_LAYOUT_MPEG_5_1A 6, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ - SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR -#define SPA_AUDIO_LAYOUT_MPEG_5_1B 6, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE -#define SPA_AUDIO_LAYOUT_MPEG_5_1C 6, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FC, \ - SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_SL, \ - SPA_AUDIO_CHANNEL_SR, SPA_AUDIO_CHANNEL_LFE -#define SPA_AUDIO_LAYOUT_MPEG_5_1D 6, SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_FL, \ - SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_SL, \ - SPA_AUDIO_CHANNEL_SR, SPA_AUDIO_CHANNEL_LFE -#define SPA_AUDIO_LAYOUT_MPEG_6_1A 7, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ - SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR, \ - SPA_AUDIO_CHANNEL_RC -#define SPA_AUDIO_LAYOUT_MPEG_7_1A 8, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ - SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR, \ - SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR -#define SPA_AUDIO_LAYOUT_MPEG_7_1B 8, SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_SL, \ - SPA_AUDIO_CHANNEL_SR, SPA_AUDIO_CHANNEL_FL, \ - SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_RL, \ - SPA_AUDIO_CHANNEL_RR, SPA_AUDIO_CHANNEL_LFE -#define SPA_AUDIO_LAYOUT_MPEG_7_1C 8, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ - SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR, \ - SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR +#define SPA_AUDIO_LAYOUT_MPEG_3_0A 3, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FC, } +#define SPA_AUDIO_LAYOUT_MPEG_3_0B 3, { SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_FL, \ + SPA_AUDIO_CHANNEL_FR, } +#define SPA_AUDIO_LAYOUT_MPEG_4_0A 4, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_RC, } +#define SPA_AUDIO_LAYOUT_MPEG_4_0B 4, { SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_FL, \ + SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_RC, } +#define SPA_AUDIO_LAYOUT_MPEG_5_0A 5, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_SL, \ + SPA_AUDIO_CHANNEL_SR, } +#define SPA_AUDIO_LAYOUT_MPEG_5_0B 5, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR, \ + SPA_AUDIO_CHANNEL_FC, } +#define SPA_AUDIO_LAYOUT_MPEG_5_0C 5, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FC, \ + SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_SL, \ + SPA_AUDIO_CHANNEL_SR, } +#define SPA_AUDIO_LAYOUT_MPEG_5_0D 5, { SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_FL, \ + SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_SL, \ + SPA_AUDIO_CHANNEL_SR, } +#define SPA_AUDIO_LAYOUT_MPEG_5_1A 6, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ + SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR, } +#define SPA_AUDIO_LAYOUT_MPEG_5_1B 6, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, } +#define SPA_AUDIO_LAYOUT_MPEG_5_1C 6, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FC, \ + SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_SL, \ + SPA_AUDIO_CHANNEL_SR, SPA_AUDIO_CHANNEL_LFE, } +#define SPA_AUDIO_LAYOUT_MPEG_5_1D 6, { SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_FL, \ + SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_SL, \ + SPA_AUDIO_CHANNEL_SR, SPA_AUDIO_CHANNEL_LFE, } +#define SPA_AUDIO_LAYOUT_MPEG_6_1A 7, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ + SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR, \ + SPA_AUDIO_CHANNEL_RC, } +#define SPA_AUDIO_LAYOUT_MPEG_7_1A 8, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ + SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR, \ + SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR, } +#define SPA_AUDIO_LAYOUT_MPEG_7_1B 8, { SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_SL, \ + SPA_AUDIO_CHANNEL_SR, SPA_AUDIO_CHANNEL_FL, \ + SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_RL, \ + SPA_AUDIO_CHANNEL_RR, SPA_AUDIO_CHANNEL_LFE, } +#define SPA_AUDIO_LAYOUT_MPEG_7_1C 8, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ + SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR, \ + SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR, } -#define SPA_AUDIO_LAYOUT_2_1 3, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_LFE +#define SPA_AUDIO_LAYOUT_2_1 3, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_LFE, } -#define SPA_AUDIO_LAYOUT_2RC 3, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_RC -#define SPA_AUDIO_LAYOUT_2FC 3, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FC +#define SPA_AUDIO_LAYOUT_2RC 3, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_RC, } +#define SPA_AUDIO_LAYOUT_2FC 3, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FC, } -#define SPA_AUDIO_LAYOUT_3_1 4, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE -#define SPA_AUDIO_LAYOUT_4_0 4, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_RC -#define SPA_AUDIO_LAYOUT_2_2 4, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR +#define SPA_AUDIO_LAYOUT_3_1 4, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, } +#define SPA_AUDIO_LAYOUT_4_0 4, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_RC, } +#define SPA_AUDIO_LAYOUT_2_2 4, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR, } -#define SPA_AUDIO_LAYOUT_4_1 5, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ - SPA_AUDIO_CHANNEL_RC -#define SPA_AUDIO_LAYOUT_5_0 5, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_SL, \ - SPA_AUDIO_CHANNEL_SR -#define SPA_AUDIO_LAYOUT_5_0R 5, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_RL, \ - SPA_AUDIO_CHANNEL_RR -#define SPA_AUDIO_LAYOUT_5_1 6, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ - SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR -#define SPA_AUDIO_LAYOUT_5_1R 6, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ - SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR -#define SPA_AUDIO_LAYOUT_6_0 6, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_RC, \ - SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR -#define SPA_AUDIO_LAYOUT_6_0F 6, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FLC, SPA_AUDIO_CHANNEL_FRC, \ - SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR -#define SPA_AUDIO_LAYOUT_6_1 7, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ - SPA_AUDIO_CHANNEL_RC, SPA_AUDIO_CHANNEL_SL, \ - SPA_AUDIO_CHANNEL_SR -#define SPA_AUDIO_LAYOUT_6_1F 7, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ - SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR, \ - SPA_AUDIO_CHANNEL_RC -#define SPA_AUDIO_LAYOUT_7_0 7, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_RL, \ - SPA_AUDIO_CHANNEL_RR, SPA_AUDIO_CHANNEL_SL, \ - SPA_AUDIO_CHANNEL_SR -#define SPA_AUDIO_LAYOUT_7_0F 7, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_FLC, \ - SPA_AUDIO_CHANNEL_FRC, SPA_AUDIO_CHANNEL_SL, \ - SPA_AUDIO_CHANNEL_SR -#define SPA_AUDIO_LAYOUT_7_1 8, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ - SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR, \ - SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR -#define SPA_AUDIO_LAYOUT_7_1W 8, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ - SPA_AUDIO_CHANNEL_FLC, SPA_AUDIO_CHANNEL_FRC, \ - SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR -#define SPA_AUDIO_LAYOUT_7_1WR 8, SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ - SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ - SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR, \ - SPA_AUDIO_CHANNEL_FLC, SPA_AUDIO_CHANNEL_FRC +#define SPA_AUDIO_LAYOUT_4_1 5, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ + SPA_AUDIO_CHANNEL_RC, } +#define SPA_AUDIO_LAYOUT_5_0 5, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_SL, \ + SPA_AUDIO_CHANNEL_SR, } +#define SPA_AUDIO_LAYOUT_5_0R 5, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_RL, \ + SPA_AUDIO_CHANNEL_RR, } +#define SPA_AUDIO_LAYOUT_5_1 6, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ + SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR, } +#define SPA_AUDIO_LAYOUT_5_1R 6, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ + SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR, } +#define SPA_AUDIO_LAYOUT_6_0 6, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_RC, \ + SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR, } +#define SPA_AUDIO_LAYOUT_6_0F 6, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FLC, SPA_AUDIO_CHANNEL_FRC, \ + SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR, } +#define SPA_AUDIO_LAYOUT_6_1 7, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ + SPA_AUDIO_CHANNEL_RC, SPA_AUDIO_CHANNEL_SL, \ + SPA_AUDIO_CHANNEL_SR, } +#define SPA_AUDIO_LAYOUT_6_1F 7, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ + SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR, \ + SPA_AUDIO_CHANNEL_RC, } +#define SPA_AUDIO_LAYOUT_7_0 7, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_RL, \ + SPA_AUDIO_CHANNEL_RR, SPA_AUDIO_CHANNEL_SL, \ + SPA_AUDIO_CHANNEL_SR, } +#define SPA_AUDIO_LAYOUT_7_0F 7, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_FLC, \ + SPA_AUDIO_CHANNEL_FRC, SPA_AUDIO_CHANNEL_SL, \ + SPA_AUDIO_CHANNEL_SR, } +#define SPA_AUDIO_LAYOUT_7_1 8, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ + SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR, \ + SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR, } +#define SPA_AUDIO_LAYOUT_7_1W 8, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ + SPA_AUDIO_CHANNEL_FLC, SPA_AUDIO_CHANNEL_FRC, \ + SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR, } +#define SPA_AUDIO_LAYOUT_7_1WR 8, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \ + SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \ + SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR, \ + SPA_AUDIO_CHANNEL_FLC, SPA_AUDIO_CHANNEL_FRC, } #ifdef __cplusplus } /* extern "C" */ diff --git a/src/tools/pw-cat.c b/src/tools/pw-cat.c index 7988ce9e..24855fec 100644 --- a/src/tools/pw-cat.c +++ b/src/tools/pw-cat.c @@ -442,22 +442,27 @@ static int channelmap_from_sf(struct channelmap *map) } return 0; } - struct mapping { const char *name; - unsigned int values[33]; + unsigned int channels; + unsigned int values[32]; }; static const struct mapping maps[] = { - { "stereo", { SPA_AUDIO_LAYOUT_Stereo } }, - { "quad", { SPA_AUDIO_LAYOUT_Quad } }, - { "surround-40", { SPA_AUDIO_LAYOUT_Quad } }, - { "surround-31", { SPA_AUDIO_LAYOUT_3_1 } }, - { "surround-41", { SPA_AUDIO_LAYOUT_4_1 } }, - { "surround-50", { SPA_AUDIO_LAYOUT_5_0 } }, - { "surround-51", { SPA_AUDIO_LAYOUT_5_1 } }, - { "surround-71", { SPA_AUDIO_LAYOUT_7_1 } }, + { "mono", SPA_AUDIO_LAYOUT_Mono }, + { "stereo", SPA_AUDIO_LAYOUT_Stereo }, + { "surround-21", SPA_AUDIO_LAYOUT_2_1 }, + { "quad", SPA_AUDIO_LAYOUT_Quad }, + { "surround-22", SPA_AUDIO_LAYOUT_2_2 }, + { "surround-40", SPA_AUDIO_LAYOUT_4_0 }, + { "surround-31", SPA_AUDIO_LAYOUT_3_1 }, + { "surround-41", SPA_AUDIO_LAYOUT_4_1 }, + { "surround-50", SPA_AUDIO_LAYOUT_5_0 }, + { "surround-51", SPA_AUDIO_LAYOUT_5_1 }, + { "surround-51r", SPA_AUDIO_LAYOUT_5_1R }, + { "surround-70", SPA_AUDIO_LAYOUT_7_0 }, + { "surround-71", SPA_AUDIO_LAYOUT_7_1 }, }; static unsigned int find_channel(const char *name) @@ -478,8 +483,8 @@ static int parse_channelmap(const char *channelmap, struct channelmap *map) for (i = 0; i < (int) SPA_N_ELEMENTS(maps); i++) { if (strcmp(maps[i].name, channelmap) == 0) { - map->n_channels = maps[i].values[0]; - spa_memcpy(map->channels, &maps[i].values[1], + map->n_channels = maps[i].channels; + spa_memcpy(map->channels, &maps[i].values, map->n_channels * sizeof(unsigned int)); return 0; } @@ -499,6 +504,41 @@ static int parse_channelmap(const char *channelmap, struct channelmap *map) return 0; } +static int channelmap_default(struct channelmap *map, int n_channels) +{ + switch(n_channels) { + case 1: + parse_channelmap("mono", map); + break; + case 2: + parse_channelmap("stereo", map); + break; + case 3: + parse_channelmap("surround-21", map); + break; + case 4: + parse_channelmap("quad", map); + break; + case 5: + parse_channelmap("surround-50", map); + break; + case 6: + parse_channelmap("surround-51", map); + break; + case 7: + parse_channelmap("surround-70", map); + break; + case 8: + parse_channelmap("surround-71", map); + break; + default: + n_channels = 0; + break; + } + map->n_channels = n_channels; + return 0; +} + static void target_destroy(struct target *target) { @@ -1090,18 +1130,19 @@ int main(int argc, char *argv[]) data.channels = data.info.channels; if (data.channelmap.n_channels == 0) { - if (!sf_command(data.file, SFC_GET_CHANNEL_MAP_INFO, + if (sf_command(data.file, SFC_GET_CHANNEL_MAP_INFO, data.channelmap.channels, sizeof(data.channelmap.channels[0]) * data.channels)) { - printf("no channel map, assuming default\n"); - data.channelmap.n_channels = 0; - } else { data.channelmap.n_channels = data.channels; if (channelmap_from_sf(&data.channelmap) < 0) data.channelmap.n_channels = 0; } - if (data.channelmap.n_channels > 0) + if (data.channelmap.n_channels > 0) { printf("got channel map\n"); + } else { + printf("no channel map, assuming default\n"); + channelmap_default(&data.channelmap, data.channels); + } } } data.samplesize = sf_format_samplesize(format); @@ -1230,8 +1271,9 @@ int main(int argc, char *argv[]) info = SPA_AUDIO_INFO_RAW_INIT( .flags = data.channelmap.n_channels ? 0 : SPA_AUDIO_FLAG_UNPOSITIONED, .format = data.spa_format, - .channels = data.channels, - .rate = data.rate); + .rate = data.rate, + .channels = data.channels); + if (data.channelmap.n_channels) memcpy(info.position, data.channelmap.channels, data.channels * sizeof(int)); |