[Scummvm-git-logs] scummvm master -> 59682f9ccf4ecd8e86c05cb6fb8e56ee84acb639

bluegr noreply at scummvm.org
Sun Nov 13 21:14:43 UTC 2022


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:
59682f9ccf AUDIO: Unify implementations of SilentAudioStream


Commit: 59682f9ccf4ecd8e86c05cb6fb8e56ee84acb639
    https://github.com/scummvm/scummvm/commit/59682f9ccf4ecd8e86c05cb6fb8e56ee84acb639
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2022-11-13T23:14:39+02:00

Commit Message:
AUDIO: Unify implementations of SilentAudioStream

Changed paths:
    audio/audiostream.cpp
    audio/audiostream.h
    audio/decoders/quicktime.cpp
    video/bink_decoder.cpp


diff --git a/audio/audiostream.cpp b/audio/audiostream.cpp
index 182060657ba..08de5bee61f 100644
--- a/audio/audiostream.cpp
+++ b/audio/audiostream.cpp
@@ -485,4 +485,29 @@ AudioStream *makeNullAudioStream() {
 	return new NullAudioStream();
 }
 
+/**
+ * An AudioStream that just returns silent samples and runs infinitely.
+ */
+class SilentAudioStream : public AudioStream {
+public:
+	SilentAudioStream(int rate, bool stereo) : _rate(rate), _isStereo(stereo) {}
+
+	int readBuffer(int16 *buffer, const int numSamples) override {
+		memset(buffer, 0, numSamples * 2);
+		return numSamples;
+	}
+
+	bool endOfData() const override { return false; } // it never ends!
+	bool isStereo() const override { return _isStereo; }
+	int getRate() const override { return _rate; }
+
+private:
+	int _rate;
+	bool _isStereo;
+};
+
+AudioStream *makeSilentAudioStream(int rate, bool stereo) {
+	return new SilentAudioStream(rate, stereo);
+}
+
 } // End of namespace Audio
diff --git a/audio/audiostream.h b/audio/audiostream.h
index 05c165dc25e..d8779623894 100644
--- a/audio/audiostream.h
+++ b/audio/audiostream.h
@@ -497,6 +497,12 @@ private:
  * endOfStream() has been reached.
  */
 AudioStream *makeNullAudioStream();
+
+/**
+ * Create an AudioStream that just returns silent samples and runs infinitely.
+ */
+AudioStream *makeSilentAudioStream(int rate, bool stereo);
+
 /** @} */
 } // End of namespace Audio
 
diff --git a/audio/decoders/quicktime.cpp b/audio/decoders/quicktime.cpp
index f54578cf5c0..41c29c249e7 100644
--- a/audio/decoders/quicktime.cpp
+++ b/audio/decoders/quicktime.cpp
@@ -38,29 +38,6 @@
 
 namespace Audio {
 
-/**
- * An AudioStream that just returns silent samples and runs infinitely.
- * Used to fill in the "empty edits" in the track queue which are just
- * supposed to be no sound playing.
- */
-class SilentAudioStream : public AudioStream {
-public:
-	SilentAudioStream(int rate, bool stereo) : _rate(rate), _isStereo(stereo) {}
-
-	int readBuffer(int16 *buffer, const int numSamples) override {
-		memset(buffer, 0, numSamples * 2);
-		return numSamples;
-	}
-
-	bool endOfData() const override { return false; } // it never ends!
-	bool isStereo() const override { return _isStereo; }
-	int getRate() const override { return _rate; }
-
-private:
-	int _rate;
-	bool _isStereo;
-};
-
 /**
  * An AudioStream wrapper that forces audio to be played in mono.
  * It currently just ignores the right channel if stereo.
@@ -228,7 +205,7 @@ void QuickTimeAudioDecoder::QuickTimeAudioTrack::queueAudio(const Timestamp &len
 				_skipSamples = Timestamp();
 			}
 
-			queueStream(makeLimitingAudioStream(new SilentAudioStream(getRate(), isStereo()), editLength), editLength);
+			queueStream(makeLimitingAudioStream(makeSilentAudioStream(getRate(), isStereo()), editLength), editLength);
 			_curEdit++;
 			enterNewEdit(nextEditTime);
 		} else {
diff --git a/video/bink_decoder.cpp b/video/bink_decoder.cpp
index 2d0f3429dc0..1c4d08cd82a 100644
--- a/video/bink_decoder.cpp
+++ b/video/bink_decoder.cpp
@@ -325,27 +325,6 @@ BinkDecoder::BinkVideoTrack::~BinkVideoTrack() {
 	_surface.free();
 }
 
-/**
- * An AudioStream that just returns silent samples and runs infinitely.
- */
-class SilentAudioStream : public Audio::AudioStream {
-public:
-	SilentAudioStream(int rate, bool stereo) : _rate(rate), _isStereo(stereo) {}
-
-	int readBuffer(int16 *buffer, const int numSamples) override {
-		memset(buffer, 0, numSamples * 2);
-		return numSamples;
-	}
-
-	bool endOfData() const override { return false; } // it never ends!
-	bool isStereo() const override { return _isStereo; }
-	int getRate() const override { return _rate; }
-
-private:
-	int _rate;
-	bool _isStereo;
-};
-
 Common::Rational BinkDecoder::getFrameRate() {
 	BinkVideoTrack *videoTrack = (BinkVideoTrack *)getTrack(0);
 
@@ -435,7 +414,7 @@ bool BinkDecoder::BinkAudioTrack::seek(const Audio::Timestamp &time) {
 		// with silence.
 		// The official bink decoder behavior is documented here:
 		// http://www.radgametools.com/bnkhist.htm#Changes from 1.2i to 1.2J (02-18-2002)
-		SilentAudioStream *silence = new SilentAudioStream(_audioInfo->outSampleRate, _audioInfo->outChannels == 2);
+		Audio::AudioStream *silence = Audio::makeSilentAudioStream(_audioInfo->outSampleRate, _audioInfo->outChannels == 2);
 		Audio::AudioStream *prebuffer = Audio::makeLimitingAudioStream(silence, Audio::Timestamp(750));
 		_audioStream->queueAudioStream(prebuffer);
 	}




More information about the Scummvm-git-logs mailing list