arduino-audio-tools
Loading...
Searching...
No Matches
MutexRTOS.h
1#pragma once
2#include "AudioToolsConfig.h"
3#include "AudioTools/Concurrency/Mutex.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
22class MutexRTOS : public MutexBase {
23public:
24 MutexRTOS() {
25 xSemaphore = xSemaphoreCreateBinary();
26 xSemaphoreGive(xSemaphore);
27 }
28 virtual ~MutexRTOS() {
29 vSemaphoreDelete(xSemaphore);
30 }
31 void lock() override {
32 xSemaphoreTake(xSemaphore, portMAX_DELAY);
33 }
34 void unlock() override {
35 xSemaphoreGive(xSemaphore);
36 }
37
38protected:
39 SemaphoreHandle_t xSemaphore = NULL;
40};
41
42using Mutex = MutexRTOS;
43
44}
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:37
Mutex implemntation using FreeRTOS.
Definition MutexRTOS.h:22
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition AudioCodecsBase.h:10