2009-03-02 20:13:08 +01:00
|
|
|
/*
|
2013-01-25 22:43:01 +01:00
|
|
|
* Copyright (C) 2003-2013 The Music Player Daemon Project
|
2009-03-02 20:13:08 +01:00
|
|
|
* 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.
|
2009-03-13 18:43:16 +01:00
|
|
|
*
|
|
|
|
* 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.
|
2009-03-02 20:13:08 +01:00
|
|
|
*/
|
|
|
|
|
2013-01-25 22:43:01 +01:00
|
|
|
#ifndef MPD_INPUT_PLUGIN_HXX
|
|
|
|
#define MPD_INPUT_PLUGIN_HXX
|
2009-03-02 20:13:08 +01:00
|
|
|
|
2013-09-05 00:06:31 +02:00
|
|
|
#include "thread/Mutex.hxx"
|
|
|
|
#include "thread/Cond.hxx"
|
|
|
|
|
2009-03-02 20:13:08 +01:00
|
|
|
#include <stddef.h>
|
2013-10-17 09:43:55 +02:00
|
|
|
#include <stdint.h>
|
2009-03-02 20:13:08 +01:00
|
|
|
|
2009-03-02 23:08:17 +01:00
|
|
|
struct config_param;
|
2013-10-23 22:08:59 +02:00
|
|
|
struct InputStream;
|
2013-08-10 18:02:44 +02:00
|
|
|
class Error;
|
2013-09-05 00:06:31 +02:00
|
|
|
struct Tag;
|
2009-03-02 20:13:08 +01:00
|
|
|
|
2013-10-17 10:20:57 +02:00
|
|
|
struct InputPlugin {
|
2013-10-17 09:43:55 +02:00
|
|
|
typedef int64_t offset_type;
|
|
|
|
|
2009-03-02 23:08:17 +01:00
|
|
|
const char *name;
|
|
|
|
|
2009-03-02 20:45:50 +01:00
|
|
|
/**
|
|
|
|
* Global initialization. This method is called when MPD starts.
|
|
|
|
*
|
|
|
|
* @return true on success, false if the plugin should be
|
|
|
|
* disabled
|
|
|
|
*/
|
2013-08-10 18:02:44 +02:00
|
|
|
bool (*init)(const config_param ¶m, Error &error);
|
2009-03-02 20:45:50 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Global deinitialization. Called once before MPD shuts
|
|
|
|
* down (only if init() has returned true).
|
|
|
|
*/
|
|
|
|
void (*finish)(void);
|
|
|
|
|
2013-10-23 22:08:59 +02:00
|
|
|
InputStream *(*open)(const char *uri,
|
|
|
|
Mutex &mutex, Cond &cond,
|
|
|
|
Error &error);
|
|
|
|
void (*close)(InputStream *is);
|
2009-03-02 20:13:08 +01:00
|
|
|
|
2011-09-16 21:06:12 +02:00
|
|
|
/**
|
|
|
|
* Check for errors that may have occurred in the I/O thread.
|
|
|
|
* May be unimplemented for synchronous plugins.
|
|
|
|
*
|
|
|
|
* @return false on error
|
|
|
|
*/
|
2013-10-23 22:08:59 +02:00
|
|
|
bool (*check)(InputStream *is, Error &error);
|
2011-09-16 21:06:12 +02:00
|
|
|
|
2011-09-14 22:25:29 +02:00
|
|
|
/**
|
|
|
|
* Update the public attributes. Call before access. Can be
|
2013-10-19 18:19:03 +02:00
|
|
|
* nullptr if the plugin always keeps its attributes up to date.
|
2011-09-14 22:25:29 +02:00
|
|
|
*/
|
2013-10-23 22:08:59 +02:00
|
|
|
void (*update)(InputStream *is);
|
2011-09-14 22:25:29 +02:00
|
|
|
|
2013-10-23 22:08:59 +02:00
|
|
|
Tag *(*tag)(InputStream *is);
|
2011-09-14 21:46:41 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the next read operation will not block:
|
|
|
|
* either data is available, or end-of-stream has been
|
|
|
|
* reached, or an error has occurred.
|
|
|
|
*
|
|
|
|
* If this method is unimplemented, then it is assumed that
|
|
|
|
* reading will never block.
|
|
|
|
*/
|
2013-10-23 22:08:59 +02:00
|
|
|
bool (*available)(InputStream *is);
|
2011-09-14 21:46:41 +02:00
|
|
|
|
2013-10-23 22:08:59 +02:00
|
|
|
size_t (*read)(InputStream *is, void *ptr, size_t size,
|
2013-08-10 18:02:44 +02:00
|
|
|
Error &error);
|
2013-10-23 22:08:59 +02:00
|
|
|
bool (*eof)(InputStream *is);
|
|
|
|
bool (*seek)(InputStream *is, offset_type offset, int whence,
|
2013-08-10 18:02:44 +02:00
|
|
|
Error &error);
|
2009-03-02 20:13:08 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|