2009-03-13 18:43:16 +01:00
|
|
|
/*
|
2020-01-18 19:22:19 +01:00
|
|
|
* Copyright 2003-2020 The Music Player Daemon Project
|
2009-03-13 18:43:16 +01:00
|
|
|
* http://www.musicpd.org
|
2008-08-26 08:27:04 +02:00
|
|
|
*
|
|
|
|
* 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.
|
2008-08-26 08:27:04 +02:00
|
|
|
*/
|
|
|
|
|
2009-10-08 15:39:45 +02:00
|
|
|
/*! \file
|
|
|
|
* \brief The MPD Decoder API
|
|
|
|
*
|
2008-08-26 08:27:04 +02:00
|
|
|
* This is the public API which is used by decoder plugins to
|
|
|
|
* communicate with the mpd core.
|
|
|
|
*/
|
|
|
|
|
2013-07-28 13:18:48 +02:00
|
|
|
#ifndef MPD_DECODER_API_HXX
|
|
|
|
#define MPD_DECODER_API_HXX
|
2009-10-08 15:39:45 +02:00
|
|
|
|
2013-11-28 11:50:54 +01:00
|
|
|
// IWYU pragma: begin_exports
|
|
|
|
|
2016-11-18 07:59:01 +01:00
|
|
|
#include "Client.hxx"
|
2016-02-21 08:03:32 +01:00
|
|
|
#include "input/Ptr.hxx"
|
2018-09-21 16:56:53 +02:00
|
|
|
#include "Command.hxx"
|
2013-07-28 13:18:48 +02:00
|
|
|
#include "DecoderPlugin.hxx"
|
2013-10-02 12:22:12 +02:00
|
|
|
#include "ReplayGainInfo.hxx"
|
2013-09-05 18:22:02 +02:00
|
|
|
#include "tag/Tag.hxx"
|
2020-01-18 20:07:09 +01:00
|
|
|
#include "pcm/AudioFormat.hxx"
|
2013-10-26 14:19:34 +02:00
|
|
|
#include "MixRampInfo.hxx"
|
2015-01-21 22:13:44 +01:00
|
|
|
#include "config/Block.hxx"
|
2014-08-26 21:52:28 +02:00
|
|
|
#include "Chrono.hxx"
|
2008-08-26 08:27:06 +02:00
|
|
|
|
2013-11-28 11:50:54 +01:00
|
|
|
// IWYU pragma: end_exports
|
|
|
|
|
2020-03-13 01:08:53 +01:00
|
|
|
#include <cstdint>
|
2014-08-26 11:27:41 +02:00
|
|
|
|
2016-05-13 13:12:21 +02:00
|
|
|
/**
|
|
|
|
* Throw an instance of this class to stop decoding the current song
|
|
|
|
* (successfully). It can be used to jump out of all of a decoder's
|
|
|
|
* stack frames.
|
|
|
|
*/
|
|
|
|
class StopDecoder {};
|
|
|
|
|
2008-08-26 08:27:14 +02:00
|
|
|
/**
|
2009-10-08 15:39:45 +02:00
|
|
|
* Blocking read from the input stream.
|
|
|
|
*
|
|
|
|
* @param decoder the decoder object
|
|
|
|
* @param is the input stream to read from
|
|
|
|
* @param buffer the destination buffer
|
|
|
|
* @param length the maximum number of bytes to read
|
|
|
|
* @return the number of bytes read, or 0 if one of the following
|
|
|
|
* occurs: end of file; error; command (like SEEK or STOP).
|
2008-08-26 08:27:14 +02:00
|
|
|
*/
|
2009-10-08 15:39:45 +02:00
|
|
|
size_t
|
2016-11-18 07:13:35 +01:00
|
|
|
decoder_read(DecoderClient *decoder, InputStream &is,
|
2020-09-04 13:33:47 +02:00
|
|
|
void *buffer, size_t length) noexcept;
|
2008-08-26 08:27:14 +02:00
|
|
|
|
2013-10-21 21:12:37 +02:00
|
|
|
static inline size_t
|
2016-11-18 07:13:35 +01:00
|
|
|
decoder_read(DecoderClient &decoder, InputStream &is,
|
2020-09-04 13:33:47 +02:00
|
|
|
void *buffer, size_t length) noexcept
|
2013-10-21 21:12:37 +02:00
|
|
|
{
|
|
|
|
return decoder_read(&decoder, is, buffer, length);
|
|
|
|
}
|
|
|
|
|
2020-09-04 13:18:37 +02:00
|
|
|
/**
|
|
|
|
* Blocking read from the input stream. Attempts to fill the buffer
|
|
|
|
* as much as possible, until either end-of-file is reached or an
|
|
|
|
* error occurs.
|
|
|
|
*
|
|
|
|
* @return the number of bytes read, or 0 if one of the following
|
|
|
|
* occurs: end of file; error; command (like SEEK or STOP).
|
|
|
|
*/
|
|
|
|
size_t
|
|
|
|
decoder_read_much(DecoderClient *decoder, InputStream &is,
|
|
|
|
void *buffer, size_t size) noexcept;
|
|
|
|
|
2013-12-14 12:43:06 +01:00
|
|
|
/**
|
|
|
|
* Blocking read from the input stream. Attempts to fill the buffer
|
|
|
|
* completely; there is no partial result.
|
|
|
|
*
|
|
|
|
* @return true on success, false on error or command or not enough
|
|
|
|
* data
|
|
|
|
*/
|
|
|
|
bool
|
2016-11-18 07:13:35 +01:00
|
|
|
decoder_read_full(DecoderClient *decoder, InputStream &is,
|
2020-09-04 13:33:47 +02:00
|
|
|
void *buffer, size_t size) noexcept;
|
2013-12-14 12:43:06 +01:00
|
|
|
|
2013-12-14 12:21:23 +01:00
|
|
|
/**
|
|
|
|
* Skip data on the #InputStream.
|
|
|
|
*
|
|
|
|
* @return true on success, false on error or command
|
|
|
|
*/
|
|
|
|
bool
|
2020-09-04 13:33:47 +02:00
|
|
|
decoder_skip(DecoderClient *decoder, InputStream &is, size_t size) noexcept;
|
2013-12-14 12:21:23 +01:00
|
|
|
|
2008-08-26 08:27:04 +02:00
|
|
|
#endif
|