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
22
class
MutexRTOS
:
public
MutexBase
{
23
public
:
24
MutexRTOS
() {
25
xSemaphore
=
xSemaphoreCreateBinary
();
26
unlock
();
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
38
protected
:
39
SemaphoreHandle_t
xSemaphore
=
NULL
;
40
};
41
49
class
MutexRecursiveRTOS
:
public
MutexBase
{
50
public
:
51
MutexRecursiveRTOS
() {
52
xSemaphore
=
xSemaphoreCreateBinary
();
53
unlock
();
54
}
55
virtual
~MutexRecursiveRTOS
() {
56
vSemaphoreDelete
(
xSemaphore
);
57
}
58
void
lock
()
override
{
59
xSemaphoreTakeRecursive
(
xSemaphore
,
portMAX_DELAY
);
60
}
61
void
unlock
()
override
{
62
xSemaphoreGiveRecursive
(
xSemaphore
);
63
}
64
65
protected
:
66
SemaphoreHandle_t
xSemaphore
=
NULL
;
67
};
68
69
72
using
Mutex
=
MutexRTOS
;
73
74
}
AudioToolsConfig.h
Mutex.h
audio_tools::MutexBase
Empty Mutex implementation which does nothing.
Definition
Mutex.h:18
audio_tools::MutexRP2040
Mutex API for non IRQ mutual exclusion between cores. Mutexes are application level locks usually use...
Definition
MutexRP2040.h:35
audio_tools::MutexRTOS
Mutex implemntation using FreeRTOS.
Definition
MutexRTOS.h:22
audio_tools::MutexRTOS::xSemaphore
SemaphoreHandle_t xSemaphore
Definition
MutexRTOS.h:39
audio_tools::MutexRTOS::unlock
void unlock() override
Definition
MutexRTOS.h:34
audio_tools::MutexRTOS::~MutexRTOS
virtual ~MutexRTOS()
Definition
MutexRTOS.h:28
audio_tools::MutexRTOS::MutexRTOS
MutexRTOS()
Definition
MutexRTOS.h:24
audio_tools::MutexRTOS::lock
void lock() override
Definition
MutexRTOS.h:31
audio_tools::MutexRecursiveRTOS
Recursive Mutex implemntation using FreeRTOS.
Definition
MutexRTOS.h:49
audio_tools::MutexRecursiveRTOS::~MutexRecursiveRTOS
virtual ~MutexRecursiveRTOS()
Definition
MutexRTOS.h:55
audio_tools::MutexRecursiveRTOS::xSemaphore
SemaphoreHandle_t xSemaphore
Definition
MutexRTOS.h:66
audio_tools::MutexRecursiveRTOS::unlock
void unlock() override
Definition
MutexRTOS.h:61
audio_tools::MutexRecursiveRTOS::MutexRecursiveRTOS
MutexRecursiveRTOS()
Definition
MutexRTOS.h:51
audio_tools::MutexRecursiveRTOS::lock
void lock() override
Definition
MutexRTOS.h:58
audio_tools
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition
AudioCodecsBase.h:10
audio_tools::writeData
size_t writeData(Print *p_out, T *data, int samples, int maxSamples=512)
Definition
AudioTypes.h:512
Generated by
1.9.8