FlacCommon.hxx 2.17 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
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
#include "FlacInput.hxx"
28
#include "../DecoderAPI.hxx"
29
#include "pcm/PcmBuffer.hxx"
30

31
#include <FLAC/stream_decoder.h>
32

33
struct flac_data : public FlacInput {
34
	PcmBuffer buffer;
35

36 37 38 39 40
	/**
	 * The size of one frame in the output buffer.
	 */
	unsigned frame_size;

41
	/**
42
	 * Has decoder_initialized() been called yet?
43
	 */
44
	bool initialized;
45 46

	/**
47 48 49 50 51 52
	 * Does the FLAC file contain an unsupported audio format?
	 */
	bool unsupported;

	/**
	 * The validated audio format of the FLAC file.  This
53
	 * attribute is defined if "initialized" is true.
54
	 */
55
	AudioFormat audio_format;
56

57 58 59 60
	/**
	 * End of last frame's position within the stream.  This is
	 * used for bit rate calculations.
	 */
61
	FLAC__uint64 position;
62

63
	Decoder &decoder;
64
	InputStream &input_stream;
65

Max Kellermann's avatar
Max Kellermann committed
66
	Tag tag;
Max Kellermann's avatar
Max Kellermann committed
67

68
	flac_data(Decoder &decoder, InputStream &input_stream);
69 70 71 72 73 74

	/**
	 * Wrapper for decoder_initialized().
	 */
	bool Initialize(unsigned sample_rate, unsigned bits_per_sample,
			unsigned channels, FLAC__uint64 total_frames);
75
};
76

Avuton Olrich's avatar
Avuton Olrich committed
77
void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
Max Kellermann's avatar
Max Kellermann committed
78 79
			     struct flac_data *data);

80
FLAC__StreamDecoderWriteStatus
Max Kellermann's avatar
Max Kellermann committed
81
flac_common_write(struct flac_data *data, const FLAC__Frame * frame,
82 83
		  const FLAC__int32 *const buf[],
		  FLAC__uint64 nbytes);
84

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