File: buffer.h

package info (click to toggle)
libdvbpsi 1.3.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 3,632 kB
  • sloc: ansic: 19,087; makefile: 252; xml: 100; sh: 93
file content (62 lines) | stat: -rw-r--r-- 2,243 bytes parent folder | download | duplicates (4)
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
/*****************************************************************************
 * buffer.h: buffer management
 *****************************************************************************
 * Copyright (C) 2011 M2X BV
 *
 * Authors: Jean-Paul Saman <jpsaman@videolan.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *****************************************************************************/

#ifndef DVBINFO_BUFFER_H_
#define DVBINFO_BUFFER_H_

typedef struct buffer_s buffer_t;

struct buffer_s
{
    size_t   i_size;    /* size of buffer data */
    mtime_t  i_date;    /* timestamp */
    buffer_t *p_next;   /* pointer to next buffer_t */
    uint8_t  *p_data;   /* actuall buffer data */
};

typedef struct fifo_s fifo_t;

/* Buffer management:
 * buffer_new()  - create new buffer of size i_size + plus header structure
 * buffer_free() - free buffer
 */
buffer_t *buffer_new(size_t i_size);
void buffer_free(buffer_t *buffer);

/* Fifo:
 * fifo_new()  - create a new fifo holding buffer_t pointers
 * fifo_free() - release fifo and all buffers contained therein
 * fifo_count()- number of buffers in fifo_t
 * fifo_size() - total size of buffers in fifo_t
 * fifo_push() - push buffer at end of fifo
 * fifo_pop()  - pop buffer from start of fifo
 * fifo_wake() - wake up fifo listeners
 */
fifo_t *fifo_new(void);
void fifo_free(fifo_t *fifo);
ssize_t fifo_count(fifo_t *fifo);
size_t fifo_size(fifo_t *fifo);
void fifo_push(fifo_t *fifo, buffer_t *buffer);
buffer_t *fifo_pop(fifo_t *fifo);
void fifo_wake(fifo_t *fifo);

#endif