kopia lustrzana https://github.com/mobilinkd/tnc3-firmware
Add support for frame resizing. Handle old stream frame type in encoder.
rodzic
70a6ab22f6
commit
f35e38a92f
|
@ -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_;}
|
||||
|
|
|
@ -225,6 +225,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());
|
||||
|
|
|
@ -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.
|
||||
|
|
Ładowanie…
Reference in New Issue