|
Lines 33-43
Link Here
|
| 33 |
#include <stdio.h> |
33 |
#include <stdio.h> |
| 34 |
#include <string.h> |
34 |
#include <string.h> |
| 35 |
#include <unistd.h> |
35 |
#include <unistd.h> |
|
|
36 |
#include <FLAC/export.h> |
| 37 |
#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT < 8 |
| 38 |
#define LEGACY_FLAC |
| 39 |
#else |
| 40 |
#undef LEGACY_FLAC |
| 41 |
#endif |
| 42 |
#ifdef LEGACY_FLAC |
| 36 |
#include <FLAC/seekable_stream_decoder.h> |
43 |
#include <FLAC/seekable_stream_decoder.h> |
|
|
44 |
#else |
| 45 |
#include <FLAC/stream_decoder.h> |
| 46 |
#endif |
| 37 |
#include <FLAC/metadata.h> |
47 |
#include <FLAC/metadata.h> |
| 38 |
|
48 |
|
| 39 |
/* this code is based on flac123, from flac-tools */ |
49 |
/* this code is based on flac123, from flac-tools */ |
| 40 |
|
50 |
|
|
|
51 |
#ifdef LEGACY_FLAC |
| 41 |
static void flacError(const FLAC__SeekableStreamDecoder *, |
52 |
static void flacError(const FLAC__SeekableStreamDecoder *, |
| 42 |
FLAC__StreamDecoderErrorStatus, void *); |
53 |
FLAC__StreamDecoderErrorStatus, void *); |
| 43 |
static void flacPrintErroredState(FLAC__SeekableStreamDecoderState state); |
54 |
static void flacPrintErroredState(FLAC__SeekableStreamDecoderState state); |
|
Lines 64-85
Link Here
|
| 64 |
*, FLAC__uint64 *, |
75 |
*, FLAC__uint64 *, |
| 65 |
void *); |
76 |
void *); |
| 66 |
static FLAC__bool flacEOF(const FLAC__SeekableStreamDecoder *, void *); |
77 |
static FLAC__bool flacEOF(const FLAC__SeekableStreamDecoder *, void *); |
|
|
78 |
#else |
| 79 |
static void flacError(const FLAC__StreamDecoder *, |
| 80 |
FLAC__StreamDecoderErrorStatus, void *); |
| 81 |
static void flacPrintErroredState(FLAC__StreamDecoderState state); |
| 82 |
static void flacMetadata(const FLAC__StreamDecoder *, |
| 83 |
const FLAC__StreamMetadata *, void *); |
| 84 |
static FLAC__StreamDecoderWriteStatus flacWrite(const |
| 85 |
FLAC__StreamDecoder *, |
| 86 |
const FLAC__Frame *, |
| 87 |
const FLAC__int32 * const buf[], |
| 88 |
void *); |
| 89 |
static FLAC__StreamDecoderReadStatus flacRead(const |
| 90 |
FLAC__StreamDecoder |
| 91 |
*, FLAC__byte buf[], |
| 92 |
size_t *, void *); |
| 93 |
static FLAC__StreamDecoderSeekStatus flacSeek(const |
| 94 |
FLAC__StreamDecoder |
| 95 |
*, FLAC__uint64, void *); |
| 96 |
static FLAC__StreamDecoderTellStatus flacTell(const |
| 97 |
FLAC__StreamDecoder |
| 98 |
*, FLAC__uint64 *, |
| 99 |
void *); |
| 100 |
static FLAC__StreamDecoderLengthStatus flacLength(const |
| 101 |
FLAC__StreamDecoder |
| 102 |
*, FLAC__uint64 *, |
| 103 |
void *); |
| 104 |
static FLAC__bool flacEOF(const FLAC__StreamDecoder *, void *); |
| 105 |
#endif |
| 67 |
|
106 |
|
| 68 |
static int flac_decode(OutputBuffer * cb, DecoderControl * dc, |
107 |
static int flac_decode(OutputBuffer * cb, DecoderControl * dc, |
| 69 |
InputStream * inStream) |
108 |
InputStream * inStream) |
| 70 |
{ |
109 |
{ |
|
|
110 |
#ifdef LEGACY_FLAC |
| 71 |
FLAC__SeekableStreamDecoder *flacDec = NULL; |
111 |
FLAC__SeekableStreamDecoder *flacDec = NULL; |
|
|
112 |
#else |
| 113 |
FLAC__StreamDecoder *flacDec = NULL; |
| 114 |
#endif |
| 72 |
FlacData data; |
115 |
FlacData data; |
| 73 |
int status = 1; |
116 |
int status = 1; |
| 74 |
int ret = 0; |
117 |
int ret = 0; |
| 75 |
|
118 |
|
| 76 |
init_FlacData(&data, cb, dc, inStream); |
119 |
init_FlacData(&data, cb, dc, inStream); |
| 77 |
|
120 |
|
|
|
121 |
#ifdef LEGACY_FLAC |
| 78 |
if (!(flacDec = FLAC__seekable_stream_decoder_new())) { |
122 |
if (!(flacDec = FLAC__seekable_stream_decoder_new())) { |
| 79 |
ret = -1; |
123 |
ret = -1; |
| 80 |
goto fail; |
124 |
goto fail; |
| 81 |
} |
125 |
} |
| 82 |
/*status&=FLAC__file_decoder_set_md5_checking(flacDec,1); */ |
126 |
/*status&=FLAC__seekable_decoder_set_md5_checking(flacDec,1); */ |
| 83 |
status &= FLAC__seekable_stream_decoder_set_read_callback(flacDec, |
127 |
status &= FLAC__seekable_stream_decoder_set_read_callback(flacDec, |
| 84 |
flacRead); |
128 |
flacRead); |
| 85 |
status &= FLAC__seekable_stream_decoder_set_seek_callback(flacDec, |
129 |
status &= FLAC__seekable_stream_decoder_set_seek_callback(flacDec, |
|
Lines 130-149
Link Here
|
| 130 |
ret = -1; |
174 |
ret = -1; |
| 131 |
goto fail; |
175 |
goto fail; |
| 132 |
} |
176 |
} |
|
|
177 |
#else |
| 178 |
if (!(flacDec = FLAC__stream_decoder_new())) { |
| 179 |
ret = -1; |
| 180 |
goto fail; |
| 181 |
} |
| 182 |
/*status&=FLAC__stream_decoder_set_md5_checking(flacDec,1); */ |
| 183 |
status &= FLAC__stream_decoder_set_metadata_respond(flacDec, FLAC__METADATA_TYPE_VORBIS_COMMENT); |
| 184 |
if (!status) { |
| 185 |
ERROR("flac problem before init()\n"); |
| 186 |
flacPrintErroredState(FLAC__stream_decoder_get_state(flacDec)); |
| 187 |
ret = -1; |
| 188 |
goto fail; |
| 189 |
} |
| 190 |
|
| 191 |
if (FLAC__stream_decoder_init_stream(flacDec, flacRead, flacSeek, flacTell, flacLength, flacEOF, flacWrite, flacMetadata, flacError, (void *)&data) != |
| 192 |
FLAC__STREAM_DECODER_INIT_STATUS_OK) { |
| 193 |
ERROR("flac problem doing init()\n"); |
| 194 |
flacPrintErroredState(FLAC__stream_decoder_get_state(flacDec)); |
| 195 |
ret = -1; |
| 196 |
goto fail; |
| 197 |
} |
| 198 |
|
| 199 |
if (!FLAC__stream_decoder_process_until_end_of_metadata(flacDec)) { |
| 200 |
ERROR("flac problem reading metadata\n"); |
| 201 |
flacPrintErroredState(FLAC__stream_decoder_get_state(flacDec)); |
| 202 |
ret = -1; |
| 203 |
goto fail; |
| 204 |
} |
| 205 |
#endif |
| 133 |
|
206 |
|
| 134 |
dc->state = DECODE_STATE_DECODE; |
207 |
dc->state = DECODE_STATE_DECODE; |
| 135 |
|
208 |
|
| 136 |
while (1) { |
209 |
while (1) { |
|
|
210 |
#ifdef LEGACY_FLAC |
| 137 |
FLAC__seekable_stream_decoder_process_single(flacDec); |
211 |
FLAC__seekable_stream_decoder_process_single(flacDec); |
| 138 |
if (FLAC__seekable_stream_decoder_get_state(flacDec) != |
212 |
if (FLAC__seekable_stream_decoder_get_state(flacDec) != |
| 139 |
FLAC__SEEKABLE_STREAM_DECODER_OK) { |
213 |
FLAC__SEEKABLE_STREAM_DECODER_OK) { |
| 140 |
break; |
214 |
break; |
| 141 |
} |
215 |
} |
|
|
216 |
#else |
| 217 |
FLAC__stream_decoder_process_single(flacDec); |
| 218 |
if (FLAC__stream_decoder_get_state(flacDec) > |
| 219 |
FLAC__STREAM_DECODER_READ_FRAME) { |
| 220 |
break; |
| 221 |
} |
| 222 |
#endif |
| 142 |
if (dc->seek) { |
223 |
if (dc->seek) { |
| 143 |
FLAC__uint64 sampleToSeek = dc->seekWhere * |
224 |
FLAC__uint64 sampleToSeek = dc->seekWhere * |
| 144 |
dc->audioFormat.sampleRate + 0.5; |
225 |
dc->audioFormat.sampleRate + 0.5; |
|
|
226 |
#ifdef LEGACY_FLAC |
| 145 |
if (FLAC__seekable_stream_decoder_seek_absolute(flacDec, |
227 |
if (FLAC__seekable_stream_decoder_seek_absolute(flacDec, |
| 146 |
sampleToSeek)) |
228 |
sampleToSeek)) |
|
|
229 |
#else |
| 230 |
if (FLAC__stream_decoder_seek_absolute(flacDec, sampleToSeek)) |
| 231 |
#endif |
| 147 |
{ |
232 |
{ |
| 148 |
clearOutputBuffer(cb); |
233 |
clearOutputBuffer(cb); |
| 149 |
data.time = ((float)sampleToSeek) / |
234 |
data.time = ((float)sampleToSeek) / |
|
Lines 157-165
Link Here
|
| 157 |
/* I don't think we need this bit here! -shank */ |
242 |
/* I don't think we need this bit here! -shank */ |
| 158 |
/*FLAC__file_decoder_process_until_end_of_file(flacDec); */ |
243 |
/*FLAC__file_decoder_process_until_end_of_file(flacDec); */ |
| 159 |
if (!dc->stop) { |
244 |
if (!dc->stop) { |
|
|
245 |
#ifdef LEGACY_FLAC |
| 160 |
flacPrintErroredState(FLAC__seekable_stream_decoder_get_state |
246 |
flacPrintErroredState(FLAC__seekable_stream_decoder_get_state |
| 161 |
(flacDec)); |
247 |
(flacDec)); |
| 162 |
FLAC__seekable_stream_decoder_finish(flacDec); |
248 |
FLAC__seekable_stream_decoder_finish(flacDec); |
|
|
249 |
#else |
| 250 |
flacPrintErroredState(FLAC__stream_decoder_get_state(flacDec)); |
| 251 |
FLAC__stream_decoder_finish(flacDec); |
| 252 |
#endif |
| 163 |
} |
253 |
} |
| 164 |
/* send last little bit */ |
254 |
/* send last little bit */ |
| 165 |
if (data.chunk_length > 0 && !dc->stop) { |
255 |
if (data.chunk_length > 0 && !dc->stop) { |
|
Lines 180-198
Link Here
|
| 180 |
freeReplayGainInfo(data.replayGainInfo); |
270 |
freeReplayGainInfo(data.replayGainInfo); |
| 181 |
|
271 |
|
| 182 |
if (flacDec) |
272 |
if (flacDec) |
|
|
273 |
#ifdef LEGACY_FLAC |
| 183 |
FLAC__seekable_stream_decoder_delete(flacDec); |
274 |
FLAC__seekable_stream_decoder_delete(flacDec); |
|
|
275 |
#else |
| 276 |
FLAC__stream_decoder_delete(flacDec); |
| 277 |
#endif |
| 184 |
|
278 |
|
| 185 |
closeInputStream(inStream); |
279 |
closeInputStream(inStream); |
| 186 |
|
280 |
|
| 187 |
return ret; |
281 |
return ret; |
| 188 |
} |
282 |
} |
| 189 |
|
283 |
|
|
|
284 |
#ifdef LEGACY_FLAC |
| 190 |
static FLAC__SeekableStreamDecoderReadStatus flacRead(const |
285 |
static FLAC__SeekableStreamDecoderReadStatus flacRead(const |
| 191 |
FLAC__SeekableStreamDecoder |
286 |
FLAC__SeekableStreamDecoder |
| 192 |
* flacDec, |
287 |
* flacDec, |
| 193 |
FLAC__byte buf[], |
288 |
FLAC__byte buf[], |
| 194 |
unsigned *bytes, |
289 |
unsigned *bytes, |
| 195 |
void *fdata) |
290 |
void *fdata) |
|
|
291 |
#else |
| 292 |
static FLAC__StreamDecoderReadStatus flacRead(const |
| 293 |
FLAC__StreamDecoder* flacDec, |
| 294 |
FLAC__byte buf[], |
| 295 |
size_t *bytes, |
| 296 |
void *fdata) |
| 297 |
#endif |
| 196 |
{ |
298 |
{ |
| 197 |
FlacData *data = (FlacData *) fdata; |
299 |
FlacData *data = (FlacData *) fdata; |
| 198 |
size_t r; |
300 |
size_t r; |
|
Lines 208-261
Link Here
|
| 208 |
*bytes = r; |
310 |
*bytes = r; |
| 209 |
|
311 |
|
| 210 |
if (*bytes == 0 && !inputStreamAtEOF(data->inStream) && !data->dc->stop) |
312 |
if (*bytes == 0 && !inputStreamAtEOF(data->inStream) && !data->dc->stop) |
|
|
313 |
#ifdef LEGACY_FLAC |
| 211 |
return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR; |
314 |
return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR; |
|
|
315 |
#else |
| 316 |
return FLAC__STREAM_DECODER_READ_STATUS_ABORT; |
| 317 |
#endif |
| 212 |
|
318 |
|
|
|
319 |
#ifdef LEGACY_FLAC |
| 213 |
return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK; |
320 |
return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK; |
|
|
321 |
#else |
| 322 |
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; |
| 323 |
#endif |
| 214 |
} |
324 |
} |
| 215 |
|
325 |
|
|
|
326 |
#ifdef LEGACY_FLAC |
| 216 |
static FLAC__SeekableStreamDecoderSeekStatus flacSeek(const |
327 |
static FLAC__SeekableStreamDecoderSeekStatus flacSeek(const |
| 217 |
FLAC__SeekableStreamDecoder |
328 |
FLAC__SeekableStreamDecoder |
| 218 |
* flacDec, |
329 |
* flacDec, |
| 219 |
FLAC__uint64 offset, |
330 |
FLAC__uint64 offset, |
| 220 |
void *fdata) |
331 |
void *fdata) |
|
|
332 |
#else |
| 333 |
static FLAC__StreamDecoderSeekStatus flacSeek(const |
| 334 |
FLAC__StreamDecoder* flacDec, |
| 335 |
FLAC__uint64 offset, |
| 336 |
void *fdata) |
| 337 |
#endif |
| 221 |
{ |
338 |
{ |
| 222 |
FlacData *data = (FlacData *) fdata; |
339 |
FlacData *data = (FlacData *) fdata; |
| 223 |
|
340 |
|
| 224 |
if (seekInputStream(data->inStream, offset, SEEK_SET) < 0) { |
341 |
if (seekInputStream(data->inStream, offset, SEEK_SET) < 0) { |
|
|
342 |
#ifdef LEGACY_FLAC |
| 225 |
return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR; |
343 |
return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR; |
|
|
344 |
#else |
| 345 |
return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; |
| 346 |
#endif |
| 226 |
} |
347 |
} |
| 227 |
|
348 |
|
|
|
349 |
#ifdef LEGACY_FLAC |
| 228 |
return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK; |
350 |
return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK; |
|
|
351 |
#else |
| 352 |
return FLAC__STREAM_DECODER_SEEK_STATUS_OK; |
| 353 |
#endif |
| 229 |
} |
354 |
} |
| 230 |
|
355 |
|
|
|
356 |
#ifdef LEGACY_FLAC |
| 231 |
static FLAC__SeekableStreamDecoderTellStatus flacTell(const |
357 |
static FLAC__SeekableStreamDecoderTellStatus flacTell(const |
| 232 |
FLAC__SeekableStreamDecoder |
358 |
FLAC__SeekableStreamDecoder* flacDec, |
| 233 |
* flacDec, |
359 |
FLAC__uint64 * offset, |
|
|
360 |
void *fdata) |
| 361 |
#else |
| 362 |
static FLAC__StreamDecoderTellStatus flacTell(const |
| 363 |
FLAC__StreamDecoder* flacDec, |
| 234 |
FLAC__uint64 * offset, |
364 |
FLAC__uint64 * offset, |
| 235 |
void *fdata) |
365 |
void *fdata) |
|
|
366 |
#endif |
| 236 |
{ |
367 |
{ |
| 237 |
FlacData *data = (FlacData *) fdata; |
368 |
FlacData *data = (FlacData *) fdata; |
| 238 |
|
369 |
|
| 239 |
*offset = (long)(data->inStream->offset); |
370 |
*offset = (long)(data->inStream->offset); |
| 240 |
|
371 |
|
|
|
372 |
#ifdef LEGACY_FLAC |
| 241 |
return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK; |
373 |
return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK; |
|
|
374 |
#else |
| 375 |
return FLAC__STREAM_DECODER_TELL_STATUS_OK; |
| 376 |
#endif |
| 242 |
} |
377 |
} |
| 243 |
|
378 |
|
|
|
379 |
#ifdef LEGACY_FLAC |
| 244 |
static FLAC__SeekableStreamDecoderLengthStatus flacLength(const |
380 |
static FLAC__SeekableStreamDecoderLengthStatus flacLength(const |
| 245 |
FLAC__SeekableStreamDecoder |
381 |
FLAC__SeekableStreamDecoder |
| 246 |
* flacDec, |
382 |
* flacDec, |
| 247 |
FLAC__uint64 * length, |
383 |
FLAC__uint64 * length, |
| 248 |
void *fdata) |
384 |
void *fdata) |
|
|
385 |
#else |
| 386 |
static FLAC__StreamDecoderLengthStatus flacLength(const |
| 387 |
FLAC__StreamDecoder* flacDec, |
| 388 |
FLAC__uint64 * length, |
| 389 |
void *fdata) |
| 390 |
#endif |
| 249 |
{ |
391 |
{ |
| 250 |
FlacData *data = (FlacData *) fdata; |
392 |
FlacData *data = (FlacData *) fdata; |
| 251 |
|
393 |
|
| 252 |
*length = (size_t) (data->inStream->size); |
394 |
*length = (size_t) (data->inStream->size); |
| 253 |
|
395 |
|
|
|
396 |
#ifdef LEGACY_FLAC |
| 254 |
return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK; |
397 |
return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK; |
|
|
398 |
#else |
| 399 |
return FLAC__STREAM_DECODER_LENGTH_STATUS_OK; |
| 400 |
#endif |
| 255 |
} |
401 |
} |
| 256 |
|
402 |
|
|
|
403 |
#ifdef LEGACY_FLAC |
| 257 |
static FLAC__bool flacEOF(const FLAC__SeekableStreamDecoder * flacDec, |
404 |
static FLAC__bool flacEOF(const FLAC__SeekableStreamDecoder * flacDec, |
| 258 |
void *fdata) |
405 |
void *fdata) |
|
|
406 |
#else |
| 407 |
static FLAC__bool flacEOF(const FLAC__StreamDecoder * flacDec, void *fdata) |
| 408 |
#endif |
| 259 |
{ |
409 |
{ |
| 260 |
FlacData *data = (FlacData *) fdata; |
410 |
FlacData *data = (FlacData *) fdata; |
| 261 |
|
411 |
|
|
Lines 264-277
Link Here
|
| 264 |
return false; |
414 |
return false; |
| 265 |
} |
415 |
} |
| 266 |
|
416 |
|
|
|
417 |
#ifdef LEGACY_FLAC |
| 267 |
static void flacError(const FLAC__SeekableStreamDecoder * dec, |
418 |
static void flacError(const FLAC__SeekableStreamDecoder * dec, |
| 268 |
FLAC__StreamDecoderErrorStatus status, void *fdata) |
419 |
FLAC__StreamDecoderErrorStatus status, void *fdata) |
|
|
420 |
#else |
| 421 |
static void flacError(const FLAC__StreamDecoder * dec, |
| 422 |
FLAC__StreamDecoderErrorStatus status, void *fdata) |
| 423 |
#endif |
| 269 |
{ |
424 |
{ |
| 270 |
flac_error_common_cb("flac", status, (FlacData *) fdata); |
425 |
flac_error_common_cb("flac", status, (FlacData *) fdata); |
| 271 |
} |
426 |
} |
| 272 |
|
427 |
|
|
|
428 |
#ifdef LEGACY_FLAC |
| 273 |
static void flacPrintErroredState(FLAC__SeekableStreamDecoderState state) |
429 |
static void flacPrintErroredState(FLAC__SeekableStreamDecoderState state) |
|
|
430 |
#else |
| 431 |
static void flacPrintErroredState(FLAC__StreamDecoderState state) |
| 432 |
#endif |
| 274 |
{ |
433 |
{ |
|
|
434 |
#ifdef LEGACY_FLAC |
| 275 |
switch (state) { |
435 |
switch (state) { |
| 276 |
case FLAC__SEEKABLE_STREAM_DECODER_MEMORY_ALLOCATION_ERROR: |
436 |
case FLAC__SEEKABLE_STREAM_DECODER_MEMORY_ALLOCATION_ERROR: |
| 277 |
ERROR("flac allocation error\n"); |
437 |
ERROR("flac allocation error\n"); |
|
Lines 299-317
Link Here
|
| 299 |
case FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM: |
459 |
case FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM: |
| 300 |
break; |
460 |
break; |
| 301 |
} |
461 |
} |
|
|
462 |
#else |
| 463 |
ERROR("%s\n", FLAC__StreamDecoderStateString[state]); |
| 464 |
#endif |
| 302 |
} |
465 |
} |
| 303 |
|
466 |
|
|
|
467 |
#ifdef LEGACY_FLAC |
| 304 |
static void flacMetadata(const FLAC__SeekableStreamDecoder * dec, |
468 |
static void flacMetadata(const FLAC__SeekableStreamDecoder * dec, |
| 305 |
const FLAC__StreamMetadata * block, void *vdata) |
469 |
const FLAC__StreamMetadata * block, void *vdata) |
|
|
470 |
#else |
| 471 |
static void flacMetadata(const FLAC__StreamDecoder * dec, |
| 472 |
const FLAC__StreamMetadata * block, void *vdata) |
| 473 |
#endif |
| 306 |
{ |
474 |
{ |
| 307 |
flac_metadata_common_cb(block, (FlacData *) vdata); |
475 |
flac_metadata_common_cb(block, (FlacData *) vdata); |
| 308 |
} |
476 |
} |
| 309 |
|
477 |
|
|
|
478 |
#ifdef LEGACY_FLAC |
| 310 |
static FLAC__StreamDecoderWriteStatus flacWrite(const |
479 |
static FLAC__StreamDecoderWriteStatus flacWrite(const |
| 311 |
FLAC__SeekableStreamDecoder * |
480 |
FLAC__SeekableStreamDecoder * |
| 312 |
dec, const FLAC__Frame * frame, |
481 |
dec, const FLAC__Frame * frame, |
| 313 |
const FLAC__int32 * const buf[], |
482 |
const FLAC__int32 * const buf[], |
| 314 |
void *vdata) |
483 |
void *vdata) |
|
|
484 |
#else |
| 485 |
static FLAC__StreamDecoderWriteStatus flacWrite(const |
| 486 |
FLAC__StreamDecoder * |
| 487 |
dec, const FLAC__Frame * frame, |
| 488 |
const FLAC__int32 * const buf[], |
| 489 |
void *vdata) |
| 490 |
#endif |
| 315 |
{ |
491 |
{ |
| 316 |
FlacData *data = (FlacData *) vdata; |
492 |
FlacData *data = (FlacData *) vdata; |
| 317 |
FLAC__uint32 samples = frame->header.blocksize; |
493 |
FLAC__uint32 samples = frame->header.blocksize; |
|
Lines 325-331
Link Here
|
| 325 |
timeChange = ((float)samples) / frame->header.sample_rate; |
501 |
timeChange = ((float)samples) / frame->header.sample_rate; |
| 326 |
data->time += timeChange; |
502 |
data->time += timeChange; |
| 327 |
|
503 |
|
|
|
504 |
#ifdef LEGACY_FLAC |
| 328 |
FLAC__seekable_stream_decoder_get_decode_position(dec, &newPosition); |
505 |
FLAC__seekable_stream_decoder_get_decode_position(dec, &newPosition); |
|
|
506 |
#else |
| 507 |
FLAC__stream_decoder_get_decode_position(dec, &newPosition); |
| 508 |
#endif |
| 329 |
if (data->position) { |
509 |
if (data->position) { |
| 330 |
data->bitRate = |
510 |
data->bitRate = |
| 331 |
((newPosition - data->position) * 8.0 / timeChange) |
511 |
((newPosition - data->position) * 8.0 / timeChange) |