summaryrefslogtreecommitdiff
path: root/decoder.h
blob: 8335db8895cf1ead2bd0c24bebbfddfa3f3822d9 (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
#ifndef DECODER_H
#define DECODER_H

#include "audioformat.h"

#include <glib.h>
#include <gio/gio.h>

struct decoder;

struct decoder_plugin {
	const gchar *name;
	const gchar * const *extensions;

	gboolean (*init)(struct decoder *decoder);
	gssize (*decode)(struct decoder *decoder, GInputStream *input,
			GOutputStream *output, GError **error);
	void (*close)(struct decoder *decoder);
};

struct decoder {
	const struct decoder_plugin *decoder;

	unsigned int rate;
	enum audio_format format;
	unsigned int channels;

	gpointer data;
};

gboolean decoder_init(struct decoder *decoder);
gssize decoder_decode(struct decoder *decoder, GInputStream *input,
		GOutputStream *output, GError **error);
void decoder_close(struct decoder *decoder);

const struct decoder_plugin *decoder_get(const gchar *name);
const struct decoder_plugin *decoder_find(const gchar *filename);

static inline GQuark decoder_quark() {
	return g_quark_from_string("decoder");
}

enum {
	DECODER_CODE_ERROR = 0,
	DECODER_CODE_DONE,
};

#endif