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
|
#ifndef _XAS_AUDIO_H
#define _XAS_AUDIO_H
#include <stdint.h>
#include <sys/types.h>
#define XAS_AUDIO_STREAM_PCM_8_BIT 1
#define XAS_AUDIO_STREAM_PCM_16_BIT 2
#define XAS_AUDIO_STREAM_MONO 1
#define XAS_AUDIO_STREAM_STEREO 2
enum xas_audio_stream_type {
XAS_AUDIO_STREAM_SINK,
XAS_AUDIO_STREAM_SOURCE
};
typedef struct _xas_audio_stream xas_audio_stream;
typedef ssize_t (*xas_audio_drain)(void *ctx,
void *samples,
size_t count,
xas_audio_stream *stream);
typedef ssize_t (*xas_audio_fill)(void *ctx,
void *samples,
size_t count,
xas_audio_stream *stream);
typedef void (*xas_audio_cleanup)(void *ctx,
xas_audio_stream *stream);
struct _xas_audio_stream {
enum xas_audio_stream_type type;
size_t sample_size,
sample_rate,
channels;
size_t buffer_size,
buffer_count;
union {
void *callback;
xas_audio_drain drain;
xas_audio_fill fill;
};
xas_audio_cleanup cleanup;
void *ctx;
};
xas_audio_stream *xas_audio_stream_new_sink(xas_audio_drain drain,
xas_audio_cleanup cleanup,
void *ctx,
size_t sample_size,
size_t sample_rate,
size_t channels,
size_t buffer_size);
xas_audio_stream *xas_audio_stream_new_source(xas_audio_fill fill,
xas_audio_cleanup cleanup,
void *ctx,
size_t sample_size,
size_t sample_rate,
size_t channels,
size_t buffer_size);
void xas_audio_stream_destroy(xas_audio_stream *stream);
ssize_t xas_audio_stream_write(xas_audio_stream *stream,
void *samples,
size_t count);
ssize_t xas_audio_stream_read(xas_audio_stream *stream,
void **samples,
size_t count);
int xas_audio_stream_flush(xas_audio_stream *stream);
#endif /* _XAS_AUDIO_H */
|