3
3
#include " freertos-all.h" // https://github.com/pschatzmann/arduino-freertos-addons
4
4
5
5
/* *
6
- * Processor for which the encoded output is buffered in a queue in order to
6
+ * @brief Processor for which the encoded output is buffered in a queue in order to
7
7
* prevent any buffer underruns. A RTOS task feeds the output from the queue.
8
+ * @author Phil Schatzmann
9
+ * @version 0.1
10
+ * @date 2024-02-26
11
+ * @copyright Copyright (c) 2023
8
12
*/
9
13
class SnapProcessorRTOS : public SnapProcessor {
10
14
public:
@@ -37,14 +41,14 @@ class SnapProcessorRTOS : public SnapProcessor {
37
41
38
42
protected:
39
43
const char *TAG = " SnapProcessorRTOS" ;
40
- const uint16_t TASK_STACK_SIZE = 10 * 1024 ;
41
- cpp_freertos::Task task{" output" , TASK_STACK_SIZE, 1 , task_copy};
42
- cpp_freertos::Queue size_queue{200 , sizeof (size_t )};
43
- audio_tools::SynchronizedBufferRTOS<uint8_t > buffer{0 };
44
+ cpp_freertos::Task task{" output" , RTOS_STACK_SIZE, 1 , task_copy};
45
+ cpp_freertos::Queue size_queue{RTOS_MAX_QUEUE_ENTRY_COUNT, sizeof (size_t )};
46
+ audio_tools::SynchronizedBufferRTOS<uint8_t > buffer{0 }; // size defined in constructor
44
47
bool task_started = false ;
45
48
int active_percent;
46
49
static SnapProcessorRTOS *self;
47
50
51
+ // / store parameters provided by constructor
48
52
void init_rtos (int buffer_size, int activationAtPercent) {
49
53
self = this ;
50
54
active_percent = activationAtPercent;
@@ -69,6 +73,7 @@ class SnapProcessorRTOS : public SnapProcessor {
69
73
ESP_LOGW (TAG, " size_queue full" );
70
74
return 0 ;
71
75
}
76
+
72
77
size_t size_written = buffer.writeArray (data, size);
73
78
if (size_written != size) {
74
79
ESP_LOGE (TAG, " buffer-overflow" );
0 commit comments