aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/vasp/source/vbuffer.cpp
blob: 137e066c1add7c2bcbaf6e06cf0cfe2a53fa7ee9 (plain)
1
2
3
4
5
6
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
#include "vbuffer.h"
#include "buflib.h"

V VSymbol::Inc() { if(sym) BufLib::IncRef(sym); }
V VSymbol::Dec() { if(sym) BufLib::DecRef(sym); }

///////////////////////////////////////////////////////////////////////////
// SysBuf class
///////////////////////////////////////////////////////////////////////////

SysBuf &SysBuf::Set(const VSymbol &s,I c,I l,I o)
{
	buf.Set(s.Symbol());

	chn = c;
	if(chn > Channels()) {
		I chn1 = Channels()-1;
		post("vasp - buffer %s: Channel index (%i) is out of range, set to highest (%i)",s.Name(),chn,chn1);
		chn = chn1; // simply correct the channel??
	}
	offs = o;
	if(offs < 0) {
		post("vasp - buffer %s: Offset (%i) is out of range, set to 0",s.Name(),offs);
		offs = 0;
	}
	if(offs > Frames()) {
//		post("vasp - buffer %s: Offset (%i) is out of range, set to %i",s.Name(),offs,Frames());
		offs = Frames();
	}
	len = l >= 0?l:Frames();
	if(offs+len > Frames()) {
		I len1 = Frames()-offs;
		if(l >= 0) post("vasp - buffer %s: Length (%i) is out of range, corrected to %i",s.Name(),len,len1);
		len = len1;
	}

	return *this;
}