[Scummvm-git-logs] scummvm master -> 724fedbbe55a4db4fe0ca96a2d691635edfc5d09

bluegr noreply at scummvm.org
Sun Aug 11 16:51:41 UTC 2024


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
724fedbbe5 BUILD: AUDIO: Drop support for FLAC < 1.1.3


Commit: 724fedbbe55a4db4fe0ca96a2d691635edfc5d09
    https://github.com/scummvm/scummvm/commit/724fedbbe55a4db4fe0ca96a2d691635edfc5d09
Author: Donovan Watteau (contrib at dwatteau.fr)
Date: 2024-08-11T19:51:39+03:00

Commit Message:
BUILD: AUDIO: Drop support for FLAC < 1.1.3

FLAC 1.1.3 (and its newer API) was released in late 2006, so it has probably
"propagated everywhere" now.

Changed paths:
    audio/decoders/flac.cpp
    configure


diff --git a/audio/decoders/flac.cpp b/audio/decoders/flac.cpp
index 13ccd28f62e..c69cc7288ad 100644
--- a/audio/decoders/flac.cpp
+++ b/audio/decoders/flac.cpp
@@ -35,42 +35,7 @@
 
 #define FLAC__NO_DLL // that MS-magic gave me headaches - just link the library you like
 #include <FLAC/export.h>
-
-
-// check if we have FLAC >= 1.1.3; LEGACY_FLAC code can be removed once FLAC-1.1.3 propagates everywhere
-#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT < 8
-#define LEGACY_FLAC
-#else
-#undef LEGACY_FLAC
-#endif
-
-
-#ifdef LEGACY_FLAC
-
-// Before FLAC 1.1.3, we needed to use the stream decoder API.
-#include <FLAC/seekable_stream_decoder.h>
-typedef uint FLAC_size_t;
-
-#else
-
-// With FLAC 1.1.3, the stream decoder API was merged into the regular
-// stream API. In order to stay compatible with older FLAC versions, we
-// simply add some typedefs and #ifdefs to map between the old and new API.
-// We use the typedefs (instead of only #defines) in order to somewhat
-// improve the readability of the code.
-
 #include <FLAC/stream_decoder.h>
-typedef size_t FLAC_size_t;
-// Add aliases for the old names
-typedef FLAC__StreamDecoderState FLAC__SeekableStreamDecoderState;
-typedef FLAC__StreamDecoderReadStatus FLAC__SeekableStreamDecoderReadStatus;
-typedef FLAC__StreamDecoderSeekStatus FLAC__SeekableStreamDecoderSeekStatus;
-typedef FLAC__StreamDecoderTellStatus FLAC__SeekableStreamDecoderTellStatus;
-typedef FLAC__StreamDecoderLengthStatus FLAC__SeekableStreamDecoderLengthStatus;
-typedef FLAC__StreamDecoder FLAC__SeekableStreamDecoder;
-
-#endif
-
 
 namespace Audio {
 
@@ -86,7 +51,7 @@ protected:
 	Common::SeekableReadStream *_inStream;
 	bool _disposeAfterUse;
 
-	::FLAC__SeekableStreamDecoder *_decoder;
+	::FLAC__StreamDecoder *_decoder;
 
 	/** Header of the stream */
 	FLAC__StreamMetadata_StreamInfo _streaminfo;
@@ -151,24 +116,24 @@ protected:
 	inline bool processUntilEndOfMetadata();
 	bool seekAbsolute(FLAC__uint64 sample);
 
-	inline ::FLAC__SeekableStreamDecoderReadStatus callbackRead(FLAC__byte buffer[], FLAC_size_t *bytes);
-	inline ::FLAC__SeekableStreamDecoderSeekStatus callbackSeek(FLAC__uint64 absoluteByteOffset);
-	inline ::FLAC__SeekableStreamDecoderTellStatus callbackTell(FLAC__uint64 *absoluteByteOffset);
-	inline ::FLAC__SeekableStreamDecoderLengthStatus callbackLength(FLAC__uint64 *streamLength);
+	inline ::FLAC__StreamDecoderReadStatus callbackRead(FLAC__byte buffer[], size_t *bytes);
+	inline ::FLAC__StreamDecoderSeekStatus callbackSeek(FLAC__uint64 absoluteByteOffset);
+	inline ::FLAC__StreamDecoderTellStatus callbackTell(FLAC__uint64 *absoluteByteOffset);
+	inline ::FLAC__StreamDecoderLengthStatus callbackLength(FLAC__uint64 *streamLength);
 	inline bool callbackEOF();
 	inline ::FLAC__StreamDecoderWriteStatus callbackWrite(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]);
 	inline void callbackMetadata(const ::FLAC__StreamMetadata *metadata);
 	inline void callbackError(::FLAC__StreamDecoderErrorStatus status);
 
 private:
-	static ::FLAC__SeekableStreamDecoderReadStatus callWrapRead(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__byte buffer[], FLAC_size_t *bytes, void *clientData);
-	static ::FLAC__SeekableStreamDecoderSeekStatus callWrapSeek(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 absoluteByteOffset, void *clientData);
-	static ::FLAC__SeekableStreamDecoderTellStatus callWrapTell(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absoluteByteOffset, void *clientData);
-	static ::FLAC__SeekableStreamDecoderLengthStatus callWrapLength(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *streamLength, void *clientData);
-	static FLAC__bool callWrapEOF(const ::FLAC__SeekableStreamDecoder *decoder, void *clientData);
-	static ::FLAC__StreamDecoderWriteStatus callWrapWrite(const ::FLAC__SeekableStreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *clientData);
-	static void callWrapMetadata(const ::FLAC__SeekableStreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *clientData);
-	static void callWrapError(const ::FLAC__SeekableStreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *clientData);
+	static ::FLAC__StreamDecoderReadStatus callWrapRead(const ::FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *clientData);
+	static ::FLAC__StreamDecoderSeekStatus callWrapSeek(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 absoluteByteOffset, void *clientData);
+	static ::FLAC__StreamDecoderTellStatus callWrapTell(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *absoluteByteOffset, void *clientData);
+	static ::FLAC__StreamDecoderLengthStatus callWrapLength(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *streamLength, void *clientData);
+	static FLAC__bool callWrapEOF(const ::FLAC__StreamDecoder *decoder, void *clientData);
+	static ::FLAC__StreamDecoderWriteStatus callWrapWrite(const ::FLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *clientData);
+	static void callWrapMetadata(const ::FLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *clientData);
+	static void callWrapError(const ::FLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *clientData);
 
 	void setBestConvertBufferMethod();
 	static void convertBuffersGeneric(SampleType* bufDestination, const FLAC__int32 *inChannels[], uint numSamples, const uint numChannels, const uint8 numBits);
@@ -179,11 +144,7 @@ private:
 };
 
 FLACStream::FLACStream(Common::SeekableReadStream *inStream, bool dispose)
-#ifdef LEGACY_FLAC
-			:	_decoder(::FLAC__seekable_stream_decoder_new()),
-#else
 			:	_decoder(::FLAC__stream_decoder_new()),
-#endif
 		_inStream(inStream),
 		_disposeAfterUse(dispose),
 		_length(0, 1000), _lastSample(0),
@@ -199,19 +160,6 @@ FLACStream::FLACStream(Common::SeekableReadStream *inStream, bool dispose)
 	_methodConvertBuffers = &FLACStream::convertBuffersGeneric;
 
 	bool success;
-#ifdef LEGACY_FLAC
-	::FLAC__seekable_stream_decoder_set_read_callback(_decoder, &FLACStream::callWrapRead);
-	::FLAC__seekable_stream_decoder_set_seek_callback(_decoder, &FLACStream::callWrapSeek);
-	::FLAC__seekable_stream_decoder_set_tell_callback(_decoder, &FLACStream::callWrapTell);
-	::FLAC__seekable_stream_decoder_set_length_callback(_decoder, &FLACStream::callWrapLength);
-	::FLAC__seekable_stream_decoder_set_eof_callback(_decoder, &FLACStream::callWrapEOF);
-	::FLAC__seekable_stream_decoder_set_write_callback(_decoder, &FLACStream::callWrapWrite);
-	::FLAC__seekable_stream_decoder_set_metadata_callback(_decoder, &FLACStream::callWrapMetadata);
-	::FLAC__seekable_stream_decoder_set_error_callback(_decoder, &FLACStream::callWrapError);
-	::FLAC__seekable_stream_decoder_set_client_data(_decoder, (void *)this);
-
-	success = (::FLAC__seekable_stream_decoder_init(_decoder) == FLAC__SEEKABLE_STREAM_DECODER_OK);
-#else
 	success = (::FLAC__stream_decoder_init_stream(
 		_decoder,
 		&FLACStream::callWrapRead,
@@ -224,7 +172,6 @@ FLACStream::FLACStream(Common::SeekableReadStream *inStream, bool dispose)
 		&FLACStream::callWrapError,
 		(void *)this
 	) == FLAC__STREAM_DECODER_INIT_STATUS_OK);
-#endif
 	if (success) {
 		if (processUntilEndOfMetadata() && _streaminfo.channels > 0) {
 			_lastSample = _streaminfo.total_samples + 1;
@@ -238,13 +185,8 @@ FLACStream::FLACStream(Common::SeekableReadStream *inStream, bool dispose)
 
 FLACStream::~FLACStream() {
 	if (_decoder != nullptr) {
-#ifdef LEGACY_FLAC
-		(void) ::FLAC__seekable_stream_decoder_finish(_decoder);
-		::FLAC__seekable_stream_decoder_delete(_decoder);
-#else
 		(void) ::FLAC__stream_decoder_finish(_decoder);
 		::FLAC__stream_decoder_delete(_decoder);
-#endif
 	}
 	if (_disposeAfterUse)
 		delete _inStream;
@@ -252,38 +194,22 @@ FLACStream::~FLACStream() {
 
 inline FLAC__StreamDecoderState FLACStream::getStreamDecoderState() const {
 	assert(_decoder != nullptr);
-#ifdef LEGACY_FLAC
-	return ::FLAC__seekable_stream_decoder_get_stream_decoder_state(_decoder);
-#else
 	return ::FLAC__stream_decoder_get_state(_decoder);
-#endif
 }
 
 inline bool FLACStream::processSingleBlock() {
 	assert(_decoder != nullptr);
-#ifdef LEGACY_FLAC
-	return 0 != ::FLAC__seekable_stream_decoder_process_single(_decoder);
-#else
 	return 0 != ::FLAC__stream_decoder_process_single(_decoder);
-#endif
 }
 
 inline bool FLACStream::processUntilEndOfMetadata() {
 	assert(_decoder != nullptr);
-#ifdef LEGACY_FLAC
-	return 0 != ::FLAC__seekable_stream_decoder_process_until_end_of_metadata(_decoder);
-#else
 	return 0 != ::FLAC__stream_decoder_process_until_end_of_metadata(_decoder);
-#endif
 }
 
 bool FLACStream::seekAbsolute(FLAC__uint64 sample) {
 	assert(_decoder != nullptr);
-#ifdef LEGACY_FLAC
-	const bool result = (0 != ::FLAC__seekable_stream_decoder_seek_absolute(_decoder, sample));
-#else
 	const bool result = (0 != ::FLAC__stream_decoder_seek_absolute(_decoder, sample));
-#endif
 	if (result) {
 		_lastSampleWritten = (_lastSample != 0 && sample >= _lastSample); // only set if we are SURE
 	}
@@ -367,31 +293,19 @@ int FLACStream::readBuffer(int16 *buffer, const int numSamples) {
 	return decoderOk ? samples : -1;
 }
 
-inline ::FLAC__SeekableStreamDecoderReadStatus FLACStream::callbackRead(FLAC__byte buffer[], FLAC_size_t *bytes) {
+inline ::FLAC__StreamDecoderReadStatus FLACStream::callbackRead(FLAC__byte buffer[], size_t *bytes) {
 	if (*bytes == 0) {
-#ifdef LEGACY_FLAC
-		return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR; /* abort to avoid a deadlock */
-#else
 		return FLAC__STREAM_DECODER_READ_STATUS_ABORT; /* abort to avoid a deadlock */
-#endif
 	}
 
 	const uint32 bytesRead = _inStream->read(buffer, *bytes);
 
 	if (bytesRead == 0) {
-#ifdef LEGACY_FLAC
-		return _inStream->eos() ? FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK : FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR;
-#else
 		return _inStream->eos() ? FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM : FLAC__STREAM_DECODER_READ_STATUS_ABORT;
-#endif
 	}
 
 	*bytes = static_cast<uint>(bytesRead);
-#ifdef LEGACY_FLAC
-	return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK;
-#else
 	return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
-#endif
 }
 
 void FLACStream::setBestConvertBufferMethod() {
@@ -623,33 +537,21 @@ inline ::FLAC__StreamDecoderWriteStatus FLACStream::callbackWrite(const ::FLAC__
 	return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
 }
 
-inline ::FLAC__SeekableStreamDecoderSeekStatus FLACStream::callbackSeek(FLAC__uint64 absoluteByteOffset) {
+inline ::FLAC__StreamDecoderSeekStatus FLACStream::callbackSeek(FLAC__uint64 absoluteByteOffset) {
 	_inStream->seek(absoluteByteOffset, SEEK_SET);
 	const bool result = (absoluteByteOffset == (FLAC__uint64)_inStream->pos());
 
-#ifdef LEGACY_FLAC
-	return result ? FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK : FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR;
-#else
 	return result ? FLAC__STREAM_DECODER_SEEK_STATUS_OK : FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
-#endif
 }
 
-inline ::FLAC__SeekableStreamDecoderTellStatus FLACStream::callbackTell(FLAC__uint64 *absoluteByteOffset) {
+inline ::FLAC__StreamDecoderTellStatus FLACStream::callbackTell(FLAC__uint64 *absoluteByteOffset) {
 	*absoluteByteOffset = static_cast<FLAC__uint64>(_inStream->pos());
-#ifdef LEGACY_FLAC
-	return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK;
-#else
 	return FLAC__STREAM_DECODER_TELL_STATUS_OK;
-#endif
 }
 
-inline ::FLAC__SeekableStreamDecoderLengthStatus FLACStream::callbackLength(FLAC__uint64 *streamLength) {
+inline ::FLAC__StreamDecoderLengthStatus FLACStream::callbackLength(FLAC__uint64 *streamLength) {
 	*streamLength = static_cast<FLAC__uint64>(_inStream->size());
-#ifdef LEGACY_FLAC
-	return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK;
-#else
 	return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
-#endif
 }
 
 inline bool FLACStream::callbackEOF() {
@@ -670,49 +572,49 @@ inline void FLACStream::callbackError(::FLAC__StreamDecoderErrorStatus status) {
 }
 
 /* Static Callback Wrappers */
-::FLAC__SeekableStreamDecoderReadStatus FLACStream::callWrapRead(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__byte buffer[], FLAC_size_t *bytes, void *clientData) {
+::FLAC__StreamDecoderReadStatus FLACStream::callWrapRead(const ::FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *clientData) {
 	FLACStream *instance = (FLACStream *)clientData;
 	assert(nullptr != instance);
 	return instance->callbackRead(buffer, bytes);
 }
 
-::FLAC__SeekableStreamDecoderSeekStatus FLACStream::callWrapSeek(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 absoluteByteOffset, void *clientData) {
+::FLAC__StreamDecoderSeekStatus FLACStream::callWrapSeek(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 absoluteByteOffset, void *clientData) {
 	FLACStream *instance = (FLACStream *)clientData;
 	assert(nullptr != instance);
 	return instance->callbackSeek(absoluteByteOffset);
 }
 
-::FLAC__SeekableStreamDecoderTellStatus FLACStream::callWrapTell(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absoluteByteOffset, void *clientData) {
+::FLAC__StreamDecoderTellStatus FLACStream::callWrapTell(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *absoluteByteOffset, void *clientData) {
 	FLACStream *instance = (FLACStream *)clientData;
 	assert(nullptr != instance);
 	return instance->callbackTell(absoluteByteOffset);
 }
 
-::FLAC__SeekableStreamDecoderLengthStatus FLACStream::callWrapLength(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *streamLength, void *clientData) {
+::FLAC__StreamDecoderLengthStatus FLACStream::callWrapLength(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *streamLength, void *clientData) {
 	FLACStream *instance = (FLACStream *)clientData;
 	assert(nullptr != instance);
 	return instance->callbackLength(streamLength);
 }
 
-FLAC__bool FLACStream::callWrapEOF(const ::FLAC__SeekableStreamDecoder *decoder, void *clientData) {
+FLAC__bool FLACStream::callWrapEOF(const ::FLAC__StreamDecoder *decoder, void *clientData) {
 	FLACStream *instance = (FLACStream *)clientData;
 	assert(nullptr != instance);
 	return instance->callbackEOF();
 }
 
-::FLAC__StreamDecoderWriteStatus FLACStream::callWrapWrite(const ::FLAC__SeekableStreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *clientData) {
+::FLAC__StreamDecoderWriteStatus FLACStream::callWrapWrite(const ::FLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *clientData) {
 	FLACStream *instance = (FLACStream *)clientData;
 	assert(nullptr != instance);
 	return instance->callbackWrite(frame, buffer);
 }
 
-void FLACStream::callWrapMetadata(const ::FLAC__SeekableStreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *clientData) {
+void FLACStream::callWrapMetadata(const ::FLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *clientData) {
 	FLACStream *instance = (FLACStream *)clientData;
 	assert(nullptr != instance);
 	instance->callbackMetadata(metadata);
 }
 
-void FLACStream::callWrapError(const ::FLAC__SeekableStreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *clientData) {
+void FLACStream::callWrapError(const ::FLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *clientData) {
 	FLACStream *instance = (FLACStream *)clientData;
 	assert(nullptr != instance);
 	instance->callbackError(status);
diff --git a/configure b/configure
index 0e5221babdd..179bb0e995d 100755
--- a/configure
+++ b/configure
@@ -5233,15 +5233,20 @@ echo "$_retrowave"
 #
 # Check for FLAC
 #
-echocheck "FLAC >= 1.0.1"
+echocheck "FLAC >= 1.1.3"
 if test "$_flac" = auto ; then
 	_flac=no
 	cat > $TMPC << EOF
 #define FLAC__NO_DLL // Like in audio/decoders/flac.cpp
 
+#include <FLAC/export.h>
 #include <FLAC/stream_decoder.h>
 #include <FLAC/format.h>
+
 int main(void) {
+#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT < 8
+	syntax error
+#endif
 	FLAC__StreamDecoder *decoder = FLAC__stream_decoder_new();
 	FLAC__stream_decoder_delete(decoder);
 	return FLAC__STREAM_SYNC_LEN >> 30; /* guaranteed to be 0 */




More information about the Scummvm-git-logs mailing list