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
xSemaphore
=
xSemaphoreCreateBinary
();
56
unlock
();
57
}
58
virtual
~MutexRecursiveRTOS
() {
59
vSemaphoreDelete
(
xSemaphore
);
60
}
61
void
lock
()
override
{
62
xSemaphoreTakeRecursive
(
xSemaphore
,
portMAX_DELAY
);
63
}
64
void
unlock
()
override
{
65
xSemaphoreGiveRecursive
(
xSemaphore
);
66
}
67
68
protected
:
69
SemaphoreHandle_t
xSemaphore
=
NULL
;
70
};
71
72
75
using
Mutex
=
MutexRTOS
;
76
77
}
AudioToolsConfig.h
Mutex.h
portMAX_DELAY
#define portMAX_DELAY
Definition
QueueZephyr.h:14
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:38
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:58
audio_tools::MutexRecursiveRTOS::xSemaphore
SemaphoreHandle_t xSemaphore
Definition
MutexRTOS.h:69
audio_tools::MutexRecursiveRTOS::unlock
void unlock() override
Definition
MutexRTOS.h:64
audio_tools::MutexRecursiveRTOS::MutexRecursiveRTOS
MutexRecursiveRTOS()
Definition
MutexRTOS.h:54
audio_tools::MutexRecursiveRTOS::lock
void lock() override
Definition
MutexRTOS.h:61
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:508
Generated by
1.9.8