summaryrefslogtreecommitdiff
path: root/galsa.h
blob: 5f5da40d69590975f5717965cbaf6c03ea229932 (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
#ifndef _GALSA_H
#define _GALSA_H

#include <alsa/asoundlib.h>
#include <glib.h>

typedef short sample;

enum dev_runstate {
	DEV_OPEN,
	DEV_RUNNING,
	DEV_STOPREQ,
};
enum qe_message {
	QE_DATA,
	QE_ERROR,
	QE_STOPPED,
};

struct device {
	char *path;
	unsigned rate;
	int chan;
	snd_pcm_t *handle;
	GAsyncQueue *queue;
	size_t pktsize;

	GThread *thread;
	enum dev_runstate state;
};

struct qe {
	enum qe_message message;
	int errcode;
	char *errp;

	ssize_t size;
	sample samples[];
};

extern struct device *device_open(const char *path,
		unsigned rate, int chan, size_t pktsize);
extern void device_start(struct device *dev);
extern void device_stop(struct device *dev);
extern void device_stop_wait(struct device *dev);
extern void device_stop_done(struct device *dev);
extern void device_close(struct device *dev);

#endif