change license from GPLv3 to GPLv3 or later
[mmq.git] / mmq.h
blobd8f4ff5826ae82e13c0d88d0f764f83bd0ced722
1 #ifndef MMQ_H
2 #define MMQ_H
4 /*
5 * This includes OS-wide headers that can be expected to be available
6 * on any machine that mmq can be compiled on for any POSIX-compliant OS
8 * This does not include headers for optional dependencies such as
9 * those for input/output modules.
11 #define _XOPEN_SOURCE 600
12 #define _GNU_SOURCE
13 /* #define _FILE_OFFSET_BITS 64 */ /* off by default */
15 #include "compat/cc.h"
17 #include <inttypes.h>
18 #include <sys/types.h>
19 #include <unistd.h>
20 #include <time.h>
21 #include <mqueue.h>
22 #include <fcntl.h>
23 #include <sys/stat.h>
24 #include <sys/time.h>
25 #include <stddef.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <errno.h>
29 #include <assert.h>
30 #include <stdio.h>
31 #include <stdarg.h>
32 #include <signal.h>
33 #include <limits.h>
35 extern void emit(const char *err, ...) PRINTF;
36 extern void warn(const char *err, ...) PRINTF;
37 extern NORETURN void die(const char *err, ...) PRINTF;
39 enum player_state {
40 STATE_PLAY = 0,
41 STATE_NEXT = 1
44 extern enum player_state g_state;
45 extern long g_seek_msec;
46 extern unsigned long g_sample_size;
48 struct afmt {
49 unsigned rate;
50 unsigned bits;
51 unsigned channels;
54 extern struct afmt g_next_afmt;
55 int audio_open(void);
56 void audio_close(int graceful);
58 typedef long (*conv_fn)(void *dst, void *src, long samples, long offset);
59 int audio_inject(void *buf, long samples, conv_fn conv_i);
60 long audio_copy(void *dst, void *src, long samples, long offset);
62 int input_open(const char *path);
63 off_t input_seek(off_t offset, int whence);
64 off_t input_size(void);
65 ssize_t input_read(void *buf, size_t count);
66 void *input_mmap(size_t *size);
67 void input_close(void);
69 #ifndef O_NOATIME
70 # define O_NOATIME 0
71 #endif
73 #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
75 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
76 # define MMQ_C99 1
77 #else
78 # ifdef NO_INLINE
79 # define inline
80 # endif
81 # ifdef __GNUC__
82 # define restrict __restrict
83 # else
84 # define restrict
85 # endif
86 # define MMQ_C99 0
87 #endif
89 #endif /* MMQ_H */