Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Files Functions Variables Typedefs Macros Groups
AuxTaskRT.h
1 /***** AuxTaskRT.h *****/
2 #ifndef __Aux_Task_RT_H_INCLUDED__
3 #define __Aux_Task_RT_H_INCLUDED__
4 
5 #include <Bela.h>
6 
7 #ifdef XENOMAI_SKIN_native
8 #include <rtdk.h>
9 #include <native/task.h>
10 #include <native/queue.h>
11 #endif
12 
13 #ifdef XENOMAI_SKIN_posix
14 #include <fcntl.h> /* For O_* constants */
15 #include <sys/stat.h> /* For mode constants */
16 #include <pthread.h>
17 #include <mqueue.h>
18 #endif
19 
20 #define AUX_RT_POOL_SIZE 500000
21 
22 class AuxTaskRT{
23  public:
24  AuxTaskRT(){}
25 
26  void create(const char* _name, void(*_callback)(), int _priority = BELA_AUDIO_PRIORITY-5);
27  void create(const char* _name, void(*_callback)(const char* str), int _priority = BELA_AUDIO_PRIORITY-5);
28  void create(const char* _name, void(*_callback)(void* buf, int size), int _priority = BELA_AUDIO_PRIORITY-5);
29  void create(const char* _name, void(*_callback)(void* ptr), void* _pointer, int _priority = BELA_AUDIO_PRIORITY-5);
30 
31  void schedule(void* buf, size_t size);
32  void schedule(const char* str);
33  void schedule();
34 
35  void cleanup();
36 
37  private:
38 #ifdef XENOMAI_SKIN_native
39  RT_TASK task;
40  RT_QUEUE queue;
41 #endif
42 #ifdef XENOMAI_SKIN_posix
43  pthread_t thread;
44  mqd_t queueDesc;
45  char queueName [100];
46 #endif
47 
48  const char* name;
49  int priority;
50  int mode;
51  void* pointer;
52 
53  void __create();
54 
55  void (*empty_callback)();
56  void (*str_callback)(const char* buffer);
57  void (*buf_callback)(void* buf, int size);
58  void (*ptr_callback)(void* ptr);
59 
60  void empty_loop();
61  void str_loop();
62  void buf_loop();
63  void ptr_loop();
64 
65  static void loop(void* ptr);
66 };
67 
68 #endif
#define BELA_AUDIO_PRIORITY
Definition: Bela.h:93
Definition: AuxTaskRT.h:22
Main Bela public API.