- removed IFormatter
git-svn-id: http://moon:8086/svn/software/trunk/libsrc/cpp@1070 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+14
-10
@@ -11,12 +11,13 @@
|
||||
// --------------------------------------------------------------
|
||||
// Formatter
|
||||
// --------------------------------------------------------------
|
||||
Formatter::Formatter(IFormatter *pFrameHandler)
|
||||
Formatter::Formatter()
|
||||
: Processor::Block(1, 1)
|
||||
, m_scrambler(FRAME_SCRAMBLER_SEED, FRAME_SCRAMBLER_POLY)
|
||||
, m_pFrameHandler(pFrameHandler)
|
||||
, m_dataCount(0)
|
||||
, m_idleCount(0)
|
||||
, m_buf_in(nullptr)
|
||||
, m_buf_out(nullptr)
|
||||
{
|
||||
resetStats();
|
||||
memset(&m_frame, 0, sizeof(frame_t));
|
||||
@@ -95,18 +96,21 @@ void Formatter::process(void *pData, uint32_t len)
|
||||
}
|
||||
}
|
||||
|
||||
void Formatter::process()
|
||||
void Formatter::prepare()
|
||||
{
|
||||
// Get buffers
|
||||
auto buf_in = buffer_in<uint8_t>();
|
||||
// auto buf_out = buffer_out<uint8_t>();
|
||||
|
||||
m_buf_in = buffer_in<uint8_t>();
|
||||
m_buf_out = buffer_out<uint8_t>();
|
||||
}
|
||||
|
||||
void Formatter::process()
|
||||
{
|
||||
// Process input
|
||||
while(buf_in->len())
|
||||
while(m_buf_in->len())
|
||||
{
|
||||
size_t frame_remain = FRAME_NUM_BYTES_PER_FRAME - m_dataCount;
|
||||
size_t to_write = std::min(buf_in->len(), frame_remain);
|
||||
buf_in->read(&m_frame.data[m_dataCount], 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;
|
||||
|
||||
if (m_dataCount == FRAME_NUM_BYTES_PER_FRAME)
|
||||
@@ -141,7 +145,7 @@ void Formatter::commit(frame_type frameType, uint32_t dataCount)
|
||||
m_scrambler.process((uint8_t*)&m_frame.hdr.length, sizeof(m_frame.hdr.length));
|
||||
m_scrambler.process(m_frame.data, FRAME_NUM_BYTES_PER_FRAME);
|
||||
|
||||
m_pFrameHandler->onFrame((void*)&m_frame, sizeof(frame_t));
|
||||
m_buf_out->write((uint8_t*)&m_frame, sizeof(frame_t));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user