OutputPlugin.hxx 2.19 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
 * 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.
14 15 16 17
 *
 * 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.
18 19
 */

Max Kellermann's avatar
Max Kellermann committed
20 21
#ifndef MPD_OUTPUT_PLUGIN_HXX
#define MPD_OUTPUT_PLUGIN_HXX
22

23
#include "Compiler.h"
24

25 26
#include <chrono>

27 28
#include <stddef.h>

29
struct ConfigBlock;
30
struct AudioFormat;
Max Kellermann's avatar
Max Kellermann committed
31
struct Tag;
32
class AudioOutput;
33
struct MixerPlugin;
34
class EventLoop;
35 36 37 38

/**
 * A plugin which controls an audio output device.
 */
39
struct AudioOutputPlugin {
40 41 42 43 44 45 46 47 48
	/**
	 * the plugin's name
	 */
	const char *name;

	/**
	 * Test if this plugin can provide a default output, in case
	 * none has been configured.  This method is optional.
	 */
49
	bool (*test_default_device)();
50 51 52 53 54

	/**
	 * Configure and initialize the device, but do not open it
	 * yet.
	 *
55 56
	 * Throws #std::runtime_error on error.
	 *
57
	 * @param param the configuration section, or nullptr if there is
58 59
	 * no configuration
	 */
60
	AudioOutput *(*init)(EventLoop &event_loop, const ConfigBlock &block);
61

62 63
	/**
	 * The mixer plugin associated with this output plugin.  This
64
	 * may be nullptr if no mixer plugin is implemented.  When
65
	 * created, this mixer plugin gets the same #ConfigParam as
66 67
	 * this audio output device.
	 */
68
	const MixerPlugin *mixer_plugin;
69 70
};

71
static inline bool
72
ao_plugin_test_default_device(const AudioOutputPlugin *plugin)
73
{
74
	return plugin->test_default_device != nullptr
75 76 77 78
		? plugin->test_default_device()
		: false;
}

79
gcc_malloc gcc_returns_nonnull
80
AudioOutput *
81 82
ao_plugin_init(EventLoop &event_loop,
	       const AudioOutputPlugin &plugin,
83
	       const ConfigBlock &block);
84

85
#endif