ITAStreamingSourceRealization.cpp 1.66 KB
Newer Older
Jonas Stienen's avatar
Jonas Stienen committed
1
2
3
4
5
// $Id: ITADatasourceRealization.cpp,v 1.4 2008-09-02 08:53:35 fwefers Exp $

#include <ITAStreamingSourceRealization.h>

#include <assert.h>
6
#include <limits>
Jonas Stienen's avatar
Jonas Stienen committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

static const long STREAM_POS_INIT( std::numeric_limits< long >::max() );

ITAStreamingSourceRealization::ITAStreamingSourceRealization(const ITAStreamingProperties& oProps)
	: m_oStreamProps( oProps ),
	  m_oOutputBuffer( oProps.iNumChannels, oProps.iBlockLength, false),
	  m_pEventHandler(nullptr)
{
	assert( oProps.IsValid() );
	Reset();
}

ITAStreamingSourceRealization::~ITAStreamingSourceRealization() {}

void ITAStreamingSourceRealization::Reset() {
	m_iStreamPos = STREAM_POS_INIT;	// Used for comparisons
	m_oOutputBuffer.zero();
}	

ITAStreamDatasourceRealizationEventHandler* ITAStreamingSourceRealization::GetStreamEventHandler() const {
	return m_pEventHandler;
}

void ITAStreamingSourceRealization::SetStreamEventHandler(ITAStreamDatasourceRealizationEventHandler* pHandler) {
	m_pEventHandler = pHandler;
}

ITASampleFrame& ITAStreamingSourceRealization::GetStreamOutputBuffer()
{
	return m_oOutputBuffer;
}

const ITASampleFrame& ITAStreamingSourceRealization::GetStreamData(const ITAStreamingState& oState) {
	// Update check
	if (m_iStreamPos != oState.nSamples) {
		assert( (m_iStreamPos < oState.nSamples) || (m_iStreamPos == STREAM_POS_INIT) ); // Monotony

		// Order: Hook first, handler second
		ProcessStreamData(oState);
		if (m_pEventHandler) m_pEventHandler->HandleProcessStreamData(this, oState);

		m_iStreamPos = oState.nSamples;
	}

	return GetStreamOutputBuffer();
}

void ITAStreamDatasourceRealizationEventHandler::HandleProcessStreamData(ITAStreamingSourceRealization*, const ITAStreamingState&) {}