AeLoopAsset.c++
1.86 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*****************************************************************************
* File: AeLoopAsset.c++
*
* AeLoopAsset Class Implementations
*
****************************************************************************/
#include <assert.h>
#include <stdlib.h>
#include "AeAsset.h"
#include "GList.h"
AeLoopAsset::AeLoopAsset (const char * name, int start, int end, int count)
: AeAsset (name, kLoopType)
{
fStart = start;
fEnd = end;
fCount = count;
}
AeLoopAsset::~AeLoopAsset()
{
if (fParentList)
{
AeAsset * parent;
int i;
// nullify any references to this asset
fParentList->Start (i, kReverse);
while (fParentList->Prev (i, parent))
{
if (((AeWaveAsset *)parent)->GetLoop () == this)
((AeWaveAsset *)parent)->SetLoop (NULL);
}
}
}
////////////////////////////////////////
//
// ADPCM Loop Class
//
////////////////////////////////////////
AeADPCMLoopAsset::AeADPCMLoopAsset (const char * name,
int start, int end, int count,
int stateSize, short * stateArray)
: AeLoopAsset (name, start, end, count)
{
fStateSize = 0;
fStateArray = NULL;
if (stateSize && stateArray)
SetStateData (fStateSize, stateArray);
}
AeADPCMLoopAsset::~AeADPCMLoopAsset()
{
if (fStateArray)
free (fStateArray);
}
void
AeADPCMLoopAsset::SetStateData (int stateSize, short * stateArray)
{
int i;
assert (stateSize);
assert (stateArray != NULL);
if (stateSize != fStateSize)
{
void * ptr;
fStateSize = stateSize;
if ((ptr = realloc (fStateArray, fStateSize * sizeof(short))) != NULL)
fStateArray = (short *)ptr;
}
for (i=0; i<fStateSize; i++)
fStateArray[i] = stateArray[i];
}
void
AeADPCMLoopAsset::GetStateData (int & stateSize, short * stateArray)
{
int i;
stateSize = fStateSize;
for (i=0; i<fStateSize; i++)
stateArray[i] = fStateArray[i];
}