1/* in_flac - Winamp2 FLAC input plugin 2 * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 */ 18 19#include "FLAC/all.h" 20#include "share/replaygain_synthesis.h" 21#include "plugin_common/all.h" 22 23/* 24 * constants 25 */ 26 27#define SAMPLES_PER_WRITE 576 28 29#define BITRATE_HIST_SEGMENT_MSEC 500 30#define BITRATE_HIST_SIZE 64 31 32/* 33 * common structures 34 */ 35 36typedef struct { 37 volatile FLAC__bool is_playing; 38 volatile FLAC__bool abort_flag; 39 volatile FLAC__bool eof; 40 volatile int seek_to; 41 FLAC__uint64 total_samples; 42 unsigned bits_per_sample; 43 unsigned output_bits_per_sample; 44 unsigned channels; 45 unsigned sample_rate; 46 int length_in_msec; /* int (instead of FLAC__uint64) only because that's what Winamp uses; seeking won't work right if this maxes out */ 47 unsigned average_bps; 48 FLAC__bool has_replaygain; 49 double replay_scale; 50 DitherContext dither_context; 51} stream_data_struct; 52 53 54typedef struct { 55 struct { 56 FLAC__bool enable; 57 FLAC__bool album_mode; 58 int preamp; 59 FLAC__bool hard_limit; 60 } replaygain; 61 struct { 62 struct { 63 FLAC__bool dither_24_to_16; 64 } normal; 65 struct { 66 FLAC__bool dither; 67 int noise_shaping; /* value must be one of NoiseShaping enum, see plugin_common/replaygain_synthesis.h */ 68 int bps_out; 69 } replaygain; 70 } resolution; 71 struct { 72 FLAC__bool stop_err; 73 } misc; 74} output_config_t; 75 76/* 77 * protopytes 78 */ 79 80FLAC__bool FLAC_plugin__decoder_init(FLAC__StreamDecoder *decoder, const char *filename, FLAC__int64 filesize, stream_data_struct *stream_data, output_config_t *config); 81void FLAC_plugin__decoder_finish(FLAC__StreamDecoder *decoder); 82void FLAC_plugin__decoder_delete(FLAC__StreamDecoder *decoder); 83 84int FLAC_plugin__seek(FLAC__StreamDecoder *decoder, stream_data_struct *stream_data); 85unsigned FLAC_plugin__decode(FLAC__StreamDecoder *decoder, stream_data_struct *stream_data, char *sample_buffer); 86int FLAC_plugin__get_rate(unsigned written_time, unsigned output_time, stream_data_struct *stream_data); 87 88/* 89 * these should be defined in plug-in 90 */ 91 92extern void FLAC_plugin__show_error(const char *message,...); 93