2 This file is part of PulseAudio.
4 PulseAudio is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published
6 by the Free Software Foundation; either version 2.1 of the License,
7 or (at your option) any later version.
9 PulseAudio is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with PulseAudio; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
26 #include <pulse/sample.h>
27 #include <pulse/volume.h>
29 #include <pulsecore/resampler.h>
30 #include <pulsecore/macro.h>
31 #include <pulsecore/endianmacros.h>
32 #include <pulsecore/memblock.h>
33 #include <pulsecore/sample-util.h>
35 #include <liboil/liboil.h>
37 int main(int argc
, char *argv
[]) {
39 static const pa_channel_map maps
[] = {
40 { 1, { PA_CHANNEL_POSITION_MONO
} },
41 { 2, { PA_CHANNEL_POSITION_LEFT
, PA_CHANNEL_POSITION_RIGHT
} },
42 { 3, { PA_CHANNEL_POSITION_LEFT
, PA_CHANNEL_POSITION_RIGHT
, PA_CHANNEL_POSITION_CENTER
} },
43 { 3, { PA_CHANNEL_POSITION_LEFT
, PA_CHANNEL_POSITION_RIGHT
, PA_CHANNEL_POSITION_LFE
} },
44 { 3, { PA_CHANNEL_POSITION_LEFT
, PA_CHANNEL_POSITION_RIGHT
, PA_CHANNEL_POSITION_REAR_CENTER
} },
45 { 4, { PA_CHANNEL_POSITION_LEFT
, PA_CHANNEL_POSITION_RIGHT
, PA_CHANNEL_POSITION_CENTER
, PA_CHANNEL_POSITION_LFE
} },
46 { 4, { PA_CHANNEL_POSITION_LEFT
, PA_CHANNEL_POSITION_RIGHT
, PA_CHANNEL_POSITION_CENTER
, PA_CHANNEL_POSITION_REAR_CENTER
} },
47 { 4, { PA_CHANNEL_POSITION_LEFT
, PA_CHANNEL_POSITION_RIGHT
, PA_CHANNEL_POSITION_REAR_LEFT
, PA_CHANNEL_POSITION_REAR_RIGHT
} },
48 { 5, { PA_CHANNEL_POSITION_LEFT
, PA_CHANNEL_POSITION_RIGHT
, PA_CHANNEL_POSITION_REAR_LEFT
, PA_CHANNEL_POSITION_REAR_RIGHT
, PA_CHANNEL_POSITION_CENTER
} },
49 { 5, { PA_CHANNEL_POSITION_LEFT
, PA_CHANNEL_POSITION_RIGHT
, PA_CHANNEL_POSITION_REAR_LEFT
, PA_CHANNEL_POSITION_REAR_RIGHT
, PA_CHANNEL_POSITION_LFE
} },
50 { 6, { PA_CHANNEL_POSITION_LEFT
, PA_CHANNEL_POSITION_RIGHT
, PA_CHANNEL_POSITION_REAR_LEFT
, PA_CHANNEL_POSITION_REAR_RIGHT
, PA_CHANNEL_POSITION_LFE
, PA_CHANNEL_POSITION_CENTER
} },
51 { 8, { PA_CHANNEL_POSITION_LEFT
, PA_CHANNEL_POSITION_RIGHT
, PA_CHANNEL_POSITION_REAR_LEFT
, PA_CHANNEL_POSITION_REAR_RIGHT
, PA_CHANNEL_POSITION_LFE
, PA_CHANNEL_POSITION_CENTER
, PA_CHANNEL_POSITION_SIDE_LEFT
, PA_CHANNEL_POSITION_SIDE_RIGHT
} },
59 pa_log_set_level(PA_LOG_DEBUG
);
61 pa_assert_se(pool
= pa_mempool_new(FALSE
, 0));
63 for (i
= 0; maps
[i
].channels
> 0; i
++)
64 for (j
= 0; maps
[j
].channels
> 0; j
++) {
65 char a
[PA_CHANNEL_MAP_SNPRINT_MAX
], b
[PA_CHANNEL_MAP_SNPRINT_MAX
];
67 pa_sample_spec ss1
, ss2
;
69 pa_log_info("Converting from '%s' to '%s'.\n", pa_channel_map_snprint(a
, sizeof(a
), &maps
[i
]), pa_channel_map_snprint(b
, sizeof(b
), &maps
[j
]));
71 ss1
.channels
= maps
[i
].channels
;
72 ss2
.channels
= maps
[j
].channels
;
74 ss1
.rate
= ss2
.rate
= 44100;
75 ss1
.format
= ss2
.format
= PA_SAMPLE_S16NE
;
77 r
= pa_resampler_new(pool
, &ss1
, &maps
[i
], &ss2
, &maps
[j
], PA_RESAMPLER_AUTO
, 0);
79 /* We don't really care for the resampler. We just want to
80 * see the remixing debug output. */
86 pa_mempool_free(pool
);