OSDN Git Service

axfer: add support for MMAP PCM operation
[android-x86/external-alsa-utils.git] / axfer / xfer-libasound.h
1 // SPDX-License-Identifier: GPL-2.0
2 //
3 // xfer-libasound.h - a header for receiver/transmitter of frames by alsa-lib.
4 //
5 // Copyright (c) 2018 Takashi Sakamoto <o-takashi@sakamocchi.jp>
6 //
7 // Licensed under the terms of the GNU General Public License, version 2.
8
9 #ifndef __ALSA_UTILS_AXFER_XFER_LIBASOUND__H_
10 #define __ALSA_UTILS_AXFER_XFER_LIBASOUND__H_
11
12 #include "xfer.h"
13
14 #define logging(state, ...) \
15         snd_output_printf(state->log, __VA_ARGS__)
16
17 struct xfer_libasound_ops;
18
19 struct libasound_state {
20         snd_pcm_t *handle;
21
22         snd_output_t *log;
23         snd_pcm_hw_params_t *hw_params;
24         snd_pcm_sw_params_t *sw_params;
25
26         const struct xfer_libasound_ops *ops;
27         void *private_data;
28
29         bool verbose;
30
31         char *node_literal;
32
33         bool finish_at_xrun:1;
34         bool nonblock:1;
35         bool mmap:1;
36 };
37
38 // For internal use in 'libasound' module.
39
40 struct xfer_libasound_ops {
41         int (*pre_process)(struct libasound_state *state);
42         int (*process_frames)(struct libasound_state *state,
43                               unsigned int *frame_count,
44                               struct mapper_context *mapper,
45                               struct container_context *cntrs);
46         void (*post_process)(struct libasound_state *state);
47         unsigned int private_size;
48 };
49
50 extern const struct xfer_libasound_ops xfer_libasound_irq_rw_ops;
51
52 extern const struct xfer_libasound_ops xfer_libasound_irq_mmap_r_ops;
53 extern const struct xfer_libasound_ops xfer_libasound_irq_mmap_w_ops;
54
55 #endif