FilterInternal.hxx 2.09 KB
Newer Older
1
/*
2
 * Copyright 2003-2016 The Music Player Daemon Project
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 * 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.
 */

/** \file
 *
 * Internal stuff for the filter core and filter plugins.
 */

Max Kellermann's avatar
Max Kellermann committed
25 26
#ifndef MPD_FILTER_INTERNAL_HXX
#define MPD_FILTER_INTERNAL_HXX
27

28 29
#include "AudioFormat.hxx"

30 31
#include <stddef.h>

32
struct AudioFormat;
33
class Error;
34
template<typename T> struct ConstBuffer;
35 36

class Filter {
37 38 39 40 41 42 43
protected:
	AudioFormat out_audio_format;

	Filter() = default;
	explicit Filter(AudioFormat _out_audio_format)
		:out_audio_format(_out_audio_format) {}

44 45 46 47
public:
	virtual ~Filter() {}

	/**
48
	 * Returns the #AudioFormat produced by FilterPCM().
49
	 */
50 51 52
	const AudioFormat &GetOutAudioFormat() const {
		return out_audio_format;
	}
53 54 55 56

	/**
	 * Filters a block of PCM data.
	 *
57 58
	 * Throws std::runtime_error on error.
	 *
59
	 * @param src the input buffer
Max Kellermann's avatar
Max Kellermann committed
60
	 * @param error location to store the error occurring
61
	 * @return the destination buffer on success (will be
62
	 * invalidated by deleting this object or the next FilterPCM()
63
	 * call)
64
	 */
65
	virtual ConstBuffer<void> FilterPCM(ConstBuffer<void> src) = 0;
66
};
67

68 69 70 71 72 73 74
class PreparedFilter {
public:
	virtual ~PreparedFilter() {}

	/**
	 * Opens the filter, preparing it for FilterPCM().
	 *
75 76
	 * Throws std::runtime_error on error.
	 *
77 78 79 80
	 * @param af the audio format of incoming data; the
	 * plugin may modify the object to enforce another input
	 * format
	 */
81
	virtual Filter *Open(AudioFormat &af) = 0;
82 83
};

84
#endif