EspiaBufferMgr.cpp 2.26 KB
Newer Older
1
2
#include "EspiaBufferMgr.h"
#include "MemUtils.h"
3
#include <sstream>
4
5
6
7
8
9
10
11
12

using namespace lima;
using namespace lima::Espia;
using namespace std;


BufferMgr::BufferMgr(Acq& acq) 
	: m_acq(acq), m_frame_cb(*this)
{
13
14
15
	DEB_CONSTRUCTOR();
       
	Dev& dev = acq.getDev();
16
	DEB_PARAM() << DEB_VAR1(dev.getDevNb());
17
18
19
20
21
22
23

	ostringstream os;
	if (dev.isMeta())
		os << "MetaBufferMgr";
	else
		os << "BufferMgr#" << dev.getDevNb();
	DEB_SET_OBJ_NAME(os.str());
24
25
26
27
}

BufferMgr::~BufferMgr() 
{
28
	DEB_DESTRUCTOR();
29
30
31
32
33
34
35
}

BufferMgr::Cap BufferMgr::getCap()
{
	return Basic | Concat;
}

36
37
int BufferMgr::getMaxNbBuffers(const FrameDim& frame_dim,
			       int nb_concat_frames)
38
{
39
	DEB_MEMBER_FUNCT();
40
	DEB_PARAM() << DEB_VAR2(frame_dim, nb_concat_frames);
41

42
43
	FrameDim buffer_frame_dim;
	getBufferFrameDim(frame_dim, nb_concat_frames, buffer_frame_dim);
44
	DEB_TRACE() << DEB_VAR1(buffer_frame_dim);
45
46

	int max_nb_buffers = GetDefMaxNbBuffers(buffer_frame_dim);
47
	DEB_RETURN() << DEB_VAR1(max_nb_buffers);
48
	return max_nb_buffers;
49
50
}

51
void BufferMgr::allocBuffers(int nb_buffers, int nb_concat_frames, 
52
53
			     const FrameDim& frame_dim)
{
54
	DEB_MEMBER_FUNCT();
55
	m_acq.bufferAlloc(nb_buffers, nb_concat_frames, frame_dim);
56
57
58
59
}

const FrameDim& BufferMgr::getFrameDim()
{
60
	DEB_MEMBER_FUNCT();
61
62
63
64
65
	return m_acq.getFrameDim();
}

void BufferMgr::getNbBuffers(int& nb_buffers)
{
66
	DEB_MEMBER_FUNCT();
67
68
69
70
71
	m_acq.getNbBuffers(nb_buffers);
}

void BufferMgr::getNbConcatFrames(int& nb_concat_frames)
{
72
	DEB_MEMBER_FUNCT();
73
74
75
76
77
	m_acq.getNbBufferFrames(nb_concat_frames);
}

void BufferMgr::releaseBuffers()
{
78
	DEB_MEMBER_FUNCT();
79
80
81
82
83
	m_acq.bufferFree();
}

void *BufferMgr::getBufferPtr(int buffer_nb, int concat_frame_nb)
{
84
	DEB_MEMBER_FUNCT();
85
86
87
88
89
	return m_acq.getBufferFramePtr(buffer_nb, concat_frame_nb);
}

void BufferMgr::getFrameInfo(int acq_frame_nb, HwFrameInfoType& info)
{
90
	DEB_MEMBER_FUNCT();
91
92
93
94
95
	m_acq.getFrameInfo(acq_frame_nb, info);
}

void BufferMgr::setStartTimestamp(Timestamp  start_ts)
{
96
	DEB_MEMBER_FUNCT();
97
98
99
100
}

void BufferMgr::getStartTimestamp(Timestamp& start_ts)
{
101
	DEB_MEMBER_FUNCT();
102
103
104
105
106
	m_acq.getStartTimestamp(start_ts);
}

void BufferMgr::setFrameCallbackActive(bool cb_active)
{
107
	DEB_MEMBER_FUNCT();
108
	DEB_PARAM() << DEB_VAR1(cb_active);
109

110
111
112
113
114
115
	if (cb_active)
		m_acq.registerFrameCallback(m_frame_cb);
	else
		m_acq.unregisterFrameCallback(m_frame_cb);
}