2007-05-30 18:52:56 +02:00
|
|
|
/* 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
|
|
|
|
*/
|
|
|
|
|
2008-09-07 22:41:17 +02:00
|
|
|
#include "../output_api.h"
|
2007-05-30 20:16:35 +02:00
|
|
|
#include "../timer.h"
|
2008-09-24 07:20:55 +02:00
|
|
|
#include "../utils.h"
|
2007-05-30 18:52:56 +02:00
|
|
|
|
2008-09-24 07:20:55 +02:00
|
|
|
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)
|
2007-05-30 18:52:56 +02:00
|
|
|
{
|
2008-09-24 07:20:55 +02:00
|
|
|
struct null_data *nd = xmalloc(sizeof(*nd));
|
|
|
|
nd->timer = NULL;
|
|
|
|
return nd;
|
2007-05-30 18:52:56 +02:00
|
|
|
}
|
|
|
|
|
2008-09-24 07:20:55 +02:00
|
|
|
static int null_openDevice(void *data,
|
2008-09-24 07:20:36 +02:00
|
|
|
struct audio_format *audio_format)
|
2007-05-30 18:52:56 +02:00
|
|
|
{
|
2008-09-24 07:20:55 +02:00
|
|
|
struct null_data *nd = data;
|
|
|
|
|
|
|
|
nd->timer = timer_new(audio_format);
|
2007-05-30 18:52:56 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-09-24 07:20:55 +02:00
|
|
|
static void null_closeDevice(void *data)
|
2007-05-30 18:52:56 +02:00
|
|
|
{
|
2008-09-24 07:20:55 +02:00
|
|
|
struct null_data *nd = data;
|
|
|
|
|
|
|
|
if (nd->timer != NULL) {
|
|
|
|
timer_free(nd->timer);
|
|
|
|
nd->timer = NULL;
|
2007-05-30 20:16:35 +02:00
|
|
|
}
|
2007-05-30 18:52:56 +02:00
|
|
|
}
|
|
|
|
|
2008-09-24 07:20:55 +02:00
|
|
|
static int null_playAudio(void *data,
|
2008-08-26 08:27:02 +02:00
|
|
|
mpd_unused const char *playChunk, size_t size)
|
2007-05-30 18:52:56 +02:00
|
|
|
{
|
2008-09-24 07:20:55 +02:00
|
|
|
struct null_data *nd = data;
|
|
|
|
Timer *timer = nd->timer;
|
2007-05-30 18:52:56 +02:00
|
|
|
|
2007-05-30 20:16:35 +02:00
|
|
|
if (!timer->started)
|
|
|
|
timer_start(timer);
|
|
|
|
else
|
|
|
|
timer_sync(timer);
|
2007-05-30 18:52:56 +02:00
|
|
|
|
2007-05-30 20:16:35 +02:00
|
|
|
timer_add(timer, size);
|
2007-05-30 18:52:56 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-09-24 07:20:55 +02:00
|
|
|
static void null_dropBufferedAudio(void *data)
|
2007-05-30 20:16:35 +02:00
|
|
|
{
|
2008-09-24 07:20:55 +02:00
|
|
|
struct null_data *nd = data;
|
|
|
|
|
|
|
|
timer_reset(nd->timer);
|
2007-05-30 20:16:35 +02:00
|
|
|
}
|
|
|
|
|
2008-09-08 11:43:38 +02:00
|
|
|
const struct audio_output_plugin nullPlugin = {
|
2007-05-30 18:52:56 +02:00
|
|
|
"null",
|
|
|
|
NULL,
|
|
|
|
null_initDriver,
|
2007-05-30 20:16:35 +02:00
|
|
|
NULL,
|
2007-05-30 18:52:56 +02:00
|
|
|
null_openDevice,
|
|
|
|
null_playAudio,
|
|
|
|
null_dropBufferedAudio,
|
|
|
|
null_closeDevice,
|
|
|
|
NULL,
|
|
|
|
};
|