arduino-audio-tools
Loading...
Searching...
No Matches
MutexRTOS.h
Go to the documentation of this file.
1#pragma once
2#include "AudioToolsConfig.h"
4
5#ifdef ESP32
6# include "freertos/FreeRTOS.h"
7# include "freertos/semphr.h"
8#elif defined(__linux__)
9#else
10# include "FreeRTOS.h"
11# include "semphr.h"
12#endif
13
14namespace audio_tools {
15
25class MutexRTOS : public MutexBase {
26public:
28 xSemaphore = xSemaphoreCreateBinary();
29 unlock();
30 }
31 virtual ~MutexRTOS() {
32 vSemaphoreDelete(xSemaphore);
33 }
34 void lock() override {
35 xSemaphoreTake(xSemaphore, portMAX_DELAY);
36 }
37 void unlock() override {
38 xSemaphoreGive(xSemaphore);
39 }
40
41protected:
42 SemaphoreHandle_t xSemaphore = NULL;
43};
44
53public:
55 xSemaphore = xSemaphoreCreateBinary();
56 unlock();
57 }
59 vSemaphoreDelete(xSemaphore);
60 }
61 void lock() override {
62 xSemaphoreTakeRecursive(xSemaphore, portMAX_DELAY);
63 }
64 void unlock() override {
65 xSemaphoreGiveRecursive(xSemaphore);
66 }
67
68protected:
69 SemaphoreHandle_t xSemaphore = NULL;
70};
71
72
75using Mutex = MutexRTOS;
76
77}
#define portMAX_DELAY
Definition QueueZephyr.h:14
Empty Mutex implementation which does nothing.
Definition Mutex.h:18
Mutex API for non IRQ mutual exclusion between cores. Mutexes are application level locks usually use...
Definition MutexRP2040.h:38
Mutex implemntation using FreeRTOS.
Definition MutexRTOS.h:25
SemaphoreHandle_t xSemaphore
Definition MutexRTOS.h:42
void unlock() override
Definition MutexRTOS.h:37
virtual ~MutexRTOS()
Definition MutexRTOS.h:31
MutexRTOS()
Definition MutexRTOS.h:27
void lock() override
Definition MutexRTOS.h:34
Recursive Mutex implemntation using FreeRTOS.
Definition MutexRTOS.h:52
virtual ~MutexRecursiveRTOS()
Definition MutexRTOS.h:58
SemaphoreHandle_t xSemaphore
Definition MutexRTOS.h:69
void unlock() override
Definition MutexRTOS.h:64
MutexRecursiveRTOS()
Definition MutexRTOS.h:54
void lock() override
Definition MutexRTOS.h:61
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition LMSEchoCancellationStream.h:6