- cleaned up
- use Block bypass to create idle frames git-svn-id: http://moon:8086/svn/software/trunk/libsrc/cpp@1075 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+13
-24
@@ -27,7 +27,7 @@ Formatter::Formatter()
|
||||
m_frame.preamble.data[1] = ~(m_frame.preamble.data[0]);
|
||||
}
|
||||
|
||||
void Formatter::process_data(uint8_t *pData, uint32_t len)
|
||||
void Formatter::process_data()
|
||||
{
|
||||
if (m_idleCount)
|
||||
{
|
||||
@@ -36,15 +36,12 @@ void Formatter::process_data(uint8_t *pData, uint32_t len)
|
||||
m_idleCount = 0;
|
||||
}
|
||||
|
||||
size_t remain = len;
|
||||
while(remain)
|
||||
while(m_buf_in->len())
|
||||
{
|
||||
size_t frame_remain = FRAME_NUM_BYTES_PER_FRAME - m_dataCount;
|
||||
size_t to_write = std::min(remain, frame_remain);
|
||||
memcpy(&m_frame.data[m_dataCount], pData, to_write);
|
||||
size_t to_write = std::min(m_buf_in->len(), frame_remain);
|
||||
m_buf_in->read(&m_frame.data[m_dataCount], to_write);
|
||||
m_dataCount += to_write;
|
||||
remain -= to_write;
|
||||
pData += to_write;
|
||||
|
||||
if (m_dataCount == FRAME_NUM_BYTES_PER_FRAME)
|
||||
{
|
||||
@@ -55,7 +52,7 @@ void Formatter::process_data(uint8_t *pData, uint32_t len)
|
||||
}
|
||||
}
|
||||
|
||||
void Formatter::process_idle(uint32_t len)
|
||||
void Formatter::process_idle(size_t len)
|
||||
{
|
||||
if (m_dataCount)
|
||||
{
|
||||
@@ -82,20 +79,6 @@ void Formatter::process_idle(uint32_t len)
|
||||
}
|
||||
}
|
||||
|
||||
void Formatter::process(void *pData, uint32_t len)
|
||||
{
|
||||
if (pData)
|
||||
{
|
||||
// Data available: Process data
|
||||
process_data((uint8_t*)pData, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Data not available: Process Idle
|
||||
process_idle(len);
|
||||
}
|
||||
}
|
||||
|
||||
void Formatter::prepare()
|
||||
{
|
||||
// Get buffers
|
||||
@@ -106,8 +89,14 @@ void Formatter::prepare()
|
||||
void Formatter::process()
|
||||
{
|
||||
// Process input
|
||||
while(m_buf_in->len())
|
||||
if (is_bypass())
|
||||
{
|
||||
process_idle(m_buf_in->len());
|
||||
m_buf_in->consume(m_buf_in->len());
|
||||
}
|
||||
else
|
||||
{
|
||||
process_data();
|
||||
size_t frame_remain = FRAME_NUM_BYTES_PER_FRAME - m_dataCount;
|
||||
size_t to_write = std::min(m_buf_in->len(), frame_remain);
|
||||
m_buf_in->read(&m_frame.data[m_dataCount], to_write);
|
||||
@@ -132,7 +121,7 @@ void Formatter::resetStats()
|
||||
memset(&m_frameStats, 0, sizeof(frame_statistics_t));
|
||||
}
|
||||
|
||||
void Formatter::commit(frame_type frameType, uint32_t dataCount)
|
||||
void Formatter::commit(frame_type frameType, size_t dataCount)
|
||||
{
|
||||
// Commit frame
|
||||
m_frame.hdr.length = (uint16_t)dataCount;
|
||||
|
||||
+5
-6
@@ -14,7 +14,6 @@ class Formatter : public Processor::Block
|
||||
public:
|
||||
Formatter();
|
||||
virtual ~Formatter() = default;
|
||||
void process(void *pData, uint32_t len);
|
||||
frame_statistics_t getStats();
|
||||
void resetStats();
|
||||
|
||||
@@ -25,16 +24,16 @@ public:
|
||||
private:
|
||||
Scrambler m_scrambler;
|
||||
frame_t m_frame;
|
||||
uint32_t m_dataCount;
|
||||
uint32_t m_idleCount;
|
||||
size_t m_dataCount;
|
||||
size_t m_idleCount;
|
||||
frame_statistics_t m_frameStats;
|
||||
Processor::Buffer<uint8_t> *m_buf_in;
|
||||
Processor::Buffer<uint8_t> *m_buf_out;
|
||||
|
||||
void process_idle(uint32_t len);
|
||||
void process_data(uint8_t *pData, uint32_t len);
|
||||
void process_idle(size_t len);
|
||||
void process_data();
|
||||
|
||||
void commit(frame_type frameType, uint32_t m_dataCount);
|
||||
void commit(frame_type frameType, size_t m_dataCount);
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user