OutputPlugin.cxx 2.22 KB
Newer Older
1
/*
Max Kellermann's avatar
Max Kellermann committed
2
 * Copyright 2003-2017 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 ConfigBlock &block)
27
{
28 29
	assert(plugin != nullptr);
	assert(plugin->init != nullptr);
30

31
	return plugin->init(block);
32 33 34
}

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

40 41
void
ao_plugin_enable(AudioOutput *ao)
42
{
43 44
	if (ao->plugin.enable != nullptr)
		ao->plugin.enable(ao);
45 46 47
}

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

54 55
void
ao_plugin_open(AudioOutput *ao, AudioFormat &audio_format)
56
{
57
	ao->plugin.open(ao, audio_format);
58 59 60
}

void
61
ao_plugin_close(AudioOutput *ao)
62
{
63
	ao->plugin.close(ao);
64 65
}

66
std::chrono::steady_clock::duration
67
ao_plugin_delay(AudioOutput *ao) noexcept
68
{
69 70
	return ao->plugin.delay != nullptr
		? ao->plugin.delay(ao)
71
		: std::chrono::steady_clock::duration::zero();
72 73 74
}

void
75
ao_plugin_send_tag(AudioOutput *ao, const Tag &tag)
76
{
77 78
	if (ao->plugin.send_tag != nullptr)
		ao->plugin.send_tag(ao, tag);
79 80 81
}

size_t
82
ao_plugin_play(AudioOutput *ao, const void *chunk, size_t size)
83
{
84
	return ao->plugin.play(ao, chunk, size);
85 86 87
}

void
88
ao_plugin_drain(AudioOutput *ao)
89
{
90 91
	if (ao->plugin.drain != nullptr)
		ao->plugin.drain(ao);
92 93 94
}

void
95
ao_plugin_cancel(AudioOutput *ao)
96
{
97 98
	if (ao->plugin.cancel != nullptr)
		ao->plugin.cancel(ao);
99 100 101
}

bool
102
ao_plugin_pause(AudioOutput *ao)
103
{
104
	return ao->plugin.pause != nullptr && ao->plugin.pause(ao);
105
}