OutputPlugin.cxx 2.28 KB
Newer Older
1
/*
Max Kellermann's avatar
Max Kellermann committed
2
 * Copyright (C) 2003-2014 The Music Player Daemon Project
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 * 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.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

20
#include "config.h"
Max Kellermann's avatar
Max Kellermann committed
21
#include "OutputPlugin.hxx"
22
#include "Internal.hxx"
23

24
AudioOutput *
25
ao_plugin_init(const AudioOutputPlugin *plugin,
26
	       const config_param &param,
27
	       Error &error)
28
{
29 30
	assert(plugin != nullptr);
	assert(plugin->init != nullptr);
31 32 33 34 35

	return plugin->init(param, error);
}

void
36
ao_plugin_finish(AudioOutput *ao)
37
{
38
	ao->plugin.finish(ao);
39 40 41
}

bool
42
ao_plugin_enable(AudioOutput *ao, Error &error_r)
43
{
44 45
	return ao->plugin.enable != nullptr
		? ao->plugin.enable(ao, error_r)
46 47 48 49
		: true;
}

void
50
ao_plugin_disable(AudioOutput *ao)
51
{
52 53
	if (ao->plugin.disable != nullptr)
		ao->plugin.disable(ao);
54 55 56
}

bool
57
ao_plugin_open(AudioOutput *ao, AudioFormat &audio_format,
58
	       Error &error)
59
{
60
	return ao->plugin.open(ao, audio_format, error);
61 62 63
}

void
64
ao_plugin_close(AudioOutput *ao)
65
{
66
	ao->plugin.close(ao);
67 68 69
}

unsigned
70
ao_plugin_delay(AudioOutput *ao)
71
{
72 73
	return ao->plugin.delay != nullptr
		? ao->plugin.delay(ao)
74 75 76 77
		: 0;
}

void
78
ao_plugin_send_tag(AudioOutput *ao, const Tag *tag)
79
{
80 81
	if (ao->plugin.send_tag != nullptr)
		ao->plugin.send_tag(ao, tag);
82 83 84
}

size_t
85
ao_plugin_play(AudioOutput *ao, const void *chunk, size_t size,
86
	       Error &error)
87
{
88
	return ao->plugin.play(ao, chunk, size, error);
89 90 91
}

void
92
ao_plugin_drain(AudioOutput *ao)
93
{
94 95
	if (ao->plugin.drain != nullptr)
		ao->plugin.drain(ao);
96 97 98
}

void
99
ao_plugin_cancel(AudioOutput *ao)
100
{
101 102
	if (ao->plugin.cancel != nullptr)
		ao->plugin.cancel(ao);
103 104 105
}

bool
106
ao_plugin_pause(AudioOutput *ao)
107
{
108
	return ao->plugin.pause != nullptr && ao->plugin.pause(ao);
109
}