Playing wave files with 1 sec of buffer
Posted on 2006-04-28
We are trying to play a wave file by allocation 1 sec of buffer at a time.
For synchronising the whole, we are doing it as
UINT pfnThreadProc(LPVOID pParam)
HANDLE handle = (HANDLE)pParam;
m_pHEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
DWORD no_chunk = (data_chunk + 176400 -1)/ 176400; //no. of 1 second chunks
for ( sec_chunk = 0; sec_chunk < no_chunk ; sec_chunk++) // loop for each 1 second chunk
if(!obj_Mixer->GetMixedSample()) // this fn gives the 1 second samples
objData.PlaySamples(obj_Mixer->mixedSample,obj_Mixer->maxSize); // this funtion plays 1 sec buffer
h_Thread = AfxBeginThread(pfnThreadProc, m_pHEvent, THREAD_PRIORITY_NORMAL, 0, 0, NULL);
delete  obj_Mixer->mixedSample;
The problem is that we are not able to syncronize it properly and there is lag or overlap between the samples.( we have tried to manipulated the milliseconds in Sleep as well.
Kindly let me know how can i remove lag or overlap between 1 second samples.