Sophie

Sophie

distrib > Mageia > 6 > armv7hl > media > core-updates-src > by-pkgid > d0632575bb1d3fdba61580e6eab88e32 > files > 3

soundtouch-1.9.2-2.2.mga6.src.rpm

Index: soundtouch/source/SoundTouch/FIFOSampleBuffer.cpp
===================================================================
--- soundtouch/source/SoundTouch/FIFOSampleBuffer.cpp
+++ soundtouch/source/SoundTouch/FIFOSampleBuffer.cpp	2018-09-13 10:43:56.991640682 -0400
@@ -80,7 +80,8 @@
 {
     uint usedBytes;
 
-    assert(numChannels > 0);
+    if (!verifyNumberOfChannels(numChannels)) return;
+
     usedBytes = channels * samplesInBuffer;
     channels = (uint)numChannels;
     samplesInBuffer = usedBytes / channels;
Index: soundtouch/source/SoundTouch/RateTransposer.cpp
===================================================================
--- soundtouch/source/SoundTouch/RateTransposer.cpp
+++ soundtouch/source/SoundTouch/RateTransposer.cpp	2018-09-13 10:45:40.516735655 -0400
@@ -177,11 +177,10 @@
 // Sets the number of channels, 1 = mono, 2 = stereo
 void RateTransposer::setChannels(int nChannels)
 {
-    assert(nChannels > 0);
+    if (!verifyNumberOfChannels(nChannels) ||
+        (pTransposer->numChannels == nChannels)) return;
 
-    if (pTransposer->numChannels == nChannels) return;
     pTransposer->setChannels(nChannels);
-
     inputBuffer.setChannels(nChannels);
     midBuffer.setChannels(nChannels);
     outputBuffer.setChannels(nChannels);
Index: soundtouch/source/SoundTouch/SoundTouch.cpp
===================================================================
--- soundtouch/source/SoundTouch/SoundTouch.cpp
+++ soundtouch/source/SoundTouch/SoundTouch.cpp	2018-09-13 10:47:09.947089995 -0400
@@ -146,11 +146,8 @@
 // Sets the number of channels, 1 = mono, 2 = stereo
 void SoundTouch::setChannels(uint numChannels)
 {
-    /*if (numChannels != 1 && numChannels != 2) 
-    {
-        //ST_THROW_RT_ERROR("Illegal number of channels");
-		return;
-    }*/
+    if (!verifyNumberOfChannels(numChannels)) return;
+
     channels = numChannels;
     pRateTransposer->setChannels((int)numChannels);
     pTDStretch->setChannels((int)numChannels);
Index: soundtouch/source/SoundTouch/TDStretch.cpp
===================================================================
--- soundtouch/source/SoundTouch/TDStretch.cpp
+++ soundtouch/source/SoundTouch/TDStretch.cpp	2018-09-13 10:48:14.832895993 -0400
@@ -591,9 +591,8 @@
 // Sets the number of channels, 1 = mono, 2 = stereo
 void TDStretch::setChannels(int numChannels)
 {
-    assert(numChannels > 0);
-    if (channels == numChannels) return;
-//    assert(numChannels == 1 || numChannels == 2);
+    if (!verifyNumberOfChannels(numChannels) ||
+        (channels == numChannels)) return;
 
     channels = numChannels;
     inputBuffer.setChannels(channels);
Index: soundtouch/include/FIFOSamplePipe.h
===================================================================
--- soundtouch/include/FIFOSamplePipe.h
+++ soundtouch/include/FIFOSamplePipe.h	2018-09-13 10:39:24.977661295 -0400
@@ -58,6 +58,18 @@
 /// Abstract base class for FIFO (first-in-first-out) sample processing classes.
 class FIFOSamplePipe
 {
+protected:
+
+    bool verifyNumberOfChannels(int nChannels) const
+    {
+        if ((nChannels > 0) && (nChannels <= SOUNDTOUCH_MAX_CHANNELS))
+        {
+            return true;
+        }
+        ST_THROW_RT_ERROR("Error: Illegal number of channels");
+        return false;
+    }
+
 public:
     // virtual default destructor
     virtual ~FIFOSamplePipe() {}
Index: soundtouch/include/STTypes.h
===================================================================
--- soundtouch/include/STTypes.h
+++ soundtouch/include/STTypes.h	2018-09-13 10:40:40.741256779 -0400
@@ -63,6 +63,9 @@
 
 namespace soundtouch
 {
+    /// Max allowed number of channels
+    #define SOUNDTOUCH_MAX_CHANNELS     16
+
     /// Activate these undef's to overrule the possible sampletype 
     /// setting inherited from some other header file:
     //#undef SOUNDTOUCH_INTEGER_SAMPLES