summaryrefslogtreecommitdiff
path: root/cras/src/server/cras_mix_ops.h
blob: 1fac6f3efb60b3e27f4461c77b021190f0d69cea (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
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef CRAS_MIX_OPS_H_
#define CRAS_MIX_OPS_H_

#include <stdint.h>

#include "cras_system_state.h"

extern const struct cras_mix_ops mixer_ops;
extern const struct cras_mix_ops mixer_ops_sse42;
extern const struct cras_mix_ops mixer_ops_avx;
extern const struct cras_mix_ops mixer_ops_avx2;
extern const struct cras_mix_ops mixer_ops_fma;

/* Struct containing ops to implement mix/scale on a buffer of samples.
 * Different architecture can provide different implementations and wraps
 * the implementations into cras_mix_ops.
 * Different sample formats will be handled by different implementations.
 * The usage of each operation is explained in cras_mix.h
 *
 * Members:
 *   scale_buffer_increment: See cras_scale_buffer_increment.
 *   scale_buffer: See cras_scale_buffer.
 *   add: See cras_mix_add.
 *   add_scale_stride: See cras_mix_add_scale_stride.
 *   mute_buffer: cras_mix_mute_buffer.
 */
struct cras_mix_ops {
	void (*scale_buffer_increment)(snd_pcm_format_t fmt, uint8_t *buff,
				       unsigned int count, float scaler,
				       float increment, float target, int step);
	void (*scale_buffer)(snd_pcm_format_t fmt, uint8_t *buff,
			     unsigned int count, float scaler);
	void (*add)(snd_pcm_format_t fmt, uint8_t *dst, uint8_t *src,
		    unsigned int count, unsigned int index, int mute,
		    float mix_vol);
	void (*add_scale_stride)(snd_pcm_format_t fmt, uint8_t *dst,
				 uint8_t *src, unsigned int count,
				 unsigned int dst_stride,
				 unsigned int src_stride, float scaler);
	size_t (*mute_buffer)(uint8_t *dst, size_t frame_bytes, size_t count);
};
#endif