Index: DirectShowFilters/StreamingServer/Source/MultiFileReader.cpp
===================================================================
--- DirectShowFilters/StreamingServer/Source/MultiFileReader.cpp	(revision 26688)
+++ DirectShowFilters/StreamingServer/Source/MultiFileReader.cpp	(working copy)
@@ -319,6 +319,20 @@
 
 	  m_TSBufferFile.SetFilePointer(0, FILE_BEGIN);
 	
+	  int readLength = sizeof(currentPosition) + sizeof(filesAdded) + sizeof(filesRemoved);
+
+	  LPBYTE readBuffer = new BYTE[readLength];
+
+	  result=m_TSBufferFile.Read(readBuffer, readLength, &bytesRead);
+    if (!SUCCEEDED(result)|| bytesRead!=readLength) Error|=0x02;
+
+	currentPosition = *((__int64*)(readBuffer + 0));
+	filesAdded = *((long*)(readBuffer + sizeof(__int64)));
+	filesRemoved = *((long*)(readBuffer + sizeof(__int64) + sizeof(long)));
+
+	delete readBuffer;
+
+	/*
 	  result=m_TSBufferFile.Read((LPBYTE)&currentPosition, sizeof(currentPosition), &bytesRead);
     if (!SUCCEEDED(result)|| bytesRead!=sizeof(currentPosition)) Error|=0x02;
 
@@ -327,7 +341,7 @@
 
 	  result=m_TSBufferFile.Read((LPBYTE)&filesRemoved, sizeof(filesRemoved), &bytesRead);
     if (!SUCCEEDED(result)||  bytesRead!=sizeof(filesRemoved)) Error=0x08;
-
+*/
     // If no files added or removed, break the loop !
     if ((m_filesAdded == filesAdded) && (m_filesRemoved == filesRemoved)) 
 			break ;
Index: DirectShowFilters/StreamingServer/Source/TSBuffer.cpp
===================================================================
--- DirectShowFilters/StreamingServer/Source/TSBuffer.cpp	(revision 26688)
+++ DirectShowFilters/StreamingServer/Source/TSBuffer.cpp	(working copy)
@@ -99,6 +99,64 @@
 	if (nBytes <= bytesAvailable)
 		return S_OK;
 
+	//	Calculate how many data items we need
+	UINT bytesRequired = nBytes - bytesAvailable;
+	UINT dataItemsRequired = bytesRequired / m_lTSBufferItemSize;
+
+	if((bytesRequired % m_lTSBufferItemSize) > 0)
+		dataItemsRequired++;
+
+	//	Work out the total number of bytes we need to read and allocate a buffer
+	UINT bytesToRead = dataItemsRequired * m_lTSBufferItemSize;
+	BYTE* readBuffer = new BYTE[bytesToRead];
+
+	UINT totalBytesRead = 0;
+	UINT iteration = 0;
+
+	do
+	{
+		if(iteration > 0)
+		{
+			//__int64 currentPosition = m_pFileReader->GetFilePointer();
+			//__int64 fileLength = m_pFileReader->GetFileSize();
+
+			//LogDebug("TSBuffer::Require() - Failed to read all requested bytes on first iteration, now iteration # %d, total bytes read %d, total bytes to read %d, current position %I64d, file size %I64d", iteration, totalBytesRead, bytesToRead, currentPosition, fileLength);
+			Sleep(iteration * 5);
+		}
+
+		ULONG bytesRead = 0;
+		HRESULT hr = m_pFileReader->Read(readBuffer + totalBytesRead, bytesToRead - totalBytesRead, &bytesRead);
+
+		if(FAILED(hr) || iteration >= 20)
+		{
+			LogDebug("TSBuffer::Require() - Failed to read buffer file");
+			
+			delete readBuffer;
+
+			return hr;
+		}
+
+		totalBytesRead += bytesRead;
+		iteration++;
+	}
+	while(totalBytesRead < bytesToRead);
+
+
+	//	Success! Copy all bytes to data items
+	for(int i = 0; i < dataItemsRequired; i++)
+	{
+		BYTE* newDataItem = new BYTE[m_lTSBufferItemSize];
+		memcpy(newDataItem, readBuffer + (i * m_lTSBufferItemSize), m_lTSBufferItemSize);
+
+		m_Array.push_back(newDataItem);
+		bytesAvailable += m_lTSBufferItemSize;
+	}
+
+	delete readBuffer;
+
+	return S_OK;
+
+	/*
 	while (nBytes > bytesAvailable)
 	{
 		BYTE *newItem = new BYTE[m_lTSBufferItemSize];
@@ -183,6 +241,7 @@
 //		m_pFileReader->setBufferPointer();
 
 	}
+	*/
 	return S_OK;
 }
 
Index: DirectShowFilters/TsReader/source/MultiFileReader.cpp
===================================================================
--- DirectShowFilters/TsReader/source/MultiFileReader.cpp	(revision 26688)
+++ DirectShowFilters/TsReader/source/MultiFileReader.cpp	(working copy)
@@ -319,6 +319,19 @@
 
 	  m_TSBufferFile.SetFilePointer(0, FILE_BEGIN);
 	
+	  int readLength = sizeof(currentPosition) + sizeof(filesAdded) + sizeof(filesRemoved);
+
+	  LPBYTE readBuffer = new BYTE[readLength];
+
+	  result=m_TSBufferFile.Read(readBuffer, readLength, &bytesRead);
+    if (!SUCCEEDED(result)|| bytesRead!=readLength) Error|=0x02;
+
+	currentPosition = *((__int64*)(readBuffer + 0));
+	filesAdded = *((long*)(readBuffer + sizeof(__int64)));
+	filesRemoved = *((long*)(readBuffer + sizeof(__int64) + sizeof(long)));
+
+	delete readBuffer;
+/*
 	  result=m_TSBufferFile.Read((LPBYTE)&currentPosition, sizeof(currentPosition), &bytesRead);
     if (!SUCCEEDED(result)|| bytesRead!=sizeof(currentPosition)) Error|=0x02;
 
@@ -327,7 +340,7 @@
 
 	  result=m_TSBufferFile.Read((LPBYTE)&filesRemoved, sizeof(filesRemoved), &bytesRead);
     if (!SUCCEEDED(result)||  bytesRead!=sizeof(filesRemoved)) Error=0x08;
-
+*/
     // If no files added or removed, break the loop !
     if ((m_filesAdded == filesAdded) && (m_filesRemoved == filesRemoved)) 
 			break ;
Index: DirectShowFilters/TsWriter/source/DiskRecorder.cpp
===================================================================
--- DirectShowFilters/TsWriter/source/DiskRecorder.cpp	(revision 26688)
+++ DirectShowFilters/TsWriter/source/DiskRecorder.cpp	(working copy)
@@ -33,7 +33,7 @@
 #include "..\..\shared\dvbutil.h"
 #include "..\..\shared\section.h"
 
-#define WRITE_BUFFER_SIZE (188*10)                  // Reduced from 175 packets ( 32900 ) to 10 for Radio startup ( Ambass )										
+#define WRITE_BUFFER_SIZE (188*43)                  // Reduced from 175 packets ( 32900 ) to 10 for Radio startup ( Ambass ) - Now 172 = 4*(8084/188) - 8084 is the buffer size of streaming server
 #define IGNORE_AFTER_TUNE 25                        // how many TS packets to ignore after tuning
 
 #define PID_PAT                               0     // PID for PAT table
Index: DirectShowFilters/TsWriter/source/MultiFileWriter.cpp
===================================================================
--- DirectShowFilters/TsWriter/source/MultiFileWriter.cpp	(revision 26688)
+++ DirectShowFilters/TsWriter/source/MultiFileWriter.cpp	(working copy)
@@ -405,11 +405,24 @@
 
 	// Write current position of most recent file.
 	__int64 currentPointer = m_pCurrentTSFile->GetFilePointer();
-	WriteFile(m_hTSBufferFile, &currentPointer, sizeof(currentPointer), &written, NULL);
 
+	BYTE* writeBuffer = new BYTE[65536];
+	BYTE* writePointer = writeBuffer;
+
+	*((__int64*)writePointer) = currentPointer;
+	writePointer += sizeof(__int64);
+	
+	*((long*)writePointer) = m_filesAdded;
+	writePointer += sizeof(long);
+	
+	*((long*)writePointer) = m_filesRemoved;
+	writePointer += sizeof(long);
+
+	//WriteFile(m_hTSBufferFile, &currentPointer, sizeof(currentPointer), &written, NULL);
+
 	// Write filesAdded and filesRemoved values
-	WriteFile(m_hTSBufferFile, &m_filesAdded, sizeof(m_filesAdded), &written, NULL);
-	WriteFile(m_hTSBufferFile, &m_filesRemoved, sizeof(m_filesRemoved), &written, NULL);
+	//WriteFile(m_hTSBufferFile, &m_filesAdded, sizeof(m_filesAdded), &written, NULL);
+	//WriteFile(m_hTSBufferFile, &m_filesRemoved, sizeof(m_filesRemoved), &written, NULL);
 
 	// Write out all the filenames (null terminated)
 	std::vector<LPWSTR>::iterator it = m_tsFileNames.begin();
@@ -418,17 +431,38 @@
 		LPWSTR pFilename = *it;
 		long length = wcslen(pFilename)+1;
 		length *= sizeof(wchar_t);
-		WriteFile(m_hTSBufferFile, pFilename, length, &written, NULL);
+		//WriteFile(m_hTSBufferFile, pFilename, length, &written, NULL);
+		memcpy(writePointer, pFilename, length);
+		writePointer += length;
+
+		if((writePointer - writeBuffer) > 60000)
+		{
+			LogDebug("MultiFileWriter: TS buffer file has exceeded maximum length.  Reduce the number of timeshifting files");
+			delete writeBuffer;
+			return S_FALSE;
+		}
 	}
 
 	// Finish up with a unicode null character in case we want to put stuff after this in the future.
 	wchar_t temp = 0;
-	WriteFile(m_hTSBufferFile, &temp, sizeof(temp), &written, NULL);
+	//WriteFile(m_hTSBufferFile, &temp, sizeof(temp), &written, NULL);
+	*((wchar_t*)writePointer) = temp;
+	writePointer += sizeof(wchar_t);
+	
+	
+	*((long*)writePointer) = m_filesAdded;
+	writePointer += sizeof(long);
+	
+	*((long*)writePointer) = m_filesRemoved;
+	writePointer += sizeof(long);
 
 	// Write again filesAdded and filesRemoved values for integrity check.
-	WriteFile(m_hTSBufferFile, &m_filesAdded, sizeof(m_filesAdded), &written, NULL);
-	WriteFile(m_hTSBufferFile, &m_filesRemoved, sizeof(m_filesRemoved), &written, NULL);
+	//WriteFile(m_hTSBufferFile, &m_filesAdded, sizeof(m_filesAdded), &written, NULL);
+	//WriteFile(m_hTSBufferFile, &m_filesRemoved, sizeof(m_filesRemoved), &written, NULL);
 
+	WriteFile(m_hTSBufferFile, writeBuffer, writePointer - writeBuffer, &written, NULL);
+	delete writeBuffer;
+
 	//randomly park the file pointer to help minimise HDD clogging
 //	if(m_pCurrentTSFile && m_pCurrentTSFile->GetFilePointer()&1)
 		SetFilePointer(m_hTSBufferFile, 0, NULL, FILE_END);
