summaryrefslogtreecommitdiff
path: root/src/tests/lo-test-util.h
blob: a6b0cde6962068dbd0fb0517c2aa3c509c9fc650 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/***
  This file is part of PulseAudio.

  Copyright 2013 Collabora Ltd.
  Author: Arun Raghavan <arun.raghavan@collabora.co.uk>

  PulseAudio is free software; you can redistribute it and/or modify
  it under the terms of the GNU Lesser General Public License as published
  by the Free Software Foundation; either version 2.1 of the License,
  or (at your option) any later version.

  PulseAudio is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  General Public License for more details.

  You should have received a copy of the GNU Lesser General Public License
  along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
***/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <pulse/pulseaudio.h>

typedef struct pa_lo_test_context {
    /* Tests need to set these */
    const char *context_name;

    pa_sample_spec sample_spec;
    int play_latency; /* ms */
    int rec_latency; /* ms */

    pa_stream_request_cb_t write_cb, read_cb;

    /* These are set by lo_test_init() */
    pa_mainloop *mainloop;
    pa_context *context;

    pa_stream *play_stream, *rec_stream;

    int ss, fs; /* sample size, frame size for convenience */
} pa_lo_test_context;

/* Initialise the test parameters, connect */
int pa_lo_test_init(pa_lo_test_context *ctx);
/* Start running the test */
int pa_lo_test_run(pa_lo_test_context *ctx);
/* Clean up */
void pa_lo_test_deinit(pa_lo_test_context *ctx);

/* Return RMS for the given signal. Assumes the data is a single channel for
 * simplicity */
float pa_rms(const float *s, int n);