]>
Commit | Line | Data |
---|---|---|
93c2b7ba ER |
1 | Index: /branches/release-0-20-fixes/mythplugins/mythmusic/mythmusic/flacencoder.h |
2 | =================================================================== | |
3 | --- /branches/release-0-20-fixes/mythplugins/mythmusic/mythmusic/flacencoder.h (revision 5420) | |
4 | +++ /branches/release-0-20-fixes/mythplugins/mythmusic/mythmusic/flacencoder.h (revision 12811) | |
5 | @@ -5,5 +5,72 @@ | |
6 | ||
7 | #define HAVE_INTTYPES_H | |
8 | -#include <FLAC/file_encoder.h> | |
9 | + | |
10 | +#include <FLAC/export.h> | |
11 | +#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7 | |
12 | + /* FLAC 1.0.4 to 1.1.2 */ | |
13 | + #include <FLAC/file_encoder.h> | |
14 | + #define encoder_new() FLAC__file_encoder_new() | |
15 | + #define encoder_setup(enc, streamable_subset, do_mid_side_stereo, \ | |
16 | + loose_mid_side_stereo, channels, bits_per_sample, \ | |
17 | + sample_rate, blocksize, max_lpc_order, \ | |
18 | + qlp_coeff_precision, do_qlp_coeff_prec_search, \ | |
19 | + do_escape_coding, do_exhaustive_model_search, \ | |
20 | + min_residual_partition_order, max_residual_partition_order, \ | |
21 | + rice_parameter_search_dist) \ | |
22 | + { \ | |
23 | + FLAC__file_encoder_set_streamable_subset(enc, streamable_subset) \ | |
24 | + FLAC__file_encoder_set_do_mid_side_stereo(enc, do_mid_side_stereo) \ | |
25 | + FLAC__file_encoder_set_loose_mid_side_stereo(enc, loose_mid_side_stereo) \ | |
26 | + FLAC__file_encoder_set_channels(enc, channels) \ | |
27 | + FLAC__file_encoder_set_bits_per_sample(enc, bits_per_sample) \ | |
28 | + FLAC__file_encoder_set_sample_rate(enc, sample_rate) \ | |
29 | + FLAC__file_encoder_set_blocksize(enc, blocksize) \ | |
30 | + FLAC__file_encoder_set_max_lpc_order(enc, max_lpc_order) \ | |
31 | + FLAC__file_encoder_set_qlp_coeff_precision(enc, qlp_coeff_precision) \ | |
32 | + FLAC__file_encoder_set_do_qlp_coeff_prec_search(enc, do_qlp_coeff_prec_search) \ | |
33 | + FLAC__file_encoder_set_do_escape_coding(enc, do_escape_coding) \ | |
34 | + FLAC__file_encoder_set_do_exhaustive_model_search(enc, do_exhaustive_model_search) \ | |
35 | + FLAC__file_encoder_set_min_residual_partition_order(enc, min_residual_partition_order) \ | |
36 | + FLAC__file_encoder_set_max_residual_partition_order(enc, max_residual_partition_order) \ | |
37 | + FLAC__file_encoder_set_rice_parameter_search_dist(enc, rice_parameter_search_dist) \ | |
38 | + } | |
39 | + #define encoder_finish(enc) FLAC__file_encoder_finish(enc) | |
40 | + #define encoder_delete(enc) FLAC__file_encoder_delete(enc) | |
41 | + #define encoder_process(enc, data, index) FLAC__file_encoder_process(enc, data, index) | |
42 | + #define FLAC_ENCODER FLAC__FileEncoder | |
43 | +#else | |
44 | + /* FLAC 1.1.3 and up */ | |
45 | + #define NEWFLAC | |
46 | + #include <FLAC/stream_encoder.h> | |
47 | + #define encoder_new() FLAC__stream_encoder_new() | |
48 | + #define encoder_setup(enc, streamable_subset, do_mid_side_stereo, \ | |
49 | + loose_mid_side_stereo, channels, bits_per_sample, \ | |
50 | + sample_rate, blocksize, max_lpc_order, \ | |
51 | + qlp_coeff_precision, do_qlp_coeff_prec_search, \ | |
52 | + do_escape_coding, do_exhaustive_model_search, \ | |
53 | + min_residual_partition_order, max_residual_partition_order, \ | |
54 | + rice_parameter_search_dist) \ | |
55 | + { \ | |
56 | + FLAC__stream_encoder_set_streamable_subset(enc, streamable_subset); \ | |
57 | + FLAC__stream_encoder_set_do_mid_side_stereo(enc, do_mid_side_stereo); \ | |
58 | + FLAC__stream_encoder_set_loose_mid_side_stereo(enc, loose_mid_side_stereo); \ | |
59 | + FLAC__stream_encoder_set_channels(enc, channels); \ | |
60 | + FLAC__stream_encoder_set_bits_per_sample(enc, bits_per_sample); \ | |
61 | + FLAC__stream_encoder_set_sample_rate(enc, sample_rate); \ | |
62 | + FLAC__stream_encoder_set_blocksize(enc, blocksize); \ | |
63 | + FLAC__stream_encoder_set_max_lpc_order(enc, max_lpc_order); \ | |
64 | + FLAC__stream_encoder_set_qlp_coeff_precision(enc, qlp_coeff_precision); \ | |
65 | + FLAC__stream_encoder_set_do_qlp_coeff_prec_search(enc, do_qlp_coeff_prec_search); \ | |
66 | + FLAC__stream_encoder_set_do_escape_coding(enc, do_escape_coding); \ | |
67 | + FLAC__stream_encoder_set_do_exhaustive_model_search(enc, do_exhaustive_model_search); \ | |
68 | + FLAC__stream_encoder_set_min_residual_partition_order(enc, min_residual_partition_order); \ | |
69 | + FLAC__stream_encoder_set_max_residual_partition_order(enc, max_residual_partition_order); \ | |
70 | + FLAC__stream_encoder_set_rice_parameter_search_dist(enc, rice_parameter_search_dist); \ | |
71 | + } | |
72 | + #define encoder_finish(enc) FLAC__stream_encoder_finish(enc) | |
73 | + #define encoder_delete(enc) FLAC__stream_encoder_delete(enc) | |
74 | + #define encoder_process(enc, data, index) FLAC__stream_encoder_process(enc, data, index) | |
75 | + #define FLAC_ENCODER FLAC__StreamEncoder | |
76 | +#endif | |
77 | ||
78 | #include "encoder.h" | |
79 | @@ -22,5 +89,5 @@ | |
80 | ||
81 | private: | |
82 | - FLAC__FileEncoder *encoder; | |
83 | + FLAC_ENCODER *encoder; | |
84 | unsigned int sampleindex; | |
85 | FLAC__int32 inputin[NUM_CHANNELS][MAX_SAMPLES]; | |
86 | Index: /branches/release-0-20-fixes/mythplugins/mythmusic/mythmusic/flacdecoder.h | |
87 | =================================================================== | |
88 | --- /branches/release-0-20-fixes/mythplugins/mythmusic/mythmusic/flacdecoder.h (revision 7611) | |
89 | +++ /branches/release-0-20-fixes/mythplugins/mythmusic/mythmusic/flacdecoder.h (revision 12811) | |
90 | @@ -4,4 +4,71 @@ | |
91 | #define HAVE_INTTYPES_H | |
92 | #include <FLAC/all.h> | |
93 | +#include <FLAC/export.h> | |
94 | +#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7 | |
95 | + /* FLAC 1.0.4 to 1.1.2 */ | |
96 | + #define StreamDecoderReadStatus FLAC__SeekableStreamDecoderReadStatus | |
97 | + #define StreamDecoder FLAC__SeekableStreamDecoder | |
98 | + #define STREAM_DECODER_READ_STATUS_ERROR FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR | |
99 | + #define STREAM_DECODER_READ_STATUS_OK FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK | |
100 | + #define StreamDecoderSeekStatus FLAC__SeekableStreamDecoderSeekStatus | |
101 | + #define STREAM_DECODER_SEEK_STATUS_ERROR FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR | |
102 | + #define STREAM_DECODER_SEEK_STATUS_OK FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK | |
103 | + #define StreamDecoderTellStatus FLAC__SeekableStreamDecoderTellStatus | |
104 | + #define STREAM_DECODER_TELL_STATUS_OK FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK | |
105 | + #define StreamDecoderLengthStatus FLAC__SeekableStreamDecoderLengthStatus | |
106 | + #define STREAM_DECODER_LENGTH_STATUS_OK FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK | |
107 | + #define FileDecoder FLAC__FileDecoder | |
108 | + #define decoder_new() FLAC__seekable_stream_decoder_new() | |
109 | + #define decoder_set_md5_checking(dec, op) \ | |
110 | + FLAC__seekable_stream_decoder_set_md5_checking(dec, op) | |
111 | + #define decoder_setup(dec, read, seek, tell, length, \ | |
112 | + eof, write, metadata, error, data) \ | |
113 | + { \ | |
114 | + FLAC__seekable_stream_decoder_set_read_callback(dec, read); \ | |
115 | + FLAC__seekable_stream_decoder_set_seek_callback(dec, seek); \ | |
116 | + FLAC__seekable_stream_decoder_set_tell_callback(dec, tell); \ | |
117 | + FLAC__seekable_stream_decoder_set_length_callback(dec, length); \ | |
118 | + FLAC__seekable_stream_decoder_set_eof_callback(dec, eof); \ | |
119 | + FLAC__seekable_stream_decoder_set_write_callback(dec, write); \ | |
120 | + FLAC__seekable_stream_decoder_set_metadata_callback(dec, metadata); \ | |
121 | + FLAC__seekable_stream_decoder_set_error_callback(dec, error); \ | |
122 | + FLAC__seekable_stream_decoder_set_client_data(dec, data); \ | |
123 | + } | |
124 | + #define decoder_process_metadata FLAC__seekable_stream_decoder_process_until_end_of_metadata | |
125 | + #define decoder_finish FLAC__seekable_stream_decoder_finish | |
126 | + #define decoder_delete FLAC__seekable_stream_decoder_delete | |
127 | + #define DecoderState FLAC__SeekableStreamDecoderState | |
128 | + #define decoder_seek_absolute FLAC__seekable_stream_decoder_seek_absolute | |
129 | + #define decoder_process_single FLAC__seekable_stream_decoder_process_single | |
130 | + #define decoder_get_state FLAC__seekable_stream_decoder_get_state | |
131 | +#else | |
132 | + /* FLAC 1.1.3 and up */ | |
133 | + #define NEWFLAC | |
134 | + #define StreamDecoderReadStatus FLAC__StreamDecoderReadStatus | |
135 | + #define StreamDecoder FLAC__StreamDecoder | |
136 | + #define STREAM_DECODER_READ_STATUS_ERROR FLAC__STREAM_DECODER_READ_STATUS_ABORT | |
137 | + #define STREAM_DECODER_READ_STATUS_OK FLAC__STREAM_DECODER_READ_STATUS_CONTINUE | |
138 | + #define StreamDecoderSeekStatus FLAC__StreamDecoderSeekStatus | |
139 | + #define STREAM_DECODER_SEEK_STATUS_ERROR FLAC__STREAM_DECODER_SEEK_STATUS_ERROR | |
140 | + #define STREAM_DECODER_SEEK_STATUS_OK FLAC__STREAM_DECODER_SEEK_STATUS_OK | |
141 | + #define StreamDecoderTellStatus FLAC__StreamDecoderTellStatus | |
142 | + #define STREAM_DECODER_TELL_STATUS_OK FLAC__STREAM_DECODER_TELL_STATUS_OK | |
143 | + #define StreamDecoderLengthStatus FLAC__StreamDecoderLengthStatus | |
144 | + #define STREAM_DECODER_LENGTH_STATUS_OK FLAC__STREAM_DECODER_LENGTH_STATUS_OK | |
145 | + #define FileDecoder FLAC__StreamDecoder | |
146 | + #define decoder_new() FLAC__stream_decoder_new() | |
147 | + #define decoder_set_md5_checking(dec, op) \ | |
148 | + FLAC__stream_decoder_set_md5_checking(dec, op) | |
149 | + #define decoder_setup(decoder, read, seek, tell, length, eof, write, metadata, error, data) \ | |
150 | + FLAC__stream_decoder_init_stream(decoder, read, seek, tell, length, \ | |
151 | + eof, write, metadata, error, data) | |
152 | + #define decoder_process_metadata FLAC__stream_decoder_process_until_end_of_metadata | |
153 | + #define decoder_finish FLAC__stream_decoder_finish | |
154 | + #define decoder_delete FLAC__stream_decoder_delete | |
155 | + #define DecoderState FLAC__StreamDecoderState | |
156 | + #define decoder_seek_absolute FLAC__stream_decoder_seek_absolute | |
157 | + #define decoder_process_single FLAC__stream_decoder_process_single | |
158 | + #define decoder_get_state FLAC__stream_decoder_get_state | |
159 | +#endif | |
160 | ||
161 | #include "decoder.h" | |
162 | @@ -36,5 +103,5 @@ | |
163 | ulong output_bytes, output_at; | |
164 | ||
165 | - FLAC__SeekableStreamDecoder *decoder; | |
166 | + StreamDecoder *decoder; | |
167 | ||
168 | unsigned int bks; | |
169 | Index: /branches/release-0-20-fixes/mythplugins/mythmusic/mythmusic/flacencoder.cpp | |
170 | =================================================================== | |
171 | --- /branches/release-0-20-fixes/mythplugins/mythmusic/mythmusic/flacencoder.cpp (revision 5215) | |
172 | +++ /branches/release-0-20-fixes/mythplugins/mythmusic/mythmusic/flacencoder.cpp (revision 12811) | |
173 | @@ -10,5 +10,13 @@ | |
174 | #include "metaioflacvorbiscomment.h" | |
175 | ||
176 | -#include <FLAC/file_encoder.h> | |
177 | +#include <FLAC/export.h> | |
178 | +#if !defined(NEWFLAC) | |
179 | + /* FLAC 1.0.4 to 1.1.2 */ | |
180 | + #include <FLAC/file_encoder.h> | |
181 | +#else | |
182 | + /* FLAC 1.1.3 and up */ | |
183 | + #include <FLAC/stream_encoder.h> | |
184 | +#endif | |
185 | + | |
186 | #include <FLAC/assert.h> | |
187 | #include <mythtv/mythcontext.h> | |
188 | @@ -20,40 +28,45 @@ | |
189 | sampleindex = 0; | |
190 | ||
191 | - int blocksize = 4608; | |
192 | - bool do_exhaustive_model_search = false; | |
193 | - bool do_escape_coding = false; | |
194 | + bool streamable_subset = true; | |
195 | bool do_mid_side = true; | |
196 | bool loose_mid_side = false; | |
197 | + int bits_per_sample = 16; | |
198 | + int sample_rate = 44100; | |
199 | + int blocksize = 4608; | |
200 | + int max_lpc_order = 8; | |
201 | int qlp_coeff_precision = 0; | |
202 | - int min_residual_partition_order = 3, max_residual_partition_order = 3; | |
203 | + bool qlp_coeff_prec_search = false; | |
204 | + bool do_escape_coding = false; | |
205 | + bool do_exhaustive_model_search = false; | |
206 | + int min_residual_partition_order = 3; | |
207 | + int max_residual_partition_order = 3; | |
208 | int rice_parameter_search_dist = 0; | |
209 | - int max_lpc_order = 8; | |
210 | ||
211 | - encoder = FLAC__file_encoder_new(); | |
212 | + encoder = encoder_new(); | |
213 | + encoder_setup(encoder, streamable_subset, \ | |
214 | + do_mid_side, loose_mid_side, \ | |
215 | + NUM_CHANNELS, bits_per_sample, \ | |
216 | + sample_rate, blocksize, \ | |
217 | + max_lpc_order, qlp_coeff_precision, \ | |
218 | + qlp_coeff_prec_search, do_escape_coding, \ | |
219 | + do_exhaustive_model_search, \ | |
220 | + min_residual_partition_order, \ | |
221 | + max_residual_partition_order, \ | |
222 | + rice_parameter_search_dist); | |
223 | ||
224 | - FLAC__file_encoder_set_streamable_subset(encoder, true); | |
225 | - FLAC__file_encoder_set_do_mid_side_stereo(encoder, do_mid_side); | |
226 | - FLAC__file_encoder_set_loose_mid_side_stereo(encoder, loose_mid_side); | |
227 | - FLAC__file_encoder_set_channels(encoder, NUM_CHANNELS); | |
228 | - FLAC__file_encoder_set_bits_per_sample(encoder, 16); | |
229 | - FLAC__file_encoder_set_sample_rate(encoder, 44100); | |
230 | - FLAC__file_encoder_set_blocksize(encoder, blocksize); | |
231 | - FLAC__file_encoder_set_max_lpc_order(encoder, max_lpc_order); | |
232 | - FLAC__file_encoder_set_qlp_coeff_precision(encoder, qlp_coeff_precision); | |
233 | - FLAC__file_encoder_set_do_qlp_coeff_prec_search(encoder, false); | |
234 | - FLAC__file_encoder_set_do_escape_coding(encoder, do_escape_coding); | |
235 | - FLAC__file_encoder_set_do_exhaustive_model_search(encoder, | |
236 | - do_exhaustive_model_search); | |
237 | - FLAC__file_encoder_set_min_residual_partition_order(encoder, | |
238 | - min_residual_partition_order); | |
239 | - FLAC__file_encoder_set_max_residual_partition_order(encoder, | |
240 | - max_residual_partition_order); | |
241 | - FLAC__file_encoder_set_rice_parameter_search_dist(encoder, | |
242 | - rice_parameter_search_dist); | |
243 | - | |
244 | +#if !defined(NEWFLAC) | |
245 | + /* FLAC 1.0.4 to 1.1.2 */ | |
246 | FLAC__file_encoder_set_filename(encoder, outfile.local8Bit()); | |
247 | ||
248 | int ret = FLAC__file_encoder_init(encoder); | |
249 | if (ret != FLAC__FILE_ENCODER_OK) | |
250 | +#else | |
251 | + /* FLAC 1.1.3 and up */ | |
252 | + int ret = FLAC__stream_encoder_init_file(encoder, | |
253 | + outfile.local8Bit(), | |
254 | + NULL, | |
255 | + NULL); | |
256 | + if(ret != FLAC__STREAM_ENCODER_INIT_STATUS_OK) | |
257 | +#endif | |
258 | { | |
259 | VERBOSE(VB_GENERAL, QString("Error initializing FLAC encoder." | |
260 | @@ -71,6 +84,6 @@ | |
261 | if (encoder) | |
262 | { | |
263 | - FLAC__file_encoder_finish(encoder); | |
264 | - FLAC__file_encoder_delete(encoder); | |
265 | + encoder_finish(encoder); | |
266 | + encoder_delete(encoder); | |
267 | } | |
268 | ||
269 | @@ -103,7 +116,6 @@ | |
270 | if(sampleindex == MAX_SAMPLES || (length == 0 && sampleindex > 0) ) | |
271 | { | |
272 | - if (!FLAC__file_encoder_process(encoder, | |
273 | - (const FLAC__int32 * const *) input, | |
274 | - sampleindex)) | |
275 | + if (!encoder_process(encoder, (const FLAC__int32 * const *) input, | |
276 | + sampleindex)) | |
277 | { | |
278 | VERBOSE(VB_GENERAL, QString("Failed to write flac data." | |
279 | Index: /branches/release-0-20-fixes/mythplugins/mythmusic/mythmusic/flacdecoder.cpp | |
280 | =================================================================== | |
281 | --- /branches/release-0-20-fixes/mythplugins/mythmusic/mythmusic/flacdecoder.cpp (revision 9718) | |
282 | +++ /branches/release-0-20-fixes/mythplugins/mythmusic/mythmusic/flacdecoder.cpp (revision 12811) | |
283 | @@ -18,5 +18,5 @@ | |
284 | #include <qtimer.h> | |
285 | ||
286 | -static FLAC__SeekableStreamDecoderReadStatus flacread(const FLAC__SeekableStreamDecoder *decoder, FLAC__byte bufferp[], unsigned *bytes, void *client_data) | |
287 | +static StreamDecoderReadStatus flacread(const StreamDecoder *decoder, FLAC__byte bufferp[], unsigned *bytes, void *client_data) | |
288 | { | |
289 | decoder = decoder; | |
290 | @@ -27,12 +27,12 @@ | |
291 | if (len == -1) | |
292 | { | |
293 | - return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR; | |
294 | + return STREAM_DECODER_READ_STATUS_ERROR; | |
295 | } | |
296 | ||
297 | *bytes = len; | |
298 | - return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK; | |
299 | -} | |
300 | - | |
301 | -static FLAC__SeekableStreamDecoderSeekStatus flacseek(const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data) | |
302 | + return STREAM_DECODER_READ_STATUS_OK; | |
303 | +} | |
304 | + | |
305 | +static StreamDecoderSeekStatus flacseek(const StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data) | |
306 | { | |
307 | decoder = decoder; | |
308 | @@ -40,12 +40,12 @@ | |
309 | ||
310 | if (!dflac->input()->isDirectAccess()) | |
311 | - return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR; | |
312 | + return STREAM_DECODER_SEEK_STATUS_ERROR; | |
313 | ||
314 | if (dflac->input()->at(absolute_byte_offset)) | |
315 | - return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK; | |
316 | - return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR; | |
317 | -} | |
318 | - | |
319 | -static FLAC__SeekableStreamDecoderTellStatus flactell(const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) | |
320 | + return STREAM_DECODER_SEEK_STATUS_OK; | |
321 | + return STREAM_DECODER_SEEK_STATUS_ERROR; | |
322 | +} | |
323 | + | |
324 | +static StreamDecoderTellStatus flactell(const StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) | |
325 | { | |
326 | decoder = decoder; | |
327 | @@ -55,8 +55,8 @@ | |
328 | *absolute_byte_offset = t; | |
329 | ||
330 | - return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK; | |
331 | -} | |
332 | - | |
333 | -static FLAC__SeekableStreamDecoderLengthStatus flaclength(const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data) | |
334 | + return STREAM_DECODER_TELL_STATUS_OK; | |
335 | +} | |
336 | + | |
337 | +static StreamDecoderLengthStatus flaclength(const StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data) | |
338 | { | |
339 | decoder = decoder; | |
340 | @@ -65,8 +65,8 @@ | |
341 | ||
342 | *stream_length = dflac->input()->size(); | |
343 | - return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK; | |
344 | -} | |
345 | - | |
346 | -static FLAC__bool flaceof(const FLAC__SeekableStreamDecoder *decoder, void *client_data) | |
347 | + return STREAM_DECODER_LENGTH_STATUS_OK; | |
348 | +} | |
349 | + | |
350 | +static FLAC__bool flaceof(const StreamDecoder *decoder, void *client_data) | |
351 | { | |
352 | decoder = decoder; | |
353 | @@ -77,5 +77,5 @@ | |
354 | } | |
355 | ||
356 | -static FLAC__StreamDecoderWriteStatus flacwrite(const FLAC__SeekableStreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) | |
357 | +static FLAC__StreamDecoderWriteStatus flacwrite(const StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) | |
358 | { | |
359 | decoder = decoder; | |
360 | @@ -133,5 +133,5 @@ | |
361 | } | |
362 | ||
363 | -static void flacmetadata(const FLAC__SeekableStreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) | |
364 | +static void flacmetadata(const StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) | |
365 | { | |
366 | decoder = decoder; | |
367 | @@ -157,9 +157,9 @@ | |
368 | } | |
369 | ||
370 | -static void flacerror(const FLAC__SeekableStreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) | |
371 | -{ | |
372 | - decoder = decoder; | |
373 | - | |
374 | - FLAC__FileDecoder *file_decoder = (FLAC__FileDecoder *)client_data; | |
375 | +static void flacerror(const StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) | |
376 | +{ | |
377 | + decoder = decoder; | |
378 | + | |
379 | + FileDecoder *file_decoder = (FileDecoder *)client_data; | |
380 | ||
381 | file_decoder = file_decoder; | |
382 | @@ -263,15 +263,8 @@ | |
383 | } | |
384 | ||
385 | - decoder = FLAC__seekable_stream_decoder_new(); | |
386 | - FLAC__seekable_stream_decoder_set_md5_checking(decoder, false); | |
387 | - FLAC__seekable_stream_decoder_set_read_callback(decoder, flacread); | |
388 | - FLAC__seekable_stream_decoder_set_seek_callback(decoder, flacseek); | |
389 | - FLAC__seekable_stream_decoder_set_tell_callback(decoder, flactell); | |
390 | - FLAC__seekable_stream_decoder_set_length_callback(decoder, flaclength); | |
391 | - FLAC__seekable_stream_decoder_set_eof_callback(decoder, flaceof); | |
392 | - FLAC__seekable_stream_decoder_set_write_callback(decoder, flacwrite); | |
393 | - FLAC__seekable_stream_decoder_set_metadata_callback(decoder, flacmetadata); | |
394 | - FLAC__seekable_stream_decoder_set_error_callback(decoder, flacerror); | |
395 | - FLAC__seekable_stream_decoder_set_client_data(decoder, this); | |
396 | + decoder = decoder_new(); | |
397 | + decoder_set_md5_checking(decoder, false); | |
398 | + decoder_setup(decoder, flacread, flacseek, flactell, flaclength, \ | |
399 | + flaceof, flacwrite, flacmetadata, flacerror, this); | |
400 | ||
401 | freq = 0; | |
402 | @@ -282,6 +275,8 @@ | |
403 | totalTime = totalTime < 0 ? 0 : totalTime; | |
404 | ||
405 | +#if !defined(NEWFLAC) | |
406 | FLAC__seekable_stream_decoder_init(decoder); | |
407 | - FLAC__seekable_stream_decoder_process_until_end_of_metadata(decoder); | |
408 | +#endif | |
409 | + decoder_process_metadata(decoder); | |
410 | ||
411 | inited = TRUE; | |
412 | @@ -296,6 +291,6 @@ | |
413 | void FlacDecoder::deinit() | |
414 | { | |
415 | - FLAC__seekable_stream_decoder_finish(decoder); | |
416 | - FLAC__seekable_stream_decoder_delete(decoder); | |
417 | + decoder_finish(decoder); | |
418 | + decoder_delete(decoder); | |
419 | ||
420 | if (input()->isOpen()) | |
421 | @@ -331,5 +326,5 @@ | |
422 | ||
423 | bool flacok = true; | |
424 | - FLAC__SeekableStreamDecoderState decoderstate; | |
425 | + DecoderState decoderstate; | |
426 | ||
427 | while (! done && ! finish) { | |
428 | @@ -341,10 +336,10 @@ | |
429 | if (sample > totalsamples - 50) | |
430 | sample = totalsamples - 50; | |
431 | - FLAC__seekable_stream_decoder_seek_absolute(decoder, sample); | |
432 | + decoder_seek_absolute(decoder, sample); | |
433 | seekTime = -1.0; | |
434 | } | |
435 | ||
436 | - flacok = FLAC__seekable_stream_decoder_process_single(decoder); | |
437 | - decoderstate = FLAC__seekable_stream_decoder_get_state(decoder); | |
438 | + flacok = decoder_process_single(decoder); | |
439 | + decoderstate = decoder_get_state(decoder); | |
440 | ||
441 | if (decoderstate == 0 || decoderstate == 1) | |
442 | Index: /branches/release-0-20-fixes/mythplugins/mythmusic/mythmusic/flacencoder.h | |
443 | =================================================================== | |
444 | --- /branches/release-0-20-fixes/mythplugins/mythmusic/mythmusic/flacencoder.h (revision 12811) | |
445 | +++ /branches/release-0-20-fixes/mythplugins/mythmusic/mythmusic/flacencoder.h (revision 12824) | |
446 | @@ -19,19 +19,19 @@ | |
447 | rice_parameter_search_dist) \ | |
448 | { \ | |
449 | - FLAC__file_encoder_set_streamable_subset(enc, streamable_subset) \ | |
450 | - FLAC__file_encoder_set_do_mid_side_stereo(enc, do_mid_side_stereo) \ | |
451 | - FLAC__file_encoder_set_loose_mid_side_stereo(enc, loose_mid_side_stereo) \ | |
452 | - FLAC__file_encoder_set_channels(enc, channels) \ | |
453 | - FLAC__file_encoder_set_bits_per_sample(enc, bits_per_sample) \ | |
454 | - FLAC__file_encoder_set_sample_rate(enc, sample_rate) \ | |
455 | - FLAC__file_encoder_set_blocksize(enc, blocksize) \ | |
456 | - FLAC__file_encoder_set_max_lpc_order(enc, max_lpc_order) \ | |
457 | - FLAC__file_encoder_set_qlp_coeff_precision(enc, qlp_coeff_precision) \ | |
458 | - FLAC__file_encoder_set_do_qlp_coeff_prec_search(enc, do_qlp_coeff_prec_search) \ | |
459 | - FLAC__file_encoder_set_do_escape_coding(enc, do_escape_coding) \ | |
460 | - FLAC__file_encoder_set_do_exhaustive_model_search(enc, do_exhaustive_model_search) \ | |
461 | - FLAC__file_encoder_set_min_residual_partition_order(enc, min_residual_partition_order) \ | |
462 | - FLAC__file_encoder_set_max_residual_partition_order(enc, max_residual_partition_order) \ | |
463 | - FLAC__file_encoder_set_rice_parameter_search_dist(enc, rice_parameter_search_dist) \ | |
464 | + FLAC__file_encoder_set_streamable_subset(enc, streamable_subset); \ | |
465 | + FLAC__file_encoder_set_do_mid_side_stereo(enc, do_mid_side_stereo); \ | |
466 | + FLAC__file_encoder_set_loose_mid_side_stereo(enc, loose_mid_side_stereo); \ | |
467 | + FLAC__file_encoder_set_channels(enc, channels); \ | |
468 | + FLAC__file_encoder_set_bits_per_sample(enc, bits_per_sample); \ | |
469 | + FLAC__file_encoder_set_sample_rate(enc, sample_rate); \ | |
470 | + FLAC__file_encoder_set_blocksize(enc, blocksize); \ | |
471 | + FLAC__file_encoder_set_max_lpc_order(enc, max_lpc_order); \ | |
472 | + FLAC__file_encoder_set_qlp_coeff_precision(enc, qlp_coeff_precision); \ | |
473 | + FLAC__file_encoder_set_do_qlp_coeff_prec_search(enc, do_qlp_coeff_prec_search); \ | |
474 | + FLAC__file_encoder_set_do_escape_coding(enc, do_escape_coding); \ | |
475 | + FLAC__file_encoder_set_do_exhaustive_model_search(enc, do_exhaustive_model_search); \ | |
476 | + FLAC__file_encoder_set_min_residual_partition_order(enc, min_residual_partition_order); \ | |
477 | + FLAC__file_encoder_set_max_residual_partition_order(enc, max_residual_partition_order); \ | |
478 | + FLAC__file_encoder_set_rice_parameter_search_dist(enc, rice_parameter_search_dist); \ | |
479 | } | |
480 | #define encoder_finish(enc) FLAC__file_encoder_finish(enc) | |
481 | Index: /branches/release-0-20-fixes/mythplugins/mythmusic/mythmusic/flacdecoder.h | |
482 | =================================================================== | |
483 | --- /branches/release-0-20-fixes/mythplugins/mythmusic/mythmusic/flacdecoder.h (revision 12811) | |
484 | +++ /branches/release-0-20-fixes/mythplugins/mythmusic/mythmusic/flacdecoder.h (revision 12853) | |
485 | @@ -42,4 +42,5 @@ | |
486 | #define decoder_process_single FLAC__seekable_stream_decoder_process_single | |
487 | #define decoder_get_state FLAC__seekable_stream_decoder_get_state | |
488 | + #define bytesSize unsigned | |
489 | #else | |
490 | /* FLAC 1.1.3 and up */ | |
491 | @@ -70,4 +71,5 @@ | |
492 | #define decoder_process_single FLAC__stream_decoder_process_single | |
493 | #define decoder_get_state FLAC__stream_decoder_get_state | |
494 | + #define bytesSize size_t | |
495 | #endif | |
496 | ||
497 | Index: /branches/release-0-20-fixes/mythplugins/mythmusic/mythmusic/flacdecoder.cpp | |
498 | =================================================================== | |
499 | --- /branches/release-0-20-fixes/mythplugins/mythmusic/mythmusic/flacdecoder.cpp (revision 12811) | |
500 | +++ /branches/release-0-20-fixes/mythplugins/mythmusic/mythmusic/flacdecoder.cpp (revision 12853) | |
501 | @@ -18,5 +18,5 @@ | |
502 | #include <qtimer.h> | |
503 | ||
504 | -static StreamDecoderReadStatus flacread(const StreamDecoder *decoder, FLAC__byte bufferp[], unsigned *bytes, void *client_data) | |
505 | +static StreamDecoderReadStatus flacread(const StreamDecoder *decoder, FLAC__byte bufferp[], bytesSize *bytes, void *client_data) | |
506 | { | |
507 | decoder = decoder; | |
508 | @@ -265,5 +265,5 @@ | |
509 | decoder = decoder_new(); | |
510 | decoder_set_md5_checking(decoder, false); | |
511 | - decoder_setup(decoder, flacread, flacseek, flactell, flaclength, \ | |
512 | + decoder_setup(decoder, flacread, flacseek, flactell, flaclength, | |
513 | flaceof, flacwrite, flacmetadata, flacerror, this); | |
514 |