﻿Index: src/Processing/AudioFileIO/MonoAudioFileReader.hxx
===================================================================
--- src/Processing/AudioFileIO/MonoAudioFileReader.hxx	(révision 10864)
+++ src/Processing/AudioFileIO/MonoAudioFileReader.hxx	(copie de travail)
@@ -27,6 +27,7 @@
 #include "AudioOutPort.hxx"
 #include "AudioFile.hxx"
 #include "OutControl.hxx"
+#include "AudioCodecs_Stream.hxx"
 
 namespace CLAM
 {
@@ -46,6 +47,12 @@
 		const AudioTextDescriptors & GetTextDescriptors () const { return mAudioFile.GetTextDescriptors(); }
 		const EAudioFileCodec GetCodec() const { return mAudioFile.GetCodec(); }
+
+	        void Pause() { mIsPaused = (mIsPaused)?false:true; };
 
 	protected: // methods
 
@@ -66,6 +73,7 @@
 		TTime                     mCurrentBeginTime;
 		TTime                     mDeltaTime;
 		bool                      mEOFReached;
+	        bool                      mIsPaused;
 	};
 }
 
Index: src/Processing/AudioFileIO/MultiChannelAudioFileReader.cxx
===================================================================
--- src/Processing/AudioFileIO/MultiChannelAudioFileReader.cxx	(révision 10864)
+++ src/Processing/AudioFileIO/MultiChannelAudioFileReader.cxx	(copie de travail)
@@ -84,9 +84,6 @@
 		if ( !AbleToExecute() )
 			return false;
 
-		if ( mEOFReached )
-			return false;
-		
 		// Check all outputs sizes
 		bool allOutputsSameSize = true;
 		
@@ -116,14 +113,20 @@
 		int j = 0;
 		for ( OutputVec::iterator i = outputs.begin();
 		      i != outputs.end(); i++ )
-			mSamplesMatrix[ j++ ] = (*i).GetBuffer().GetPtr();
+		  mSamplesMatrix[ j++ ] = (*i).GetBuffer().GetPtr();
 
 		// read the data
 		
-		mEOFReached = mNativeStream->ReadData( mSelectedChannels.GetPtr(),
+		if ( !mEOFReached && !mIsPaused ) mEOFReached = mNativeStream->ReadData( mSelectedChannels.GetPtr(),
 						       mSelectedChannels.Size(),
 						       mSamplesMatrix.GetPtr(),
 						       sizeTmp );
+		else {
+		  if ( mEOFReached ) mCurrentBeginTime = GetHeader().GetLength()/1000;
+		  for ( int i = 0; i != mSamplesMatrix.Size(); i++ ) {
+		    memset ((void *)mSamplesMatrix[i], 0, sizeTmp*sizeof(TData));
+		  }
+		}
 		// Audio 'simple meta-data' setup
 		
 		for ( OutputVec::iterator i = outputs.begin();
@@ -132,11 +135,11 @@
 			(*i).SetSampleRate( mAudioFile.GetHeader().GetSampleRate() );
 			(*i).SetBeginTime( mCurrentBeginTime );
 		}
-		
-		
-		mDeltaTime = TData(sizeTmp) / mAudioFile.GetHeader().GetSampleRate()*1000;
-		mCurrentBeginTime += mDeltaTime;
-
+		if ( !mEOFReached && !mIsPaused )
+		{
+		        mDeltaTime = (TData(sizeTmp) / mAudioFile.GetHeader().GetSampleRate());//*1000;
+		        mCurrentBeginTime += mDeltaTime;
+		}
 		mTimeOutput.SendControl( mCurrentBeginTime );
 		
 		return mNativeStream->WasSomethingRead();
@@ -147,9 +150,6 @@
 		if ( !AbleToExecute() )
 			return false;
 
-		if ( mEOFReached )
-			return false;
-		
 		// Check all outputs sizes
 		bool allOutputsSameSize = true;
 		
@@ -190,10 +190,16 @@
 
 		// read the data
 		
-		mEOFReached = mNativeStream->ReadData( mSelectedChannels.GetPtr(),
+		if ( !mEOFReached && !mIsPaused ) mEOFReached = mNativeStream->ReadData( mSelectedChannels.GetPtr(),
 						       mSelectedChannels.Size(),
 						       mSamplesMatrix.GetPtr(),
 						       sizeTmp );
+		else {
+		  if ( mEOFReached ) mCurrentBeginTime = GetHeader().GetLength()/1000;
+		  for ( int i = 0; i != mSamplesMatrix.Size(); i++) {
+		    memset ((void *)mSamplesMatrix[i], 0, sizeTmp*sizeof(TData));
+		  }
+		}
 
 		// Audio 'simple meta-data' setup
 		
@@ -205,8 +211,11 @@
 		}
 		
 		
-		mDeltaTime = TData(sizeTmp) / mAudioFile.GetHeader().GetSampleRate();
-		mCurrentBeginTime += mDeltaTime;
+		if ( !mEOFReached && !mIsPaused) 
+		{
+		  mDeltaTime = (TData(sizeTmp) / mAudioFile.GetHeader().GetSampleRate());//*1000;
+		  mCurrentBeginTime += mDeltaTime;
+		}
 			
 		mTimeOutput.SendControl( mCurrentBeginTime );
 		
@@ -331,6 +340,7 @@
 		mNativeStream->PrepareReading();
 		mCurrentBeginTime = 0.0;
 		mEOFReached = false;
+		mIsPaused = false;
 
 		return true;
 	}
Index: src/Processing/AudioFileIO/MultiChannelAudioFileReader.hxx
===================================================================
--- src/Processing/AudioFileIO/MultiChannelAudioFileReader.hxx	(révision 10864)
+++ src/Processing/AudioFileIO/MultiChannelAudioFileReader.hxx	(copie de travail)
@@ -51,6 +52,13 @@
 		const AudioFileHeader & GetHeader() const { return mAudioFile.GetHeader(); }
 		const AudioTextDescriptors & GetTextDescriptors () const { return mAudioFile.GetTextDescriptors(); }
 		const EAudioFileCodec GetCodec() const { return mAudioFile.GetCodec(); }
+
+	        void Pause() { mIsPaused = (mIsPaused)?false:true; };
 	
 	protected: // methods
 		
@@ -74,6 +82,7 @@
 		TTime                               mCurrentBeginTime;
 		TTime                               mDeltaTime;
 		bool                                mEOFReached;
+	        bool                                mIsPaused;
 		AudioFileSource                     mAudioFile;
 	};
 }
Index: src/Processing/AudioFileIO/MonoAudioFileReader.cxx
===================================================================
--- src/Processing/AudioFileIO/MonoAudioFileReader.cxx	(révision 10864)
+++ src/Processing/AudioFileIO/MonoAudioFileReader.cxx	(copie de travail)
@@ -113,7 +113,8 @@
 		mNativeStream->PrepareReading();
 		mCurrentBeginTime = 0.0;
 		mEOFReached = false;
-		
+		mIsPaused = false;
+
 		return true;
 	}
 
@@ -141,16 +142,20 @@
 		if ( !AbleToExecute() )
 			return false;
 
-		if ( mEOFReached )
-			return false;
-
-		mEOFReached = mNativeStream->ReadData( mConfig.GetSelectedChannel(),
+		if ( !mEOFReached && !mIsPaused ) mEOFReached = mNativeStream->ReadData( mConfig.GetSelectedChannel(),
 						       outputSamples.GetBuffer().GetPtr(),
 						       outputSamples.GetSize() );
+		else {
+		    if ( mEOFReached ) mCurrentBeginTime = GetHeader().GetLength();// /1000;
+		    memset ((void *)outputSamples.GetBuffer().GetPtr(), 0, outputSamples.GetSize()*sizeof(TData));
+		}
 		
 		outputSamples.SetBeginTime( mCurrentBeginTime );
-		mDeltaTime = outputSamples.GetSize() / mAudioFile.GetHeader().GetSampleRate()*1000;
-		mCurrentBeginTime += mDeltaTime;
+		if ( !mEOFReached && !mIsPaused )
+		{
+		         mDeltaTime = (outputSamples.GetSize() / mAudioFile.GetHeader().GetSampleRate())*1000;
+		         mCurrentBeginTime += mDeltaTime;
+		}
 		mTimeOutput.SendControl( mCurrentBeginTime / 1000 );
 		outputSamples.SetSampleRate( mAudioFile.GetHeader().GetSampleRate() );
