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,
24 snd_pcm_stream_t direction;
26 const struct xfer_ops *ops;
29 char *sample_format_literal;
30 char *cntr_format_literal;
32 unsigned int frames_per_second;
33 unsigned int samples_per_frame;
35 bool multiple_cntrs:1; // For mapper.
37 snd_pcm_format_t sample_format;
41 unsigned int path_count;
42 enum container_format cntr_format;
45 enum xfer_type xfer_type_from_label(const char *label);
47 int xfer_context_init(struct xfer_context *xfer, enum xfer_type type,
48 snd_pcm_stream_t direction, int argc, char *const *argv);
49 void xfer_context_destroy(struct xfer_context *xfer);
50 int xfer_context_pre_process(struct xfer_context *xfer,
51 snd_pcm_format_t *format,
52 unsigned int *samples_per_frame,
53 unsigned int *frames_per_second,
54 snd_pcm_access_t *access,
55 snd_pcm_uframes_t *frames_per_buffer);
56 int xfer_context_process_frames(struct xfer_context *xfer,
57 struct mapper_context *mapper,
58 struct container_context *cntrs,
59 unsigned int *frame_count);
60 void xfer_context_pause(struct xfer_context *xfer, bool enable);
61 void xfer_context_post_process(struct xfer_context *xfer);
64 int xfer_options_parse_args(struct xfer_context *xfer,
65 const struct xfer_data *data, int argc,
67 int xfer_options_fixup_paths(struct xfer_context *xfer);
69 // For internal use in 'xfer' module.
72 int (*init)(struct xfer_context *xfer, snd_pcm_stream_t direction);
73 int (*parse_opt)(struct xfer_context *xfer, int key, const char *optarg);
74 int (*validate_opts)(struct xfer_context *xfer);
75 int (*pre_process)(struct xfer_context *xfer, snd_pcm_format_t *format,
76 unsigned int *samples_per_frame,
77 unsigned int *frames_per_second,
78 snd_pcm_access_t *access,
79 snd_pcm_uframes_t *frames_per_buffer);
80 int (*process_frames)(struct xfer_context *xfer,
81 unsigned int *frame_count,
82 struct mapper_context *mapper,
83 struct container_context *cntrs);
84 void (*post_process)(struct xfer_context *xfer);
85 void (*destroy)(struct xfer_context *xfer);
86 void (*pause)(struct xfer_context *xfer, bool enable);
91 const struct option *l_opts;
92 unsigned int l_opts_count;
94 unsigned int private_size;
97 extern const struct xfer_data xfer_alsa;