Skip to content

Commit 0689bfa

Browse files
committed
SnapConfig for RTOS
1 parent 2bf3dc5 commit 0689bfa

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/SnapConfig.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,12 @@
5454
#ifndef CONFIG_WIFI_PASSWORD
5555
# define CONFIG_WIFI_PASSWORD "12341234"
5656
#endif
57+
58+
// FreeRTOS - max number of entries in the queue
59+
#ifndef RTOS_MAX_QUEUE_ENTRY_COUNT
60+
# define RTOS_MAX_QUEUE_ENTRY_COUNT 200
61+
#endif
62+
63+
#ifndef RTOS_STACK_SIZE
64+
# define RTOS_STACK_SIZE 10 * 1024
65+
#endif

src/api/SnapProcessorRTOS.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
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
*/
913
class 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

Comments
 (0)