-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMPEGlist.cpp
More file actions
60 lines (51 loc) · 882 Bytes
/
MPEGlist.cpp
File metadata and controls
60 lines (51 loc) · 882 Bytes
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
#include "MPEGlist.h"
MPEGlist::MPEGlist()
{
size = 0;
data = 0;
lock = 0;
next = 0;
prev = 0;
TimeStamp = -1;
}
MPEGlist::~MPEGlist()
{
if(next) next->prev = prev;
if(prev) prev->next = next;
if(data)
{
delete[] data;
data = 0;
}
}
/* Return the next free buffer or allocate a new one if none is empty */
MPEGlist * MPEGlist::Alloc(Uint32 Buffer_Size)
{
MPEGlist * tmp;
tmp = next;
next = new MPEGlist;
next->next = tmp;
if ( Buffer_Size ) {
next->data = new Uint8[Buffer_Size];
if(!next->data)
{
//fprintf(stderr, "Alloc : Not enough memory\n");
return(0);
}
} else {
next->data = 0;
}
next->size = Buffer_Size;
next->prev = this;
return(next);
}
/* Lock current buffer */
void MPEGlist::Lock()
{
lock++;
}
/* Unlock current buffer */
void MPEGlist::Unlock()
{
if(lock != 0) lock--;
}