forked from xwax/xwax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
device.h
66 lines (51 loc) · 1.83 KB
/
device.h
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
/*
* Copyright (C) 2021 Mark Hills <mark@xwax.org>
*
* This file is part of "xwax".
*
* "xwax" is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License, version 3 as
* published by the Free Software Foundation.
*
* "xwax" 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef DEVICE_H
#define DEVICE_H
#include <stdbool.h>
#include <sys/poll.h>
#include <sys/types.h>
#define DEVICE_CHANNELS 2
struct device {
bool fault;
void *local;
struct device_ops *ops;
struct timecoder *timecoder;
struct player *player;
};
struct device_ops {
ssize_t (*pollfds)(struct device *dv, struct pollfd *pe, size_t z);
int (*handle)(struct device *dv);
unsigned int (*sample_rate)(struct device *dv);
void (*start)(struct device *dv);
void (*stop)(struct device *dv);
void (*clear)(struct device *dv);
};
void device_init(struct device *dv, struct device_ops *ops);
void device_clear(struct device *dv);
void device_connect_timecoder(struct device *dv, struct timecoder *tc);
void device_connect_player(struct device *dv, struct player *pl);
unsigned int device_sample_rate(struct device *dv);
void device_start(struct device *dv);
void device_stop(struct device *dv);
ssize_t device_pollfds(struct device *dv, struct pollfd *pe, size_t z);
void device_handle(struct device *dv);
void device_submit(struct device *dv, signed short *pcm, size_t npcm);
void device_collect(struct device *dv, signed short *pcm, size_t npcm);
#endif