1 /* PipeWire
2 *
3 * Copyright © 2021 Wim Taymans <wim.taymans@gmail.com>
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25 #include "echo-cancel.h"
26
27 struct impl {
28 uint32_t channels;
29 };
30
null_create(const struct pw_properties * args,const struct spa_audio_info_raw * info)31 static void *null_create(const struct pw_properties *args, const struct spa_audio_info_raw *info)
32 {
33 struct impl *impl;
34 impl = calloc(1, sizeof(struct impl));
35 impl->channels = info->channels;
36 return impl;
37 }
38
null_destroy(void * ec)39 static void null_destroy(void *ec)
40 {
41 free(ec);
42 }
43
null_run(void * ec,const float * rec[],const float * play[],float * out[],uint32_t n_samples)44 static int null_run(void *ec, const float *rec[], const float *play[], float *out[], uint32_t n_samples)
45 {
46 struct impl *impl = ec;
47 uint32_t i;
48 for (i = 0; i < impl->channels; i++)
49 memcpy(out[i], rec[i], n_samples * sizeof(float));
50 return 0;
51 }
52
53 static const struct echo_cancel_info echo_cancel_null_impl = {
54 .name = "null",
55 .info = SPA_DICT_INIT(NULL, 0),
56 .latency = NULL,
57
58 .create = null_create,
59 .destroy = null_destroy,
60
61 .run = null_run,
62 };
63
64 const struct echo_cancel_info *echo_cancel_null = &echo_cancel_null_impl;
65