Skip to content

Commit fc7a25c

Browse files
committed
Add support for frame resizing. Handle old stream frame type in encoder.
1 parent 5398bc0 commit fc7a25c

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

TNC/HdlcFrame.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class Frame : public list_base_hook<>
101101
}
102102

103103
uint16_t size() const {return data_.size();}
104+
bool resize(uint16_t size) {return data_.resize(size);}
104105

105106
uint16_t crc() const {return crc_;}
106107
uint16_t fcs() const {return fcs_;}
@@ -170,12 +171,10 @@ class FramePool
170171
free_list_.pop_front();
171172
}
172173
taskEXIT_CRITICAL_FROM_ISR(x);
173-
DEBUG("Acquired frame %p (size after = %d)", result, free_list_.size());
174174
return result;
175175
}
176176

177177
void release(frame_type* frame) {
178-
DEBUG("Released frame %p (size before = %d)", frame, free_list_.size());
179178
frame->clear();
180179
auto x = taskENTER_CRITICAL_FROM_ISR();
181180
free_list_.push_back(*frame);

TNC/M17Encoder.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,12 @@ void M17Encoder::process_stream(tnc::hdlc::IoFrame* frame, FrameType type)
224224
{
225225
send_stream(frame, type); // Consumes frame.
226226
}
227+
else if (frame->size() == 26)
228+
{
229+
// Old-style frame with trailing CRC.
230+
frame->resize(24);
231+
send_stream(frame, type);
232+
}
227233
else
228234
{
229235
WARN("Unexpected AUDIO frame size = %u", frame->size());

TNC/SegmentedBuffer.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,23 @@ struct SegmentedBuffer {
8181

8282
uint16_t size() const {return size_;}
8383

84+
bool resize(uint16_t size)
85+
{
86+
if (size <= size_)
87+
{
88+
size_ = size;
89+
}
90+
else
91+
{
92+
for (;size_ != size;)
93+
{
94+
if (!push_back(value_type()))
95+
return false;
96+
}
97+
}
98+
return true;
99+
}
100+
84101
bool push_back(value_type value) {
85102
uint16_t offset = size_ & 0xFF;
86103
if (offset == 0) { // Must allocate.

0 commit comments

Comments
 (0)