mirror of
https://github.com/clangen/musikcube.git
synced 2024-12-28 15:16:43 +00:00
Fixed waveOut for multichannel audio (more than 2 channels)
This commit is contained in:
parent
889f4c856d
commit
f25b682747
@ -65,9 +65,8 @@ bool WaveOut::Open(void)
|
||||
}
|
||||
|
||||
m_Buffers = (WAVEHDR *)VirtualAlloc(NULL, m_NumBuffers * sizeof(WAVEHDR), MEM_COMMIT, PAGE_READWRITE);
|
||||
// m_dwBufferSize = m_BlockSize * m_NumBuffers;
|
||||
|
||||
unsigned int bytesPerSample = m_waveFormatPCMEx.Format.nChannels*m_waveFormatPCMEx.Format.wBitsPerSample/16;
|
||||
|
||||
unsigned int bytesPerSample = m_waveFormatPCMEx.Format.wBitsPerSample/8;
|
||||
|
||||
m_dwBufferSize = m_BlockSize*bytesPerSample;
|
||||
|
||||
@ -76,9 +75,8 @@ bool WaveOut::Open(void)
|
||||
|
||||
for(unsigned long x=0; x<m_NumBuffers; x++)
|
||||
{
|
||||
// m_Buffers[x].dwBufferLength = m_BlockSize * m_NumBuffers;
|
||||
m_Buffers[x].dwBufferLength = m_BlockSize*bytesPerSample;
|
||||
m_Buffers[x].lpData = (LPSTR)&m_pfAudioBuffer[x * m_BlockSize];
|
||||
m_Buffers[x].dwBufferLength = m_dwBufferSize;
|
||||
m_Buffers[x].lpData = (LPSTR)&(this->m_pfAudioBuffer[x*m_BlockSize]);
|
||||
m_Buffers[x].dwUser = x;
|
||||
m_Buffers[x].dwBytesRecorded = 0;
|
||||
m_Buffers[x].dwFlags = 0;
|
||||
@ -105,20 +103,17 @@ bool WaveOut::Close(void)
|
||||
{
|
||||
m_Playing = false;
|
||||
|
||||
again:
|
||||
if(waveOutReset(m_waveHandle) == MMSYSERR_NOERROR)
|
||||
{
|
||||
for(unsigned long x=0; x<m_NumBuffers; x++)
|
||||
{
|
||||
if(m_Buffers[x].dwFlags & WHDR_PREPARED)
|
||||
waveOutUnprepareHeader(m_waveHandle, &m_Buffers[x], sizeof(WAVEHDR));
|
||||
}
|
||||
}
|
||||
do{
|
||||
if(waveOutReset(m_waveHandle) == MMSYSERR_NOERROR)
|
||||
{
|
||||
for(unsigned long x=0; x<m_NumBuffers; x++)
|
||||
{
|
||||
if(m_Buffers[x].dwFlags & WHDR_PREPARED)
|
||||
waveOutUnprepareHeader(m_waveHandle, &m_Buffers[x], sizeof(WAVEHDR));
|
||||
}
|
||||
}
|
||||
} while((r = waveOutClose(m_waveHandle)) != MMSYSERR_NOERROR);
|
||||
|
||||
while((r = waveOutClose(m_waveHandle)) != MMSYSERR_NOERROR)
|
||||
{
|
||||
goto again;
|
||||
}
|
||||
|
||||
m_waveHandle = NULL;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user