Browse Source

fixed stream seeking bug

--HG--
branch : minor
rcoaxil 8 years ago
parent
commit
c5e0846c52
1 changed files with 9 additions and 2 deletions
  1. 9 2
      src/modules/audio/openal/Source.cpp

+ 9 - 2
src/modules/audio/openal/Source.cpp

@@ -444,6 +444,8 @@ float Source::getVolume() const
 
 
 void Source::seekAtomic(float offset, void *unit)
 void Source::seekAtomic(float offset, void *unit)
 {
 {
+	float offsetSamples, offsetSeconds;
+	
 	switch (*((Source::Unit *) unit))
 	switch (*((Source::Unit *) unit))
 	{
 	{
 	case Source::UNIT_SAMPLES:
 	case Source::UNIT_SAMPLES:
@@ -461,7 +463,7 @@ void Source::seekAtomic(float offset, void *unit)
 	{
 	{
 		case TYPE_STATIC:
 		case TYPE_STATIC:
 			alSourcef(source, AL_SAMPLE_OFFSET, offsetSamples);
 			alSourcef(source, AL_SAMPLE_OFFSET, offsetSamples);
-			offsetSamples = offsetSeconds = 0;
+			this->offsetSamples = this->offsetSeconds = 0;
 			break;
 			break;
 		case TYPE_STREAM:
 		case TYPE_STREAM:
 		{
 		{
@@ -471,6 +473,8 @@ void Source::seekAtomic(float offset, void *unit)
 			if (valid)
 			if (valid)
 				stopAtomic();
 				stopAtomic();
 			
 			
+			this->offsetSamples = offsetSamples;
+			this->offsetSeconds = offsetSeconds;
 			decoder->seek(offsetSeconds);
 			decoder->seek(offsetSeconds);
 
 
 			if (wasPlaying)
 			if (wasPlaying)
@@ -482,7 +486,7 @@ void Source::seekAtomic(float offset, void *unit)
 			if (valid)
 			if (valid)
 			{
 			{
 				alSourcef(source, AL_SAMPLE_OFFSET, offsetSamples);
 				alSourcef(source, AL_SAMPLE_OFFSET, offsetSamples);
-				offsetSamples = offsetSeconds = 0;
+				this->offsetSamples = this->offsetSeconds = 0;
 			}
 			}
 			else
 			else
 			{
 			{
@@ -505,6 +509,8 @@ void Source::seekAtomic(float offset, void *unit)
 				if (buffer == AL_NONE)
 				if (buffer == AL_NONE)
 					offsetSamples = 0;
 					offsetSamples = 0;
 				offsetSeconds = offsetSamples / sampleRate;
 				offsetSeconds = offsetSamples / sampleRate;
+				this->offsetSamples = offsetSamples;
+				this->offsetSeconds = offsetSeconds;
 			}
 			}
 			break;
 			break;
 		case TYPE_MAX_ENUM:
 		case TYPE_MAX_ENUM:
@@ -755,6 +761,7 @@ bool Source::queueAtomic(void *data, ALsizei length)
 		unusedBufferQueue(buffer);
 		unusedBufferQueue(buffer);
 	}
 	}
 	bufferedBytes += length;
 	bufferedBytes += length;
+
 	return true;
 	return true;
 }
 }