Add support for frame resizing. Handle old stream frame type in encoder.

master
Rob Riggs 2021-07-08 19:50:54 -05:00
rodzic 5398bc0be1
commit fc7a25c92a
3 zmienionych plików z 24 dodań i 2 usunięć

Wyświetl plik

@ -101,6 +101,7 @@ public:
}
uint16_t size() const {return data_.size();}
bool resize(uint16_t size) {return data_.resize(size);}
uint16_t crc() const {return crc_;}
uint16_t fcs() const {return fcs_;}
@ -170,12 +171,10 @@ public:
free_list_.pop_front();
}
taskEXIT_CRITICAL_FROM_ISR(x);
DEBUG("Acquired frame %p (size after = %d)", result, free_list_.size());
return result;
}
void release(frame_type* frame) {
DEBUG("Released frame %p (size before = %d)", frame, free_list_.size());
frame->clear();
auto x = taskENTER_CRITICAL_FROM_ISR();
free_list_.push_back(*frame);

Wyświetl plik

@ -224,6 +224,12 @@ void M17Encoder::process_stream(tnc::hdlc::IoFrame* frame, FrameType type)
{
send_stream(frame, type); // Consumes frame.
}
else if (frame->size() == 26)
{
// Old-style frame with trailing CRC.
frame->resize(24);
send_stream(frame, type);
}
else
{
WARN("Unexpected AUDIO frame size = %u", frame->size());

Wyświetl plik

@ -81,6 +81,23 @@ struct SegmentedBuffer {
uint16_t size() const {return size_;}
bool resize(uint16_t size)
{
if (size <= size_)
{
size_ = size;
}
else
{
for (;size_ != size;)
{
if (!push_back(value_type()))
return false;
}
}
return true;
}
bool push_back(value_type value) {
uint16_t offset = size_ & 0xFF;
if (offset == 0) { // Must allocate.