File: MPEGlist.cpp

package info (click to toggle)
smpeg 0.4.4-8
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,892 kB
  • ctags: 1,445
  • sloc: cpp: 14,948; sh: 8,962; ansic: 2,323; asm: 542; makefile: 162
file content (60 lines) | stat: -rw-r--r-- 878 bytes parent folder | download
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--;
}