arduino-audio-tools
All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Modules Pages
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#else
9# include "FreeRTOS.h"
10# include "semphr.h"
11#endif
12
13namespace audio_tools {
14
21class MutexRTOS : public MutexBase {
22public:
23 MutexRTOS() {
24 xSemaphore = xSemaphoreCreateBinary();
25 xSemaphoreGive(xSemaphore);
26 }
27 virtual ~MutexRTOS() {
28 vSemaphoreDelete(xSemaphore);
29 }
30 void lock() override {
31 xSemaphoreTake(xSemaphore, portMAX_DELAY);
32 }
33 void unlock() override {
34 xSemaphoreGive(xSemaphore);
35 }
36
37protected:
38 SemaphoreHandle_t xSemaphore = NULL;
39};
40
41using Mutex = MutexRTOS;
42
43}
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:21
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition AudioCodecsBase.h:10