summaryrefslogtreecommitdiffstats
path: root/include/xas/riff.h
blob: 5a5d4ed62546a7abc9dc7e74007cd9f73f49dc1c (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
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
#ifndef _XAS_RIFF_H
#define _XAS_RIFF_H

#include <stdint.h>
#include <sys/types.h>

#include <xas/audio.h>

#define XAS_RIFF_HEADER_MAIN_ID      "RIFF"
#define XAS_RIFF_HEADER_WAVE_ID      "WAVE"
#define XAS_RIFF_HEADER_WAVE_FMT_ID  "fmt "
#define XAS_RIFF_HEADER_WAVE_DATA_ID "data"

#define XAS_RIFF_WAVE_DEFAULT_TYPE 1

#pragma pack(1)
#pragma pack(push)

typedef struct _xas_riff_chunk {
    char id[4];
    uint32_t size;
} xas_riff_chunk;

typedef struct _xas_riff_main_chunk {
    xas_riff_chunk header;
    char type[4];
} xas_riff_main_chunk;

typedef struct _xas_riff_wave_chunk {
    xas_riff_chunk header;

    uint16_t type,
             channels;

    uint32_t sample_rate,
             byte_rate;

    uint16_t sample_size,
             sample_size_bits;
} xas_riff_wave_chunk;

typedef struct _xas_riff_wave_header {
    xas_riff_main_chunk riff;
    xas_riff_wave_chunk wave;
    xas_riff_chunk data;
} xas_riff_wave_header;

typedef struct _xas_riff xas_riff;

#pragma pack(pop)

xas_audio_stream *xas_riff_new_file(const char *path,
                                        xas_audio_format format,
                                        int flags);

xas_audio_stream *xas_riff_open_file(const char *path, int flags);

xas_audio_stream *xas_riff_open_fd(int fd);

#endif /* _XAS_RIFF_H */