arduino-audio-tools
MutexRTOS.h
1 #pragma once
2 #include "AudioConfig.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 
13 namespace audio_tools {
14 
21 class MutexRTOS : public MutexBase {
22 public:
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 
37 protected:
38  SemaphoreHandle_t xSemaphore = NULL;
39 };
40 
41 using 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: AudioConfig.h:872