FLACCommon.hxx 2.51 KB
Newer Older
1
/*
2
 * Copyright (C) 2003-2012 The Music Player Daemon Project
3
 * http://www.musicpd.org
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 18 19 20 21
 *
 * 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.
 */

/*
 * Common data structures and functions used by FLAC and OggFLAC
22 23
 */

24 25
#ifndef MPD_FLAC_COMMON_HXX
#define MPD_FLAC_COMMON_HXX
26

27 28
#include "FLACInput.hxx"

29
extern "C" {
30 31
#include "decoder_api.h"
#include "pcm_buffer.h"
32
}
33

34
#include <FLAC/stream_decoder.h>
35 36
#include <FLAC/metadata.h>

37 38
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "flac"
39

40
struct flac_data : public FLACInput {
41 42
	struct pcm_buffer buffer;

43 44 45 46 47
	/**
	 * The size of one frame in the output buffer.
	 */
	unsigned frame_size;

48
	/**
49
	 * Has decoder_initialized() been called yet?
50
	 */
51
	bool initialized;
52 53

	/**
54 55 56 57 58 59
	 * Does the FLAC file contain an unsupported audio format?
	 */
	bool unsupported;

	/**
	 * The validated audio format of the FLAC file.  This
60
	 * attribute is defined if "initialized" is true.
61 62 63 64
	 */
	struct audio_format audio_format;

	/**
65 66 67
	 * The total number of frames in this song.  The decoder
	 * plugin may initialize this attribute to override the value
	 * provided by libFLAC (e.g. for sub songs from a CUE sheet).
68
	 */
69
	FLAC__uint64 total_frames;
70

71 72 73 74 75 76
	/**
	 * The number of the first frame in this song.  This is only
	 * non-zero if playing sub songs from a CUE sheet.
	 */
	FLAC__uint64 first_frame;

77 78 79 80 81
	/**
	 * The number of the next frame which is going to be decoded.
	 */
	FLAC__uint64 next_frame;

82
	FLAC__uint64 position;
83

Max Kellermann's avatar
Max Kellermann committed
84
	struct decoder *decoder;
Max Kellermann's avatar
Max Kellermann committed
85
	struct input_stream *input_stream;
86

87
	struct tag *tag;
Max Kellermann's avatar
Max Kellermann committed
88

89 90 91
	flac_data(struct decoder *decoder, struct input_stream *input_stream);
	~flac_data();
};
92

Avuton Olrich's avatar
Avuton Olrich committed
93
void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
Max Kellermann's avatar
Max Kellermann committed
94 95
			     struct flac_data *data);

96
FLAC__StreamDecoderWriteStatus
Max Kellermann's avatar
Max Kellermann committed
97
flac_common_write(struct flac_data *data, const FLAC__Frame * frame,
98 99
		  const FLAC__int32 *const buf[],
		  FLAC__uint64 nbytes);
100

Avuton Olrich's avatar
Avuton Olrich committed
101
#endif /* _FLAC_COMMON_H */