arduino-audio-tools
Loading...
Searching...
No Matches
src
AudioTools
Concurrency
RTOS
MutexRTOS.h
Go to the documentation of this file.
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
14
namespace
audio_tools
{
15
25
class
MutexRTOS
:
public
MutexBase
{
26
public
:
27
MutexRTOS
() {
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
41
protected
:
42
SemaphoreHandle_t
xSemaphore
= NULL;
43
};
44
52
class
MutexRecursiveRTOS
:
public
MutexBase
{
53
public
:
54
MutexRecursiveRTOS
() {
55
// the recursive take/give functions need a recursive mutex: with a
56
// binary semaphore the first lock() would block forever
57
xSemaphore
= xSemaphoreCreateRecursiveMutex();
58
}
59
virtual
~MutexRecursiveRTOS
() {
60
vSemaphoreDelete(
xSemaphore
);
61
}
62
void
lock
()
override
{
63
xSemaphoreTakeRecursive(
xSemaphore
,
portMAX_DELAY
);
64
}
65
void
unlock
()
override
{
66
xSemaphoreGiveRecursive(
xSemaphore
);
67
}
68
69
protected
:
70
SemaphoreHandle_t
xSemaphore
= NULL;
71
};
72
73
76
using
Mutex
=
MutexRTOS
;
77
80
using
MutexRecursive
=
MutexRecursiveRTOS
;
81
82
83
}
AudioToolsConfig.h
portMAX_DELAY
#define portMAX_DELAY
Definition
BufferBlocking.h:14
Mutex.h
audio_tools::MutexBase
Empty Mutex implementation which does nothing.
Definition
Mutex.h:15
audio_tools::MutexRTOS
Mutex implemntation using FreeRTOS.
Definition
MutexRTOS.h:25
audio_tools::MutexRTOS::xSemaphore
SemaphoreHandle_t xSemaphore
Definition
MutexRTOS.h:42
audio_tools::MutexRTOS::unlock
void unlock() override
Definition
MutexRTOS.h:37
audio_tools::MutexRTOS::~MutexRTOS
virtual ~MutexRTOS()
Definition
MutexRTOS.h:31
audio_tools::MutexRTOS::MutexRTOS
MutexRTOS()
Definition
MutexRTOS.h:27
audio_tools::MutexRTOS::lock
void lock() override
Definition
MutexRTOS.h:34
audio_tools::MutexRecursiveRTOS
Recursive Mutex implemntation using FreeRTOS.
Definition
MutexRTOS.h:52
audio_tools::MutexRecursiveRTOS::~MutexRecursiveRTOS
virtual ~MutexRecursiveRTOS()
Definition
MutexRTOS.h:59
audio_tools::MutexRecursiveRTOS::xSemaphore
SemaphoreHandle_t xSemaphore
Definition
MutexRTOS.h:70
audio_tools::MutexRecursiveRTOS::unlock
void unlock() override
Definition
MutexRTOS.h:65
audio_tools::MutexRecursiveRTOS::MutexRecursiveRTOS
MutexRecursiveRTOS()
Definition
MutexRTOS.h:54
audio_tools::MutexRecursiveRTOS::lock
void lock() override
Definition
MutexRTOS.h:62
audio_tools::StdMutex
Mutex implemntation based on std::mutex.
Definition
Mutex.h:16
audio_tools::StdRecursiveMutex
Mutex implemntation based on std::mutex.
Definition
Mutex.h:31
audio_tools
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition
LMSEchoCancellationStream.h:6
Generated by
1.9.8