diff options
author | Max Kellermann <max@duempel.org> | 2008-10-26 11:29:44 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-26 11:29:44 +0100 |
commit | ece8c1347caae044db0fc4565ed3db6028d7b90e (patch) | |
tree | 27ec1bee18cd10b6997a9a44a4043dd4a4449153 /src/output/null_plugin.c | |
parent | e11355f47d545fe523b019481415b1347aecd4bd (diff) | |
download | mpd-ece8c1347caae044db0fc4565ed3db6028d7b90e.tar.gz mpd-ece8c1347caae044db0fc4565ed3db6028d7b90e.tar.xz mpd-ece8c1347caae044db0fc4565ed3db6028d7b90e.zip |
renamed src/audioOutputs/ to src/output/
Again, no CamelCase in the directory name.
Diffstat (limited to 'src/output/null_plugin.c')
-rw-r--r-- | src/output/null_plugin.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/src/output/null_plugin.c b/src/output/null_plugin.c new file mode 100644 index 000000000..ff3a9833c --- /dev/null +++ b/src/output/null_plugin.c @@ -0,0 +1,85 @@ +/* the Music Player Daemon (MPD) + * Copyright (C) 2003-2007 by Warren Dukes (warren.dukes@gmail.com) + * This project's homepage is: http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "../output_api.h" +#include "../timer.h" +#include "../utils.h" + +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) +{ + struct null_data *nd = xmalloc(sizeof(*nd)); + nd->timer = NULL; + return nd; +} + +static int null_openDevice(void *data, + struct audio_format *audio_format) +{ + struct null_data *nd = data; + + nd->timer = timer_new(audio_format); + return 0; +} + +static void null_closeDevice(void *data) +{ + struct null_data *nd = data; + + if (nd->timer != NULL) { + timer_free(nd->timer); + nd->timer = NULL; + } +} + +static int null_playAudio(void *data, + mpd_unused const char *playChunk, size_t size) +{ + struct null_data *nd = data; + Timer *timer = nd->timer; + + if (!timer->started) + timer_start(timer); + else + timer_sync(timer); + + timer_add(timer, size); + + return 0; +} + +static void null_dropBufferedAudio(void *data) +{ + struct null_data *nd = data; + + timer_reset(nd->timer); +} + +const struct audio_output_plugin nullPlugin = { + .name = "null", + .init = null_initDriver, + .open = null_openDevice, + .play = null_playAudio, + .cancel = null_dropBufferedAudio, + .close = null_closeDevice, +}; |