New audio output interface
[2oom.git] / src / audio / audio.c
blob3ebeec1023aa63d79de03571c0dc608035898273
1 /* 2ooM: The Master of Orion II Reverse Engineering Project
2 * Copyright (C) 2006 Nick Bowler
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * $HeadURL$
19 * $Date$
20 * $Revision$
21 * $Author$
24 #include <stdlib.h>
26 #include "audio.h"
27 #include "../sys/log.h"
28 #include "../plugin/plugin.h"
30 static struct audio_output *ao;
32 int ao_play(struct audio_data *data, int flags)
34 if (!ao)
35 return -1;
37 return ao->play(data, flags);
40 int ao_init(int flags)
42 if (!ao)
43 return -1;
45 return ao->init(flags);
48 static int ao_register(const char *name, void *data)
50 ao = data;
51 return 0;
54 int audio_init(void)
56 if (plugin_addservice(AO_SERVICE, ao_register, NULL)) {
57 log_write(LOG_ERROR, AO_MODULENAME,
58 "Failed to register service: %s", AO_SERVICE);
59 return -1;
62 return 0;