33#include " freertos-all.h" // https://github.com/pschatzmann/arduino-freertos-addons
44
55/* *
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
77 * 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
812 */
913class SnapProcessorRTOS : public SnapProcessor {
1014 public:
@@ -37,14 +41,14 @@ class SnapProcessorRTOS : public SnapProcessor {
3741
3842 protected:
3943 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
4447 bool task_started = false ;
4548 int active_percent;
4649 static SnapProcessorRTOS *self;
4750
51+ // / store parameters provided by constructor
4852 void init_rtos (int buffer_size, int activationAtPercent) {
4953 self = this ;
5054 active_percent = activationAtPercent;
@@ -69,6 +73,7 @@ class SnapProcessorRTOS : public SnapProcessor {
6973 ESP_LOGW (TAG, " size_queue full" );
7074 return 0 ;
7175 }
76+
7277 size_t size_written = buffer.writeArray (data, size);
7378 if (size_written != size) {
7479 ESP_LOGE (TAG, " buffer-overflow" );
0 commit comments