Skip to content

Commit 4d76eab

Browse files
authored
Merge pull request #37 from MartinMueller2003/master
Added the ability to adjust the ring buffer dynamically
2 parents cb730aa + f4511fd commit 4d76eab

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

ESPAsyncE131.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ const byte ESPAsyncE131::ACN_ID[12] = { 0x41, 0x53, 0x43, 0x2d, 0x45, 0x31, 0x2e
2727
ESPAsyncE131::ESPAsyncE131(uint8_t buffers) {
2828

2929
pbuff = nullptr;
30-
if (buffers)
31-
{
32-
pbuff = RingBuf_new (sizeof (e131_packet_t), buffers);
33-
}
30+
setBuffers(buffers);
3431

3532
stats.num_packets = 0;
3633
stats.packet_errors = 0;
@@ -67,6 +64,20 @@ bool ESPAsyncE131::begin (e131_listen_t type, ESPAsyncE131PortId UdpPortId, uint
6764
//
6865
/////////////////////////////////////////////////////////
6966

67+
void ESPAsyncE131::setBuffers(uint8_t buffers)
68+
{
69+
if(pbuff)
70+
{
71+
RingBuf_delete(pbuff);
72+
pbuff = nullptr;
73+
}
74+
75+
if (buffers)
76+
{
77+
pbuff = RingBuf_new (sizeof (e131_packet_t), buffers);
78+
}
79+
} // setBuffers
80+
7081
bool ESPAsyncE131::initUnicast() {
7182
bool success = false;
7283
delay(100);

ESPAsyncE131.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ class ESPAsyncE131 {
177177

178178
// Diag functions
179179
void dumpError(e131_error_t error);
180+
void setBuffers(uint8_t buffers);
180181
};
181182

182183
#endif // ESPASYNCE131_H_

0 commit comments

Comments
 (0)