1 // SPDX-License-Identifier: GPL-2.0
3 // xfer.h - a header for receiver/transmiter of data frames.
5 // Copyright (c) 2018 Takashi Sakamoto <o-takashi@sakamocchi.jp>
7 // Licensed under the terms of the GNU General Public License, version 2.
9 #ifndef __ALSA_UTILS_AXFER_XFER__H_
10 #define __ALSA_UTILS_AXFER_XFER__H_
17 XFER_TYPE_UNSUPPORTED = -1,
18 XFER_TYPE_LIBASOUND = 0,
25 snd_pcm_stream_t direction;
27 const struct xfer_ops *ops;
30 char *sample_format_literal;
31 char *cntr_format_literal;
33 unsigned int frames_per_second;
34 unsigned int samples_per_frame;
36 bool multiple_cntrs:1; // For mapper.
38 snd_pcm_format_t sample_format;
42 unsigned int path_count;
43 enum container_format cntr_format;
46 enum xfer_type xfer_type_from_label(const char *label);
48 int xfer_context_init(struct xfer_context *xfer, enum xfer_type type,
49 snd_pcm_stream_t direction, int argc, char *const *argv);
50 void xfer_context_destroy(struct xfer_context *xfer);
51 int xfer_context_pre_process(struct xfer_context *xfer,
52 snd_pcm_format_t *format,
53 unsigned int *samples_per_frame,
54 unsigned int *frames_per_second,
55 snd_pcm_access_t *access,
56 snd_pcm_uframes_t *frames_per_buffer);
57 int xfer_context_process_frames(struct xfer_context *xfer,
58 struct mapper_context *mapper,
59 struct container_context *cntrs,
60 unsigned int *frame_count);
61 void xfer_context_pause(struct xfer_context *xfer, bool enable);
62 void xfer_context_post_process(struct xfer_context *xfer);
65 int xfer_options_parse_args(struct xfer_context *xfer,
66 const struct xfer_data *data, int argc,
68 int xfer_options_fixup_paths(struct xfer_context *xfer);
70 // For internal use in 'xfer' module.
73 int (*init)(struct xfer_context *xfer, snd_pcm_stream_t direction);
74 int (*parse_opt)(struct xfer_context *xfer, int key, const char *optarg);
75 int (*validate_opts)(struct xfer_context *xfer);
76 int (*pre_process)(struct xfer_context *xfer, snd_pcm_format_t *format,
77 unsigned int *samples_per_frame,
78 unsigned int *frames_per_second,
79 snd_pcm_access_t *access,
80 snd_pcm_uframes_t *frames_per_buffer);
81 int (*process_frames)(struct xfer_context *xfer,
82 unsigned int *frame_count,
83 struct mapper_context *mapper,
84 struct container_context *cntrs);
85 void (*post_process)(struct xfer_context *xfer);
86 void (*destroy)(struct xfer_context *xfer);
87 void (*pause)(struct xfer_context *xfer, bool enable);
92 const struct option *l_opts;
93 unsigned int l_opts_count;
95 unsigned int private_size;
98 extern const struct xfer_data xfer_libasound;