Developer World
Spresense SDK Library v3.3.0-375c679
al_workercomp.h
1#ifndef __INCLUDE_AUDIOLITE_WORKERCOMP_H
2#define __INCLUDE_AUDIOLITE_WORKERCOMP_H
3
4/****************************************************************************
5 * Included Files
6 ****************************************************************************/
7
8#include <audiolite/al_component.h>
9#include <audiolite/al_worker.h>
10#include <audiolite/al_thread.h>
11
12/****************************************************************************
13 * Pre-processor Definitions
14 ****************************************************************************/
15
16#define WORKERCOMP_SPKNAMESZ (32)
17
18/****************************************************************************
19 * Class Pre-definitions
20 ****************************************************************************/
21
23
24/****************************************************************************
25 * Class Definitions
26 ****************************************************************************/
27
29{
30 public:
31 virtual void bootup(audiolite_workercomp *wcomp, al_wtask_t *wtask,
32 int version, void *d)
33 {
34 };
35
36 virtual void error(audiolite_workercomp *wcomp, al_wtask_t *wtask,
37 int id, int ercode)
38 {
39 };
40
41 virtual void debug(audiolite_workercomp *wcomp, al_wtask_t *wtask,
42 int code)
43 {
44 };
45
46 virtual void info(audiolite_workercomp *wcomp, al_wtask_t *wtask,
47 int id, int chs, int fs, int layer, int rate)
48 {
49 };
50
51 virtual void done(audiolite_workercomp *wcomp, al_wtask_t *wtask,
52 int id)
53 {
54 };
55
56 virtual void term(audiolite_workercomp *wcomp)
57 {
58 };
59
60 virtual audiolite_memapbuf *release_inmem(audiolite_workercomp *wcomp,
61 al_wtask_t *wtask,
63 int size)
64 {
65 return NULL;
66 };
67
68 virtual audiolite_memapbuf *release_outmem(audiolite_workercomp *wcomp,
69 al_wtask_t *wtask,
71 {
72 push_data(wcomp, mem);
73 return NULL;
74 };
75
76 virtual void usermsg(audiolite_workercomp *wcomp, al_wtask_t *wtask,
78 {
79 };
80
81 void push_data(audiolite_workercomp *wcomp, audiolite_memapbuf *mem);
82 int get_inqsize(audiolite_workercomp *wcomp);
83 int get_outqsize(audiolite_workercomp *wcomp);
85};
86
88{
89 protected:
90 char _workerspk[WORKERCOMP_SPKNAMESZ];
91 audiolite_worker _worker;
94 bool _worker_booted;
95 bool _worker_terminated;
98
99 static int handle_message(al_comm_msghdr_t hdr,
100 al_comm_msgopt_t *opt, void *arg);
101
102 int start_worker();
103 void stop_worker();
104
105 public:
106 audiolite_workercomp(const char *workername,
107 int inqsz,
108 int outqsz,
109 int inputnum = 1,
110 int outputnum = 1,
111 int depth = 16,
112 int prio = 105,
113 int stack_sz = 2048);
114
115 virtual ~audiolite_workercomp();
116
117 void set_msglistener(audiolite_stdworker_msglistener *lsnr)
118 {
119 _lsnr = lsnr;
120 }
121
122 /* Inherited methods from audiolite_component */
123
124 virtual void on_data();
125 virtual int on_starting(audiolite_inputnode *inode,
126 audiolite_outputnode *onode);
127 virtual void on_canceled(audiolite_inputnode *inode,
128 audiolite_outputnode *onode);
129 virtual void on_stopping(audiolite_inputnode *inode,
130 audiolite_outputnode *onode);
131
132 /* Inherited methods from audiolite_stdworker_msglistener */
133
134 virtual bool before_start(void *arg);
135 virtual int run(void *arg);
136 virtual void before_stop(void *arg);
137
139};
140
141#endif /* __INCLUDE_AUDIOLITE_WORKERCOMP_H */
Definition: al_component.h:58
Definition: al_inputnode.h:71
Definition: al_memalloc.h:156
Definition: al_outputnode.h:65
Definition: al_thread.h:21
Definition: al_workercomp.h:29
Definition: al_thread.h:47
Definition: al_worker.h:101
Definition: al_workercomp.h:88
Definition: al_worker.h:74
Definition: alworker_comm.h:183
Definition: alworker_comm.h:133
Definition: alworker_comm.h:146