OSDN Git Service

axfer: add support for a mapper for single target
[android-x86/external-alsa-utils.git] / axfer / mapper.h
1 // SPDX-License-Identifier: GPL-2.0
2 //
3 // mapper.h - an interface of muxer/demuxer between buffer with data frames and
4 //            formatted files.
5 //
6 // Copyright (c) 2018 Takashi Sakamoto <o-takashi@sakamocchi.jp>
7 //
8 // Licensed under the terms of the GNU General Public License, version 2.
9
10 #ifndef __ALSA_UTILS_AXFER_MAPPER__H_
11 #define __ALSA_UTILS_AXFER_MAPPER__H_
12
13 #include "container.h"
14
15 enum mapper_type {
16         MAPPER_TYPE_MUXER = 0,
17         MAPPER_TYPE_DEMUXER,
18         MAPPER_TYPE_COUNT,
19 };
20
21 enum mapper_target {
22         MAPPER_TARGET_SINGLE = 0,
23         MAPPER_TARGET_COUNT,
24 };
25
26 struct mapper_ops;
27
28 struct mapper_context {
29         enum mapper_type type;
30         enum mapper_target target;
31         const struct mapper_ops *ops;
32         unsigned int private_size;
33
34         void *private_data;
35         unsigned int cntr_count;
36
37         // A part of parameters of PCM substream.
38         snd_pcm_access_t access;
39         unsigned int bytes_per_sample;
40         unsigned int samples_per_frame;
41         snd_pcm_uframes_t frames_per_buffer;
42
43         unsigned int verbose;
44 };
45
46 int mapper_context_init(struct mapper_context *mapper,
47                         enum mapper_type type, unsigned int cntr_count,
48                         unsigned int verbose);
49 int mapper_context_pre_process(struct mapper_context *mapper,
50                                snd_pcm_access_t access,
51                                unsigned int bytes_per_sample,
52                                unsigned int samples_per_frame,
53                                unsigned int frames_per_buffer,
54                                struct container_context *cntrs);
55 int mapper_context_process_frames(struct mapper_context *mapper,
56                                   void *frame_buffer,
57                                   unsigned int *frame_count,
58                                   struct container_context *cntrs);
59 void mapper_context_post_process(struct mapper_context *mapper);
60 void mapper_context_destroy(struct mapper_context *mapper);
61
62 // For internal use in 'mapper' module.
63
64 struct mapper_ops {
65         int (*pre_process)(struct mapper_context *mapper,
66                            struct container_context *cntrs,
67                            unsigned int cntr_count);
68         int (*process_frames)(struct mapper_context *mapper,
69                               void *frame_buffer, unsigned int *frame_count,
70                               struct container_context *cntrs,
71                               unsigned int cntr_count);
72         void (*post_process)(struct mapper_context *mapper);
73 };
74
75 struct mapper_data {
76         struct mapper_ops ops;
77         unsigned int private_size;
78 };
79
80 extern const struct mapper_data mapper_muxer_single;
81 extern const struct mapper_data mapper_demuxer_single;
82
83 #endif