~binli/ubuntu/vivid/pulseaudio/load-extcon-module

« back to all changes in this revision

Viewing changes to .pc/0303-lfe-filter-change-the-crossover-frequency-as-a-param.patch/src/tests/remix-test.c

  • Committer: Bin Li
  • Date: 2016-01-23 15:04:48 UTC
  • Revision ID: bin.li@canonical.com-20160123150448-5ockvw4p5xxntda4
init the 1:6.0-0ubuntu9.15 from silo 12

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***
 
2
  This file is part of PulseAudio.
 
3
 
 
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.
 
8
 
 
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.
 
13
 
 
14
  You should have received a copy of the GNU Lesser General Public License
 
15
  along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
 
16
***/
 
17
 
 
18
#ifdef HAVE_CONFIG_H
 
19
#include <config.h>
 
20
#endif
 
21
 
 
22
#include <stdio.h>
 
23
 
 
24
#include <pulse/sample.h>
 
25
 
 
26
#include <pulsecore/resampler.h>
 
27
#include <pulsecore/macro.h>
 
28
#include <pulsecore/memblock.h>
 
29
 
 
30
int main(int argc, char *argv[]) {
 
31
 
 
32
    static const pa_channel_map maps[] = {
 
33
        { 1, { PA_CHANNEL_POSITION_MONO } },
 
34
        { 2, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT } },
 
35
        { 3, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT, PA_CHANNEL_POSITION_CENTER } },
 
36
        { 3, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT, PA_CHANNEL_POSITION_LFE } },
 
37
        { 3, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT, PA_CHANNEL_POSITION_REAR_CENTER } },
 
38
        { 4, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT, PA_CHANNEL_POSITION_CENTER, PA_CHANNEL_POSITION_LFE } },
 
39
        { 4, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT, PA_CHANNEL_POSITION_CENTER, PA_CHANNEL_POSITION_REAR_CENTER } },
 
40
        { 4, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT, PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT } },
 
41
        { 5, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT, PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT, PA_CHANNEL_POSITION_CENTER } },
 
42
        { 5, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT, PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT, PA_CHANNEL_POSITION_LFE } },
 
43
        { 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 } },
 
44
        { 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 } },
 
45
        { 0, { 0 } }
 
46
    };
 
47
 
 
48
    unsigned i, j;
 
49
    pa_mempool *pool;
 
50
 
 
51
    pa_log_set_level(PA_LOG_DEBUG);
 
52
 
 
53
    pa_assert_se(pool = pa_mempool_new(false, 0));
 
54
 
 
55
    for (i = 0; maps[i].channels > 0; i++)
 
56
        for (j = 0; maps[j].channels > 0; j++) {
 
57
            char a[PA_CHANNEL_MAP_SNPRINT_MAX], b[PA_CHANNEL_MAP_SNPRINT_MAX];
 
58
            pa_resampler *r;
 
59
            pa_sample_spec ss1, ss2;
 
60
 
 
61
            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]));
 
62
 
 
63
            ss1.channels = maps[i].channels;
 
64
            ss2.channels = maps[j].channels;
 
65
 
 
66
            ss1.rate = ss2.rate = 44100;
 
67
            ss1.format = ss2.format = PA_SAMPLE_S16NE;
 
68
 
 
69
            r = pa_resampler_new(pool, &ss1, &maps[i], &ss2, &maps[j], PA_RESAMPLER_AUTO, 0);
 
70
 
 
71
            /* We don't really care for the resampler. We just want to
 
72
             * see the remixing debug output. */
 
73
 
 
74
            pa_resampler_free(r);
 
75
        }
 
76
 
 
77
    pa_mempool_free(pool);
 
78
 
 
79
    return 0;
 
80
}