Commit bde0b463 authored by ahoms's avatar ahoms
Browse files

* more progress in buffer management


git-svn-id: https://scm.blissgarden.org/svn/lima/trunk@22 45c4679d-1946-429d-baad-37912b19538b
parent 6aa4df04
......@@ -80,7 +80,7 @@ class BufferCbMgr : public HwFrameCallbackGen
{
public:
enum Cap {
Concat=1, Acc=2,
Basic=0, Concat=1, Acc=2,
};
virtual ~BufferCbMgr();
......@@ -122,12 +122,16 @@ class StdBufferCbMgr : public BufferCbMgr
virtual int getMaxNbBuffers(const FrameDim& frame_dim);
virtual void allocBuffers(int nb_buffers,
const FrameDim& frame_dim);
virtual const FrameDim& getFrameDim() const;
virtual int getNbBuffers() const;
virtual const FrameDim& getFrameDim();
virtual int getNbBuffers();
virtual void releaseBuffers();
virtual void *getBufferPtr(int buffer_nb) const;
virtual Timestamp getBufferTimestamp(int buffer_nb) const;
virtual void *getBufferPtr(int buffer_nb);
virtual void clearBuffer(int buffer_nb);
virtual void clearAllBuffers();
virtual Timestamp getBufferTimestamp(int buffer_nb);
void setStartTimestamp(Timestamp start_ts);
bool newFrameReady(int acq_frame_nr);
......@@ -158,8 +162,11 @@ class StdBufferCbMgr : public BufferCbMgr
class BufferCtrlMgr
{
public:
BufferCtrlMgr(BufferCbMgr *acq_buffer_mgr = NULL);
~BufferCtrlMgr();
void setFrameDim(const FrameDim& frame_dim);
void getFramedim( FrameDim& frame_dim);
void getFrameDim( FrameDim& frame_dim);
void setNbBuffers(int nb_buffers);
void getNbBuffers(int& nb_buffers);
......@@ -181,6 +188,15 @@ class BufferCtrlMgr
void registerFrameCallback(HwFrameCallback *frame_cb);
void unregisterFrameCallback(HwFrameCallback *frame_cb);
BufferCbMgr& getAcqBufferMgr();
private:
BufferCbMgr *m_acq_buffer_mgr;
bool m_int_acq_buffer_mgr;
StdBufferCbMgr m_aux_buffer_mgr;
BufferCbMgr *m_effect_buffer_mgr;
FrameDim m_frame_dim;
};
......
......@@ -144,6 +144,11 @@ StdBufferCbMgr::~StdBufferCbMgr()
delete m_alloc_mgr;
}
BufferCbMgr::Cap StdBufferCbMgr::getCap()
{
return Basic;
}
int StdBufferCbMgr::getMaxNbBuffers(const FrameDim& frame_dim)
{
return m_alloc_mgr->getMaxNbBuffers(frame_dim);
......@@ -202,22 +207,32 @@ bool StdBufferCbMgr::newFrameReady(int acq_frame_nb)
return HwFrameCallbackGen::newFrameReady(frame_info);
}
const FrameDim& StdBufferCbMgr::getFrameDim() const
const FrameDim& StdBufferCbMgr::getFrameDim()
{
return m_alloc_mgr->getFrameDim();
}
int StdBufferCbMgr::getNbBuffers() const
int StdBufferCbMgr::getNbBuffers()
{
return m_alloc_mgr->getNbBuffers();
}
void *StdBufferCbMgr::getBufferPtr(int buffer_nb) const
void *StdBufferCbMgr::getBufferPtr(int buffer_nb)
{
return m_alloc_mgr->getBufferPtr(buffer_nb);
}
Timestamp StdBufferCbMgr::getBufferTimestamp(int buffer_nb) const
void StdBufferCbMgr::clearBuffer(int buffer_nb)
{
m_alloc_mgr->clearBuffer(buffer_nb);
}
void StdBufferCbMgr::clearAllBuffers()
{
m_alloc_mgr->clearAllBuffers();
}
Timestamp StdBufferCbMgr::getBufferTimestamp(int buffer_nb)
{
const Timestamp& ts = m_ts_list[buffer_nb];
if (!ts.isSet())
......@@ -225,3 +240,62 @@ Timestamp StdBufferCbMgr::getBufferTimestamp(int buffer_nb) const
return ts - m_start_ts;
}
/*******************************************************************
* \brief BufferCtrlMgr constructor
*******************************************************************/
BufferCtrlMgr::BufferCtrlMgr(BufferCbMgr *acq_buffer_mgr)
{
m_acq_buffer_mgr = acq_buffer_mgr;
m_int_acq_buffer_mgr = (acq_buffer_mgr == NULL);
if (m_int_acq_buffer_mgr)
m_acq_buffer_mgr = new StdBufferCbMgr();
}
BufferCtrlMgr::~BufferCtrlMgr()
{
if (m_int_acq_buffer_mgr)
delete m_acq_buffer_mgr;
}
void BufferCtrlMgr::setFrameDim(const FrameDim& frame_dim)
{
if (frame_dim != m_frame_dim)
m_acq_buffer_mgr->releaseBuffers();
m_frame_dim = frame_dim;
}
void BufferCtrlMgr::getFrameDim(FrameDim& frame_dim)
{
frame_dim = m_frame_dim;
}
void BufferCtrlMgr::setNbBuffers(int nb_buffers)
{
if (nb_buffers == m_acq_buffer_mgr->getNbBuffers())
return;
m_acq_buffer_mgr->allocBuffers(nb_buffers, m_frame_dim);
}
void BufferCtrlMgr::getNbBuffers(int& nb_buffers)
{
nb_buffers = m_acq_buffer_mgr->getNbBuffers();
}
void BufferCtrlMgr::getMaxNbBuffers(int& max_nb_buffers)
{
max_nb_buffers = m_acq_buffer_mgr->getMaxNbBuffers(m_frame_dim);
}
void BufferCtrlMgr::registerFrameCallback(HwFrameCallback *frame_cb)
{
m_acq_buffer_mgr->registerFrameCallback(frame_cb);
}
void BufferCtrlMgr::unregisterFrameCallback(HwFrameCallback *frame_cb)
{
m_acq_buffer_mgr->unregisterFrameCallback(frame_cb);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment