diff options
Diffstat (limited to '')
-rw-r--r-- | src/output/openal_output_plugin.c (renamed from src/output/openal_plugin.c) | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/src/output/openal_plugin.c b/src/output/openal_output_plugin.c index 0a8f253b2..622cf559e 100644 --- a/src/output/openal_plugin.c +++ b/src/output/openal_output_plugin.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2010 The Music Player Daemon Project + * Copyright (C) 2003-2011 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -18,6 +18,7 @@ */ #include "config.h" +#include "openal_output_plugin.h" #include "output_api.h" #include "timer.h" @@ -38,10 +39,12 @@ #define NUM_BUFFERS 16 struct openal_data { + struct audio_output base; + const char *device_name; ALCdevice *device; ALCcontext *context; - Timer *timer; + struct timer *timer; ALuint buffers[NUM_BUFFERS]; int filled; ALuint source; @@ -125,10 +128,8 @@ openal_unqueue_buffers(struct openal_data *od) } } -static void * -openal_init(G_GNUC_UNUSED const struct audio_format *audio_format, - const struct config_param *param, - G_GNUC_UNUSED GError **error) +static struct audio_output * +openal_init(const struct config_param *param, GError **error_r) { const char *device_name = config_get_block_string(param, "device", NULL); struct openal_data *od; @@ -138,24 +139,30 @@ openal_init(G_GNUC_UNUSED const struct audio_format *audio_format, } od = g_new(struct openal_data, 1); + if (!ao_base_init(&od->base, &openal_output_plugin, param, error_r)) { + g_free(od); + return NULL; + } + od->device_name = device_name; - return od; + return &od->base; } static void -openal_finish(void *data) +openal_finish(struct audio_output *ao) { - struct openal_data *od = data; + struct openal_data *od = (struct openal_data *)ao; + ao_base_finish(&od->base); g_free(od); } static bool -openal_open(void *data, struct audio_format *audio_format, +openal_open(struct audio_output *ao, struct audio_format *audio_format, GError **error) { - struct openal_data *od = data; + struct openal_data *od = (struct openal_data *)ao; od->format = openal_audio_format(audio_format); @@ -197,9 +204,9 @@ openal_open(void *data, struct audio_format *audio_format, } static void -openal_close(void *data) +openal_close(struct audio_output *ao) { - struct openal_data *od = data; + struct openal_data *od = (struct openal_data *)ao; timer_free(od->timer); alcMakeContextCurrent(od->context); @@ -210,10 +217,10 @@ openal_close(void *data) } static size_t -openal_play(void *data, const void *chunk, size_t size, +openal_play(struct audio_output *ao, const void *chunk, size_t size, G_GNUC_UNUSED GError **error) { - struct openal_data *od = data; + struct openal_data *od = (struct openal_data *)ao; ALuint buffer; ALint num, state; @@ -256,9 +263,9 @@ openal_play(void *data, const void *chunk, size_t size, } static void -openal_cancel(void *data) +openal_cancel(struct audio_output *ao) { - struct openal_data *od = data; + struct openal_data *od = (struct openal_data *)ao; od->filled = 0; alcMakeContextCurrent(od->context); |