Exemplo n.º 1
0
//-----------------------------------------------------------------------------
// Name: FillBuffer()
// Desc: Fill the DirectSound buffer with data from the wav file
//-----------------------------------------------------------------------------
HRESULT PinDirectSound::FillBuffer(PinSound *pps)
{
    BYTE*   pbWavData; // Pointer to actual wav data 
    UINT    cbWavSize; // Size of data
    VOID*   pbData = NULL;
    VOID*   pbData2 = NULL;
    DWORD   dwLength;
    DWORD   dwLength2;

    // The size of wave data is in pWaveFileSound->m_ckIn
    INT nWaveFileSize = m_pWaveSoundRead->m_ckIn.cksize;

    // Allocate that buffer.
    pbWavData = new BYTE[nWaveFileSize];
    if (NULL == pbWavData)
        return E_OUTOFMEMORY;

    HRESULT hr;
    if (FAILED(hr = m_pWaveSoundRead->Read(nWaveFileSize,
        pbWavData,
        &cbWavSize)))
    {
        delete[] pbWavData;
        ShowError("Could not read wav file.");
        return hr;
    }

    // Reset the file to the beginning 
    m_pWaveSoundRead->Reset();

    // Lock the buffer down
    if (FAILED(hr = pps->m_pDSBuffer->Lock(0, m_dwBufferBytes, &pbData, &dwLength,
        &pbData2, &dwLength2, 0L)))
    {
        delete[] pbWavData;
        ShowError("Could not lock sound buffer.");
        return hr;
    }

    // Copy the memory to it.
    memcpy(pbData, pbWavData, m_dwBufferBytes);

    // Unlock the buffer, we don't need it anymore.
    pps->m_pDSBuffer->Unlock(pbData, m_dwBufferBytes, NULL, 0);
    pbData = NULL;

    pps->m_pdata = new char[m_dwBufferBytes];

    memcpy(pps->m_pdata, pbWavData, m_dwBufferBytes);

    pps->m_cdata = m_dwBufferBytes;

    // We dont need the wav file data buffer anymore, so delete it 
    SAFE_VECTOR_DELETE(pbWavData);

    return S_OK;
}
Exemplo n.º 2
0
FastIStorage::~FastIStorage()
	{
	for (int i=0;i<m_vstg.Size();i++)
		{
		m_vstg.ElementAt(i)->Release();
		}

	for (int i=0;i<m_vstm.Size();i++)
		{
		m_vstm.ElementAt(i)->Release();
		}

	SAFE_VECTOR_DELETE(m_wzName);
	}
Exemplo n.º 3
0
FastIStream::~FastIStream()
	{
	free(m_rg);
	SAFE_VECTOR_DELETE(m_wzName);
	}
Exemplo n.º 4
0
Texture::~Texture()
{
	SAFE_VECTOR_DELETE(m_colorData);
}