diff options
author | Max Kellermann <max@duempel.org> | 2008-09-24 07:20:55 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-09-24 07:20:55 +0200 |
commit | acc4a0ba2dd0be3f28c4ca009e08d1cc1bbc534a (patch) | |
tree | 7d4ea0359c85f67d0366fb58ae80c8aa35f3a473 /src/audioOutputs/audioOutput_null.c | |
parent | 63fb1efb5cd6665b73ced155ba89a5c7f094d9ab (diff) | |
download | mpd-acc4a0ba2dd0be3f28c4ca009e08d1cc1bbc534a.tar.gz mpd-acc4a0ba2dd0be3f28c4ca009e08d1cc1bbc534a.tar.xz mpd-acc4a0ba2dd0be3f28c4ca009e08d1cc1bbc534a.zip |
output: make "struct audio_output" opaque for output plugins
We have eliminated direct accesses to the audio_output struct from
the all output plugins. Make it opaque for them, and move its real
declaration to output_internal.h, similar to decoder_internal.h.
Pass the opaque structure to plugin.init() only, which will return the
plugin's data pointer on success, and NULL on failure. This data
pointer will be passed to all other methods instead of the
audio_output struct.
Diffstat (limited to '')
-rw-r--r-- | src/audioOutputs/audioOutput_null.c | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/src/audioOutputs/audioOutput_null.c b/src/audioOutputs/audioOutput_null.c index c4c7d339e..564f8b870 100644 --- a/src/audioOutputs/audioOutput_null.c +++ b/src/audioOutputs/audioOutput_null.c @@ -18,34 +18,45 @@ #include "../output_api.h" #include "../timer.h" +#include "../utils.h" -static int null_initDriver(struct audio_output *audioOutput, - mpd_unused const struct audio_format *audio_format, - mpd_unused ConfigParam *param) +struct null_data { + Timer *timer; +}; + +static void *null_initDriver(mpd_unused struct audio_output *audioOutput, + mpd_unused const struct audio_format *audio_format, + mpd_unused ConfigParam *param) { - audioOutput->data = NULL; - return 0; + struct null_data *nd = xmalloc(sizeof(*nd)); + nd->timer = NULL; + return nd; } -static int null_openDevice(struct audio_output *audioOutput, +static int null_openDevice(void *data, struct audio_format *audio_format) { - audioOutput->data = timer_new(audio_format); + struct null_data *nd = data; + + nd->timer = timer_new(audio_format); return 0; } -static void null_closeDevice(struct audio_output *audioOutput) +static void null_closeDevice(void *data) { - if (audioOutput->data) { - timer_free(audioOutput->data); - audioOutput->data = NULL; + struct null_data *nd = data; + + if (nd->timer != NULL) { + timer_free(nd->timer); + nd->timer = NULL; } } -static int null_playAudio(struct audio_output *audioOutput, +static int null_playAudio(void *data, mpd_unused const char *playChunk, size_t size) { - Timer *timer = audioOutput->data; + struct null_data *nd = data; + Timer *timer = nd->timer; if (!timer->started) timer_start(timer); @@ -57,9 +68,11 @@ static int null_playAudio(struct audio_output *audioOutput, return 0; } -static void null_dropBufferedAudio(struct audio_output *audioOutput) +static void null_dropBufferedAudio(void *data) { - timer_reset(audioOutput->data); + struct null_data *nd = data; + + timer_reset(nd->timer); } const struct audio_output_plugin nullPlugin = { |