summaryrefslogtreecommitdiffstats
path: root/bufferq.h
blob: a6453985eaa5a81b47322c412176d8e2cd5405b3 (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
#ifndef foosydneybufferqhfoo
#define foosydneybufferqhfoo

#include <inttypes.h>

#include "macro.h"
#include "llist.h"
#include "sydney.h"

typedef struct sa_bufferq_item {
    int64_t idx;
    size_t size;
    SA_LLIST_ITEM(struct sa_bufferq_item, bufferq);
} sa_bufferq_item_t;

#define SA_BUFFERQ_ITEM_DATA(x) ((void*) (uint8_t*) (x) + ALIGN(sizeof(sa_bufferq_item_t)))

typedef struct sa_bufferq {
    SA_LLIST_HEAD(sa_bufferq_item_t, *items);
    sa_bufferq_item_t **last;
    int64_t read_index, write_index, end_index;
    size_t sample_size;
    unsigned nchannels;
} sa_bufferq_t;

int sa_bufferq_init(sa_bufferq_t *q, unsigned nchannels, size_t sample_size);

void sa_bufferq_done(sa_bufferq_t *q);

int sa_bufferq_push(sa_bufferq_t *q, unsigned channel, const void *data, size_t nbytes, int64_t offset, sa_seek_t whence);

int sa_bufferq_get(sa_bufferq_t *q, void *i[], size_t *bytes);
int sa_bufferq_drop(sa_bufferq_t *q, int64_t bytes);

#endif