DecoderInternal.hxx 3.13 KB
Newer Older
1
/*
Max Kellermann's avatar
Max Kellermann committed
2
 * Copyright (C) 2003-2014 The Music Player Daemon Project
3
 * http://www.musicpd.org
Max Kellermann's avatar
Max Kellermann committed
4 5 6 7 8 9 10 11 12 13
 *
 * 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.
Max Kellermann's avatar
Max Kellermann committed
18 19
 */

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

23
#include "ReplayGainInfo.hxx"
24
#include "util/Error.hxx"
Max Kellermann's avatar
Max Kellermann committed
25

26
class PcmConvert;
27
struct MusicChunk;
28
struct DecoderControl;
Max Kellermann's avatar
Max Kellermann committed
29
struct Tag;
30

31
struct Decoder {
32
	DecoderControl &dc;
33

34 35 36 37 38
	/**
	 * For converting input data to the configured audio format.
	 * nullptr means no conversion necessary.
	 */
	PcmConvert *convert;
39

40 41 42 43 44
	/**
	 * The time stamp of the next data chunk, in seconds.
	 */
	double timestamp;

45 46 47 48 49 50 51 52 53 54 55 56 57 58
	/**
	 * Is the initial seek (to the start position of the sub-song)
	 * pending, or has it been performed already?
	 */
	bool initial_seek_pending;

	/**
	 * Is the initial seek currently running?  During this time,
	 * the decoder command is SEEK.  This flag is set by
	 * decoder_get_virtual_command(), when the virtual SEEK
	 * command is generated for the first time.
	 */
	bool initial_seek_running;

59
	/**
60
	 * This flag is set by decoder_seek_time(), and checked by
61 62 63
	 * decoder_command_finished().  It is used to clean up after
	 * seeking.
	 */
64
	bool seeking;
65

66 67 68 69 70
	/**
	 * The tag from the song object.  This is only used for local
	 * files, because we expect the stream server to send us a new
	 * tag each time we play it.
	 */
Max Kellermann's avatar
Max Kellermann committed
71
	Tag *song_tag;
72

73
	/** the last tag received from the stream */
Max Kellermann's avatar
Max Kellermann committed
74
	Tag *stream_tag;
75 76

	/** the last tag received from the decoder plugin */
Max Kellermann's avatar
Max Kellermann committed
77
	Tag *decoder_tag;
78 79

	/** the chunk currently being written to */
80
	MusicChunk *chunk;
81

82
	ReplayGainInfo replay_gain_info;
83 84 85 86 87 88

	/**
	 * A positive serial number for checking if replay gain info
	 * has changed since the last check.
	 */
	unsigned replay_gain_serial;
89

90 91 92 93 94 95
	/**
	 * An error has occurred (in DecoderAPI.cxx), and the plugin
	 * will be asked to stop.
	 */
	Error error;

96
	Decoder(DecoderControl &_dc, bool _initial_seek_pending, Tag *_tag)
97
		:dc(_dc),
98
		 convert(nullptr),
99
		 timestamp(0),
100
		 initial_seek_pending(_initial_seek_pending),
101 102 103
		 initial_seek_running(false),
		 seeking(false),
		 song_tag(_tag), stream_tag(nullptr), decoder_tag(nullptr),
104
		 chunk(nullptr),
105 106 107
		 replay_gain_serial(0) {
	}

108
	~Decoder();
Max Kellermann's avatar
Max Kellermann committed
109

110 111 112 113 114 115
	/**
	 * Returns the current chunk the decoder writes to, or allocates a new
	 * chunk if there is none.
	 *
	 * @return the chunk, or NULL if we have received a decoder command
	 */
116
	MusicChunk *GetChunk();
117

118 119 120 121 122 123 124
	/**
	 * Flushes the current chunk.
	 *
	 * Caller must not lock the #DecoderControl object.
	 */
	void FlushChunk();
};
125

Max Kellermann's avatar
Max Kellermann committed
126
#endif