1 diff -r -u scummvm-0.9.0/configure scummvm-0.9.0-b2/configure
2 --- scummvm-0.9.0/configure 2006-06-21 14:19:07.000000000 -0700
3 +++ scummvm-0.9.0-b2/configure 2006-10-25 00:10:35.000000000 -0700
4 @@ -1076,15 +1076,15 @@
5 if test "$_flac" = auto ; then
8 -#include <FLAC/seekable_stream_decoder.h>
9 -int main(void) { FLAC__seekable_stream_decoder_init( 0 ); return 0; }
10 +#include <FLAC/format.h>
11 +int main(void) { return FLAC__STREAM_SYNC_LEN >> 30; /* guaranteed to be 0 */ }
13 - cc_check $LDFLAGS $CXXFLAGS $FLAC_CFLAGS $FLAC_LIBS \
14 - -lFLAC -lm && _flac=yes
15 + cc_check $LDFLAGS $CXXFLAGS $FLAC_CFLAGS $FLAC_LIBS $OGG_CFLAGS $OGG_LIBS \
16 + -lFLAC -logg -lm && _flac=yes
18 if test "$_flac" = yes ; then
19 _def_flac='#define USE_FLAC'
20 - LIBS="$LIBS $FLAC_LIBS -lFLAC"
21 + LIBS="$LIBS $FLAC_LIBS $OGG_LIBS -lFLAC -logg"
22 INCLUDES="$INCLUDES $FLAC_CFLAGS"
24 _def_flac='#undef USE_FLAC'
25 diff -r -u scummvm-0.9.0/sound/flac.cpp scummvm-0.9.0-b2/sound/flac.cpp
26 --- scummvm-0.9.0/sound/flac.cpp 2006-06-21 14:16:13.000000000 -0700
27 +++ scummvm-0.9.0-b2/sound/flac.cpp 2006-10-25 00:08:18.000000000 -0700
29 #include "sound/audiocd.h"
31 #define FLAC__NO_DLL // that MS-magic gave me headaches - just link the library you like
32 +#include <FLAC/export.h>
33 +// check if we have FLAC >= 1.1.3; LEGACY_FLAC code can be removed once FLAC-1.1.3 propagates everywhere
34 +#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT < 8
40 #include <FLAC/seekable_stream_decoder.h>
42 +#include <FLAC/stream_decoder.h>
49 const FLAC__StreamMetadata_StreamInfo& getStreamInfo() const {return _streaminfo;}
52 inline FLAC__SeekableStreamDecoderState getState() const;
54 + inline FLAC__StreamDecoderState getState() const;
56 inline FLAC__StreamDecoderState getStreamDecoderState() const;
60 inline void setLastSample(FLAC__uint64 absoluteSample);
64 inline ::FLAC__SeekableStreamDecoderReadStatus callbackRead(FLAC__byte buffer[], uint *bytes);
65 inline ::FLAC__SeekableStreamDecoderSeekStatus callbackSeek(FLAC__uint64 absoluteByteOffset);
66 inline ::FLAC__SeekableStreamDecoderTellStatus callbackTell(FLAC__uint64 *absoluteByteOffset);
67 inline ::FLAC__SeekableStreamDecoderLengthStatus callbackLength(FLAC__uint64 *streamLength);
69 + inline ::FLAC__StreamDecoderReadStatus callbackRead(FLAC__byte buffer[], size_t *bytes);
70 + inline ::FLAC__StreamDecoderSeekStatus callbackSeek(FLAC__uint64 absoluteByteOffset);
71 + inline ::FLAC__StreamDecoderTellStatus callbackTell(FLAC__uint64 *absoluteByteOffset);
72 + inline ::FLAC__StreamDecoderLengthStatus callbackLength(FLAC__uint64 *streamLength);
74 inline bool callbackEOF();
75 inline ::FLAC__StreamDecoderWriteStatus callbackWrite(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]);
76 inline void callbackMetadata(const ::FLAC__StreamMetadata *metadata);
77 inline void callbackError(::FLAC__StreamDecoderErrorStatus status);
80 ::FLAC__SeekableStreamDecoder *_decoder;
82 + ::FLAC__StreamDecoder *_decoder;
87 static ::FLAC__SeekableStreamDecoderReadStatus callWrapRead(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__byte buffer[], uint *bytes, void *clientData);
88 static ::FLAC__SeekableStreamDecoderSeekStatus callWrapSeek(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 absoluteByteOffset, void *clientData);
89 static ::FLAC__SeekableStreamDecoderTellStatus callWrapTell(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absoluteByteOffset, void *clientData);
91 static ::FLAC__StreamDecoderWriteStatus callWrapWrite(const ::FLAC__SeekableStreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *clientData);
92 static void callWrapMetadata(const ::FLAC__SeekableStreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *clientData);
93 static void callWrapError(const ::FLAC__SeekableStreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *clientData);
95 + static ::FLAC__StreamDecoderReadStatus callWrapRead(const ::FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *clientData);
96 + static ::FLAC__StreamDecoderSeekStatus callWrapSeek(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 absoluteByteOffset, void *clientData);
97 + static ::FLAC__StreamDecoderTellStatus callWrapTell(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *absoluteByteOffset, void *clientData);
98 + static ::FLAC__StreamDecoderLengthStatus callWrapLength(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *streamLength, void *clientData);
99 + static FLAC__bool callWrapEOF(const ::FLAC__StreamDecoder *decoder, void *clientData);
100 + static ::FLAC__StreamDecoderWriteStatus callWrapWrite(const ::FLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *clientData);
101 + static void callWrapMetadata(const ::FLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *clientData);
102 + static void callWrapError(const ::FLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *clientData);
104 // Private and undefined so you can't use them:
105 FlacInputStream(const FlacInputStream &);
106 void operator=(const FlacInputStream &);
110 FlacInputStream::FlacInputStream(File *sourceFile, const uint32 fileStart)
111 - : _decoder(::FLAC__seekable_stream_decoder_new()), _firstSample(0), _lastSample(0),
113 + : _decoder(::FLAC__seekable_stream_decoder_new()),
115 + : _decoder(::FLAC__stream_decoder_new()),
117 + _firstSample(0), _lastSample(0),
118 _outBuffer(NULL), _requestedSamples(0), _lastSampleWritten(true),
119 _methodConvertBuffers(&FlacInputStream::convertBuffersGeneric)
124 FlacInputStream::FlacInputStream(File *sourceFile, const uint32 fileStart, const uint32 fileStop)
125 - : _decoder(::FLAC__seekable_stream_decoder_new()), _firstSample(0), _lastSample(0),
127 + : _decoder(::FLAC__seekable_stream_decoder_new()),
129 + : _decoder(::FLAC__stream_decoder_new()),
131 + _firstSample(0), _lastSample(0),
132 _outBuffer(NULL), _requestedSamples(0), _lastSampleWritten(true),
133 _methodConvertBuffers(&FlacInputStream::convertBuffersGeneric)
137 FlacInputStream::~FlacInputStream() {
138 if (_decoder != NULL) {
140 (void) ::FLAC__seekable_stream_decoder_finish(_decoder);
141 ::FLAC__seekable_stream_decoder_delete(_decoder);
143 + (void) ::FLAC__stream_decoder_finish(_decoder);
144 + ::FLAC__stream_decoder_delete(_decoder);
147 if (_preBuffer.bufData != NULL)
148 delete[] _preBuffer.bufData;
149 @@ -210,14 +262,27 @@
150 _fileInfo.fileHandle->decRef();
153 -inline FLAC__SeekableStreamDecoderState FlacInputStream::getState() const {
155 +inline FLAC__SeekableStreamDecoderState FlacInputStream::getState() const
157 +inline FLAC__StreamDecoderState FlacInputStream::getState() const
162 return ::FLAC__seekable_stream_decoder_get_state(_decoder);
164 + return ::FLAC__stream_decoder_get_state(_decoder);
168 inline FLAC__StreamDecoderState FlacInputStream::getStreamDecoderState() const {
171 return ::FLAC__seekable_stream_decoder_get_stream_decoder_state(_decoder);
173 + return ::FLAC__stream_decoder_get_state(_decoder);
177 bool FlacInputStream::init() {
179 _lastSampleWritten = false;
180 _methodConvertBuffers = &FlacInputStream::convertBuffersGeneric;
183 ::FLAC__seekable_stream_decoder_set_read_callback(_decoder, &FlacInputStream::callWrapRead);
184 ::FLAC__seekable_stream_decoder_set_seek_callback(_decoder, &FlacInputStream::callWrapSeek);
185 ::FLAC__seekable_stream_decoder_set_tell_callback(_decoder, &FlacInputStream::callWrapTell);
191 + if (::FLAC__stream_decoder_init_stream(
193 + &FlacInputStream::callWrapRead,
194 + &FlacInputStream::callWrapSeek,
195 + &FlacInputStream::callWrapTell,
196 + &FlacInputStream::callWrapLength,
197 + &FlacInputStream::callWrapEOF,
198 + &FlacInputStream::callWrapWrite,
199 + &FlacInputStream::callWrapMetadata,
200 + &FlacInputStream::callWrapError,
202 + ) == FLAC__STREAM_DECODER_INIT_STATUS_OK) {
203 + if (processUntilEndOfMetadata() && _streaminfo.channels > 0) {
204 + if (_firstSample == 0 || 0 != ::FLAC__stream_decoder_seek_absolute(_decoder, _firstSample)) {
205 + // FLAC__StreamDecoderState state = getStreamDecoderState();
206 + return true; // no error occured
212 warning("FlacInputStream: could not create an Audiostream from File %s", _fileInfo.fileHandle->name());
214 @@ -255,28 +342,48 @@
215 bool FlacInputStream::finish() {
219 return 0 != ::FLAC__seekable_stream_decoder_finish(_decoder);
221 + return 0 != ::FLAC__stream_decoder_finish(_decoder);
225 bool FlacInputStream::flush() {
229 return 0 != ::FLAC__seekable_stream_decoder_flush(_decoder);
231 + return 0 != ::FLAC__stream_decoder_flush(_decoder);
235 inline bool FlacInputStream::processSingleBlock() {
238 return 0 != ::FLAC__seekable_stream_decoder_process_single(_decoder);
240 + return 0 != ::FLAC__stream_decoder_process_single(_decoder);
244 inline bool FlacInputStream::processUntilEndOfMetadata() {
247 return 0 != ::FLAC__seekable_stream_decoder_process_until_end_of_metadata(_decoder);
249 + return 0 != ::FLAC__stream_decoder_process_until_end_of_metadata(_decoder);
253 bool FlacInputStream::seekAbsolute(FLAC__uint64 sample) {
256 const bool result = (0 != ::FLAC__seekable_stream_decoder_seek_absolute(_decoder, sample));
258 + const bool result = (0 != ::FLAC__stream_decoder_seek_absolute(_decoder, sample));
262 _lastSampleWritten = (_lastSample != 0 && sample >= _lastSample); // only set if we are SURE
263 @@ -349,11 +456,20 @@
264 return decoderOk ? samples : -1;
267 -inline ::FLAC__SeekableStreamDecoderReadStatus FlacInputStream::callbackRead(FLAC__byte buffer[], uint *bytes) {
269 +inline ::FLAC__SeekableStreamDecoderReadStatus FlacInputStream::callbackRead(FLAC__byte buffer[], uint *bytes)
271 +inline ::FLAC__StreamDecoderReadStatus FlacInputStream::callbackRead(FLAC__byte buffer[], size_t *bytes)
274 assert(_fileInfo.fileHandle != NULL);
278 return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR; /* abort to avoid a deadlock */
280 + return FLAC__STREAM_DECODER_READ_STATUS_ABORT; /* abort to avoid a deadlock */
283 const uint32 length = MIN(_fileInfo.fileEndPos - _fileInfo.filePos, static_cast<uint32>(*bytes));
285 @@ -361,11 +477,19 @@
286 const uint32 bytesRead = _fileInfo.fileHandle->read(buffer, length);
288 if (bytesRead == 0 && _fileInfo.fileHandle->ioFailed())
290 return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR;
292 + return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
295 _fileInfo.filePos += bytesRead;
296 *bytes = static_cast<uint>(bytesRead);
298 return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK;
300 + return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
304 inline void FlacInputStream::setLastSample(FLAC__uint64 absoluteSample) {
305 @@ -637,30 +761,60 @@
306 return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
309 -inline ::FLAC__SeekableStreamDecoderSeekStatus FlacInputStream::callbackSeek(FLAC__uint64 absoluteByteOffset) {
311 +inline ::FLAC__SeekableStreamDecoderSeekStatus FlacInputStream::callbackSeek(FLAC__uint64 absoluteByteOffset)
313 +inline ::FLAC__StreamDecoderSeekStatus FlacInputStream::callbackSeek(FLAC__uint64 absoluteByteOffset)
316 FLAC__uint64 newPos = absoluteByteOffset + _fileInfo.fileStartPos;
317 const bool result = (newPos < _fileInfo.fileEndPos);
320 _fileInfo.filePos = static_cast<uint32>(newPos);
323 return result ? FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK : FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR;
326 + return result ? FLAC__STREAM_DECODER_SEEK_STATUS_OK : FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
330 -inline ::FLAC__SeekableStreamDecoderTellStatus FlacInputStream::callbackTell(FLAC__uint64 *absoluteByteOffset) {
332 +inline ::FLAC__SeekableStreamDecoderTellStatus FlacInputStream::callbackTell(FLAC__uint64 *absoluteByteOffset)
334 +inline ::FLAC__StreamDecoderTellStatus FlacInputStream::callbackTell(FLAC__uint64 *absoluteByteOffset)
338 return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR;*/
339 *absoluteByteOffset = static_cast<FLAC__uint64>(_fileInfo.filePos-_fileInfo.fileStartPos);
341 return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK;
343 + return FLAC__STREAM_DECODER_TELL_STATUS_OK;
347 -inline ::FLAC__SeekableStreamDecoderLengthStatus FlacInputStream::callbackLength(FLAC__uint64 *streamLength) {
349 +inline ::FLAC__SeekableStreamDecoderLengthStatus FlacInputStream::callbackLength(FLAC__uint64 *streamLength)
351 +inline ::FLAC__StreamDecoderLengthStatus FlacInputStream::callbackLength(FLAC__uint64 *streamLength)
354 if (_fileInfo.fileStartPos > _fileInfo.fileEndPos)
356 return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR;
358 + return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
361 *streamLength = static_cast<FLAC__uint64>(_fileInfo.fileEndPos - _fileInfo.fileStartPos);
363 return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK;
365 + return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
369 inline bool FlacInputStream::callbackEOF() {
370 @@ -682,56 +836,96 @@
373 /* Static Callback Wrappers */
374 -::FLAC__SeekableStreamDecoderReadStatus FlacInputStream::callWrapRead(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__byte buffer[], uint *bytes, void *clientData) {
376 +::FLAC__SeekableStreamDecoderReadStatus FlacInputStream::callWrapRead(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__byte buffer[], uint *bytes, void *clientData)
378 +::FLAC__StreamDecoderReadStatus FlacInputStream::callWrapRead(const ::FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *clientData)
381 assert(0 != clientData);
382 FlacInputStream *instance = reinterpret_cast<FlacInputStream *>(clientData);
383 assert(0 != instance);
384 return instance->callbackRead(buffer, bytes);
387 -::FLAC__SeekableStreamDecoderSeekStatus FlacInputStream::callWrapSeek(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 absoluteByteOffset, void *clientData) {
389 +::FLAC__SeekableStreamDecoderSeekStatus FlacInputStream::callWrapSeek(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 absoluteByteOffset, void *clientData)
391 +::FLAC__StreamDecoderSeekStatus FlacInputStream::callWrapSeek(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 absoluteByteOffset, void *clientData)
394 assert(0 != clientData);
395 FlacInputStream *instance = reinterpret_cast<FlacInputStream *>(clientData);
396 assert(0 != instance);
397 return instance->callbackSeek(absoluteByteOffset);
400 -::FLAC__SeekableStreamDecoderTellStatus FlacInputStream::callWrapTell(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absoluteByteOffset, void *clientData) {
402 +::FLAC__SeekableStreamDecoderTellStatus FlacInputStream::callWrapTell(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absoluteByteOffset, void *clientData)
404 +::FLAC__StreamDecoderTellStatus FlacInputStream::callWrapTell(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *absoluteByteOffset, void *clientData)
407 assert(0 != clientData);
408 FlacInputStream *instance = reinterpret_cast<FlacInputStream *>(clientData);
409 assert(0 != instance);
410 return instance->callbackTell(absoluteByteOffset);
413 -::FLAC__SeekableStreamDecoderLengthStatus FlacInputStream::callWrapLength(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *streamLength, void *clientData) {
415 +::FLAC__SeekableStreamDecoderLengthStatus FlacInputStream::callWrapLength(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *streamLength, void *clientData)
417 +::FLAC__StreamDecoderLengthStatus FlacInputStream::callWrapLength(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *streamLength, void *clientData)
420 assert(0 != clientData);
421 FlacInputStream *instance = reinterpret_cast<FlacInputStream *>(clientData);
422 assert(0 != instance);
423 return instance->callbackLength(streamLength);
426 -FLAC__bool FlacInputStream::callWrapEOF(const ::FLAC__SeekableStreamDecoder *decoder, void *clientData) {
428 +FLAC__bool FlacInputStream::callWrapEOF(const ::FLAC__SeekableStreamDecoder *decoder, void *clientData)
430 +FLAC__bool FlacInputStream::callWrapEOF(const ::FLAC__StreamDecoder *decoder, void *clientData)
433 assert(0 != clientData);
434 FlacInputStream *instance = reinterpret_cast<FlacInputStream *>(clientData);
435 assert(0 != instance);
436 return instance->callbackEOF();
439 -::FLAC__StreamDecoderWriteStatus FlacInputStream::callWrapWrite(const ::FLAC__SeekableStreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *clientData) {
441 +::FLAC__StreamDecoderWriteStatus FlacInputStream::callWrapWrite(const ::FLAC__SeekableStreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *clientData)
443 +::FLAC__StreamDecoderWriteStatus FlacInputStream::callWrapWrite(const ::FLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *clientData)
446 assert(0 != clientData);
447 FlacInputStream *instance = reinterpret_cast<FlacInputStream *>(clientData);
448 assert(0 != instance);
449 return instance->callbackWrite(frame, buffer);
452 -void FlacInputStream::callWrapMetadata(const ::FLAC__SeekableStreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *clientData) {
454 +void FlacInputStream::callWrapMetadata(const ::FLAC__SeekableStreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *clientData)
456 +void FlacInputStream::callWrapMetadata(const ::FLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *clientData)
459 assert(0 != clientData);
460 FlacInputStream *instance = reinterpret_cast<FlacInputStream *>(clientData);
461 assert(0 != instance);
462 instance->callbackMetadata(metadata);
465 -void FlacInputStream::callWrapError(const ::FLAC__SeekableStreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *clientData) {
467 +void FlacInputStream::callWrapError(const ::FLAC__SeekableStreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *clientData)
469 +void FlacInputStream::callWrapError(const ::FLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *clientData)
472 assert(0 != clientData);
473 FlacInputStream *instance = reinterpret_cast<FlacInputStream *>(clientData);
474 assert(0 != instance);