2009-03-13 18:43:16 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2003-2009 The Music Player Daemon Project
|
|
|
|
* http://www.musicpd.org
|
2006-03-16 07:52:46 +01: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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Common data structures and functions used by FLAC and OggFLAC
|
2006-03-16 07:52:46 +01:00
|
|
|
*/
|
|
|
|
|
2008-10-31 09:19:53 +01:00
|
|
|
#ifndef MPD_FLAC_COMMON_H
|
|
|
|
#define MPD_FLAC_COMMON_H
|
2006-03-16 07:52:46 +01:00
|
|
|
|
2009-11-10 21:46:10 +01:00
|
|
|
#include "decoder_api.h"
|
|
|
|
#include "pcm_buffer.h"
|
2006-03-16 07:52:46 +01:00
|
|
|
|
2008-11-21 20:15:50 +01:00
|
|
|
#include <glib.h>
|
|
|
|
|
2009-11-11 16:43:34 +01:00
|
|
|
#include <FLAC/stream_decoder.h>
|
2006-03-16 07:52:46 +01:00
|
|
|
#include <FLAC/metadata.h>
|
|
|
|
|
2009-11-11 16:43:34 +01:00
|
|
|
#undef G_LOG_DOMAIN
|
|
|
|
#define G_LOG_DOMAIN "flac"
|
2006-03-16 07:52:46 +01:00
|
|
|
|
2009-01-15 19:50:28 +01:00
|
|
|
struct flac_data {
|
2009-11-10 21:46:10 +01:00
|
|
|
struct pcm_buffer buffer;
|
|
|
|
|
2009-11-10 17:11:34 +01:00
|
|
|
enum sample_format sample_format;
|
|
|
|
|
2009-11-11 20:34:59 +01:00
|
|
|
/**
|
|
|
|
* The size of one frame in the output buffer.
|
|
|
|
*/
|
|
|
|
unsigned frame_size;
|
|
|
|
|
2009-11-11 19:25:15 +01:00
|
|
|
/**
|
|
|
|
* Is the #stream_info member valid?
|
|
|
|
*/
|
|
|
|
bool have_stream_info;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A copy of the stream info object passed to the metadata
|
|
|
|
* callback. Once we drop support for libFLAC 1.1.2, we can
|
|
|
|
* remove this attribute, and use
|
|
|
|
* FLAC__stream_decoder_get_total_samples() etc.
|
|
|
|
*/
|
|
|
|
FLAC__StreamMetadata_StreamInfo stream_info;
|
|
|
|
|
2009-11-11 20:18:39 +01:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
|
2009-11-11 15:09:24 +01:00
|
|
|
/**
|
|
|
|
* The number of the next frame which is going to be decoded.
|
|
|
|
*/
|
|
|
|
FLAC__uint64 next_frame;
|
|
|
|
|
2006-03-16 07:52:46 +01:00
|
|
|
FLAC__uint64 position;
|
2008-08-26 08:27:04 +02:00
|
|
|
struct decoder *decoder;
|
2009-01-15 19:50:28 +01:00
|
|
|
struct input_stream *input_stream;
|
|
|
|
struct replay_gain_info *replay_gain_info;
|
2008-08-29 09:38:11 +02:00
|
|
|
struct tag *tag;
|
2009-01-15 19:50:28 +01:00
|
|
|
};
|
2006-03-16 07:52:46 +01:00
|
|
|
|
|
|
|
/* initializes a given FlacData struct */
|
2009-01-15 19:50:28 +01:00
|
|
|
void
|
|
|
|
flac_data_init(struct flac_data *data, struct decoder * decoder,
|
|
|
|
struct input_stream *input_stream);
|
|
|
|
|
2009-11-10 21:42:15 +01:00
|
|
|
void
|
|
|
|
flac_data_deinit(struct flac_data *data);
|
|
|
|
|
2009-11-11 20:34:59 +01:00
|
|
|
/**
|
|
|
|
* Obtains the audio format from the stream_info attribute, and copies
|
|
|
|
* it to the specified #audio_format object. This also updates the
|
|
|
|
* frame_size attribute.
|
|
|
|
*
|
|
|
|
* @return true on success, false the audio format is not supported
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
flac_data_get_audio_format(struct flac_data *data,
|
|
|
|
struct audio_format *audio_format);
|
|
|
|
|
2006-07-20 18:02:40 +02:00
|
|
|
void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
|
2009-01-15 19:50:28 +01:00
|
|
|
struct flac_data *data);
|
|
|
|
|
2006-07-20 18:02:40 +02:00
|
|
|
void flac_error_common_cb(const char *plugin,
|
|
|
|
FLAC__StreamDecoderErrorStatus status,
|
2009-01-15 19:50:28 +01:00
|
|
|
struct flac_data *data);
|
2006-03-16 07:52:46 +01:00
|
|
|
|
2008-09-23 23:59:54 +02:00
|
|
|
FLAC__StreamDecoderWriteStatus
|
2009-01-15 19:50:28 +01:00
|
|
|
flac_common_write(struct flac_data *data, const FLAC__Frame * frame,
|
2009-11-11 19:52:14 +01:00
|
|
|
const FLAC__int32 *const buf[],
|
|
|
|
FLAC__uint64 nbytes);
|
2006-03-16 07:52:46 +01:00
|
|
|
|
2009-03-08 20:16:53 +01:00
|
|
|
#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7
|
|
|
|
|
|
|
|
char*
|
|
|
|
flac_cue_track( const char* pathname,
|
|
|
|
const unsigned int tnum);
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
flac_vtrack_tnum( const char*);
|
|
|
|
|
|
|
|
#endif /* FLAC_API_VERSION_CURRENT >= 7 */
|
|
|
|
|
2006-07-20 20:53:56 +02:00
|
|
|
#endif /* _FLAC_COMMON_H */
|