[Scummvm-git-logs] scummvm master -> 56bdd431005addad67c641b9c312840cccb11fd4

sev- noreply at scummvm.org
Mon Sep 2 09:20:16 UTC 2024


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

Summary:
0b1c75b803 QDENGINE: Simplified wave loading code
56bdd43100 QDENGINE: Implemented .ogg playback for sounds. Used in shveik


Commit: 0b1c75b8038315ec00168cca47bfb2e982ffc192
    https://github.com/scummvm/scummvm/commit/0b1c75b8038315ec00168cca47bfb2e982ffc192
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-09-02T11:20:09+02:00

Commit Message:
QDENGINE: Simplified wave loading code

Changed paths:
    engines/qdengine/qdcore/qd_sound.cpp
    engines/qdengine/qdcore/util/plaympp_api.cpp
    engines/qdengine/system/sound/wav_sound.cpp
    engines/qdengine/system/sound/wav_sound.h


diff --git a/engines/qdengine/qdcore/qd_sound.cpp b/engines/qdengine/qdcore/qd_sound.cpp
index 954efacc46e..84f548f6e25 100644
--- a/engines/qdengine/qdcore/qd_sound.cpp
+++ b/engines/qdengine/qdcore/qd_sound.cpp
@@ -39,12 +39,10 @@ qdSound::qdSound() : _volume(255) {
 }
 
 qdSound::~qdSound() {
-	_sound.free_data();
 }
 
 bool qdSound::free_resource() {
 	toggle_resource_status(false);
-	_sound.free_data();
 
 	return true;
 }
diff --git a/engines/qdengine/qdcore/util/plaympp_api.cpp b/engines/qdengine/qdcore/util/plaympp_api.cpp
index dcb61076ef4..0e6f384e4c8 100644
--- a/engines/qdengine/qdcore/util/plaympp_api.cpp
+++ b/engines/qdengine/qdcore/util/plaympp_api.cpp
@@ -44,7 +44,7 @@ mpegPlayer::~mpegPlayer() {
 }
 
 bool mpegPlayer::play(const Common::Path file, bool loop, int vol) {
-	bool isOGG = file.baseName().hasSuffix(".ogg");
+	bool isOGG = file.baseName().hasSuffixIgnoreCase(".ogg");
 
 	debugC(1, kDebugSound, "mpegPlayer::play(%s, %d, %d)", file.toString().c_str(), loop, vol);
 
diff --git a/engines/qdengine/system/sound/wav_sound.cpp b/engines/qdengine/system/sound/wav_sound.cpp
index 95ed81c3ba5..0a7ef0ba562 100644
--- a/engines/qdengine/system/sound/wav_sound.cpp
+++ b/engines/qdengine/system/sound/wav_sound.cpp
@@ -19,6 +19,7 @@
  *
  */
 
+#include "audio/audiostream.h"
 #include "audio/decoders/raw.h"
 #include "audio/decoders/wave.h"
 #include "common/debug.h"
@@ -32,41 +33,9 @@
 
 namespace QDEngine {
 
-wavSound::wavSound() : _data(NULL) {
-	_data_length = 0;
-	_bits_per_sample = 0;
-	_channels = 0;
-	_samples_per_sec = 0;
-}
-
-wavSound::~wavSound() {
-	free_data();
-}
+wavSound::wavSound() {}
 
-bool wavSound::init(int data_len, int bits, int chn, int samples) {
-	free_data();
-
-	_data_length = data_len;
-	_data = new char[_data_length];
-
-	_channels = chn;
-	_bits_per_sample = bits;
-	_samples_per_sec = samples;
-
-	return true;
-}
-
-void wavSound::free_data() {
-	if (_data) {
-		delete [] _data;
-		_data = NULL;
-	}
-
-	_data_length = 0;
-	_bits_per_sample = 0;
-	_channels = 0;
-	_samples_per_sec = 0;
-}
+wavSound::~wavSound() {}
 
 bool wavSound::wav_file_load(const Common::Path fpath) {
 	debugC(3, kDebugSound, "[%d] Loading Wav: %s", g_system->getMillis(), transCyrillic(fpath.toString()));
@@ -79,37 +48,13 @@ bool wavSound::wav_file_load(const Common::Path fpath) {
 
 	Common::SeekableReadStream *stream;
 
-	if (qdFileManager::instance().open_file(&stream, fpath.toString().c_str(), false)) {
-		int size, rate;
-		byte flags;
-		uint16 type;
-		int blockAlign;
-
-		if (!Audio::loadWAVFromStream(*stream, size, rate, flags, &type, &blockAlign)) {
-			warning("Error loading wav file header: '%s", transCyrillic(fpath.toString()));
-			delete stream;
-			return false;
-		}
-
-		int bits;
-		if (flags & Audio::FLAG_UNSIGNED)
-			bits = 8;
-		else if (flags & Audio::FLAG_16BITS)
-			bits = 16;
-		else if (flags & Audio::FLAG_24BITS)
-			bits = 24;
-		else
-			bits = 8;
-
-		int channels = 1;
-		if (flags & Audio::FLAG_STEREO)
-			channels = 2;
-
-		init(size, bits, channels, rate);
-
-		stream->seek(0);
+	if (_fname.baseName().hasSuffixIgnoreCase(".ogg")) {
+	}
 
+	if (qdFileManager::instance().open_file(&stream, fpath.toString().c_str(), false)) {
 		_audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::NO);
+
+		_length = (float)_audioStream->getLength().msecs() / 1000.0;
 	}
 
 	return true;
diff --git a/engines/qdengine/system/sound/wav_sound.h b/engines/qdengine/system/sound/wav_sound.h
index 2d96dbc080a..19f619fa1c1 100644
--- a/engines/qdengine/system/sound/wav_sound.h
+++ b/engines/qdengine/system/sound/wav_sound.h
@@ -34,39 +34,8 @@ public:
 	wavSound();
 	~wavSound();
 
-	const char *data() const {
-		return _data;
-	}
-	int data_length() const {
-		return _data_length;
-	}
-	int bits_per_sample() const {
-		return _bits_per_sample;
-	}
-	int channels() const {
-		return _channels;
-	}
-	int samples_per_sec() const {
-		return _samples_per_sec;
-	}
-
-	bool init(int data_len, int bits, int chn, int samples);
-	void free_data();
-
-	//! Возвращает true, если звук валиден (т.е. параметры допустимые).
-	bool is_valid() const {
-		if (_bits_per_sample != 8 && _bits_per_sample != 16) return false;
-		if (_channels != 1 && _channels != 2) return false;
-		if (!_samples_per_sec) return false;
-
-		return true;
-	}
-
-	//! Возвращает длительность звука в секундах.
-	float length() const {
-		if (!is_valid()) return 0.0f;
-		return float(_data_length / _channels / (_bits_per_sample >> 3)) / float(_samples_per_sec);
-	}
+	//! Returns sound length in seconds
+	float length() const { return _length; }
 
 	bool wav_file_load(const Common::Path fname);
 
@@ -74,20 +43,7 @@ public:
 	Common::Path _fname;
 
 private:
-
-	//! Данные.
-	char *_data;
-	//! Длина данных.
-	int _data_length;
-	//! Количество бит на сэмпл (8/16).
-	int _bits_per_sample;
-	//! Количество каналов (1/2 - моно/стерео).
-	int _channels;
-	//! Частота дискретизации - количество сэмплов в секунду.
-	/**
-	Значения: 8.0, 11.025, 22.05, 44.1 x1000 Hz.
-	 */
-	int _samples_per_sec;
+	float _length = 0.0;
 };
 
 } // namespace QDEngine


Commit: 56bdd431005addad67c641b9c312840cccb11fd4
    https://github.com/scummvm/scummvm/commit/56bdd431005addad67c641b9c312840cccb11fd4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-09-02T11:20:09+02:00

Commit Message:
QDENGINE: Implemented .ogg playback for sounds. Used in shveik

Changed paths:
    engines/qdengine/system/sound/wav_sound.cpp


diff --git a/engines/qdengine/system/sound/wav_sound.cpp b/engines/qdengine/system/sound/wav_sound.cpp
index 0a7ef0ba562..1ea436be86c 100644
--- a/engines/qdengine/system/sound/wav_sound.cpp
+++ b/engines/qdengine/system/sound/wav_sound.cpp
@@ -20,7 +20,7 @@
  */
 
 #include "audio/audiostream.h"
-#include "audio/decoders/raw.h"
+#include "audio/decoders/vorbis.h"
 #include "audio/decoders/wave.h"
 #include "common/debug.h"
 #include "common/system.h"
@@ -48,11 +48,17 @@ bool wavSound::wav_file_load(const Common::Path fpath) {
 
 	Common::SeekableReadStream *stream;
 
-	if (_fname.baseName().hasSuffixIgnoreCase(".ogg")) {
-	}
-
 	if (qdFileManager::instance().open_file(&stream, fpath.toString().c_str(), false)) {
-		_audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::NO);
+		if (_fname.baseName().hasSuffixIgnoreCase(".ogg")) {
+#ifdef USE_VORBIS
+			_audioStream = Audio::makeVorbisStream(stream, DisposeAfterUse::NO);
+#else
+			warning("wavSound::wav_file_load(%s): Vorbis support not compiled", fpath.toString().c_str());
+			return false;
+#endif
+		} else {
+			_audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::NO);
+		}
 
 		_length = (float)_audioStream->getLength().msecs() / 1000.0;
 	}




More information about the Scummvm-git-logs mailing list