X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ee4f8c2af9c6c5458e488db10aef7d00a89ace25..4b5d9823ec8c849bcd51e3b15ba78f656e54493e:/src/msw/wave.cpp diff --git a/src/msw/wave.cpp b/src/msw/wave.cpp index 6486eec941..df4b95ee74 100644 --- a/src/msw/wave.cpp +++ b/src/msw/wave.cpp @@ -35,21 +35,28 @@ #include #endif +#ifndef __TWIN32__ #ifdef __GNUWIN32__ #include "wx/msw/gnuwin32/extra.h" #endif +#endif wxWave::wxWave() - : m_waveLength(0), m_isResource(FALSE), m_waveData(NULL) + : m_waveData(NULL), m_waveLength(0), m_isResource(FALSE) { } wxWave::wxWave(const wxString& sFileName, bool isResource) - : m_waveLength(0), m_isResource(isResource), m_waveData(NULL) + : m_waveData(NULL), m_waveLength(0), m_isResource(isResource) { Create(sFileName, isResource); } +wxWave::wxWave(int size, const wxByte* data) + : m_waveData(NULL), m_waveLength(0), m_isResource(FALSE) +{ + Create(size, data); +} wxWave::~wxWave() { @@ -65,10 +72,14 @@ bool wxWave::Create(const wxString& fileName, bool isResource) m_isResource = TRUE; HRSRC hresInfo; -#ifdef __WIN32__ - hresInfo = ::FindResourceA((HMODULE) wxhInstance, fileName, "WAVE"); +#if defined(__WIN32__) && !defined(__TWIN32__) +#ifdef _UNICODE + hresInfo = ::FindResourceW((HMODULE) wxhInstance, fileName, _T("WAVE")); +#else + hresInfo = ::FindResourceA((HMODULE) wxhInstance, fileName, _T("WAVE")); +#endif #else - hresInfo = ::FindResource((HMODULE) wxhInstance, fileName, "WAVE"); + hresInfo = ::FindResource((HMODULE) wxhInstance, fileName, _T("WAVE")); #endif if (!hresInfo) return FALSE; @@ -77,7 +88,7 @@ bool wxWave::Create(const wxString& fileName, bool isResource) if (waveData) { - m_waveData= (byte*)::LockResource(waveData); + m_waveData= (wxByte*)::LockResource(waveData); m_waveLength = (int) ::SizeofResource((HMODULE) wxhInstance, hresInfo); } @@ -93,7 +104,7 @@ bool wxWave::Create(const wxString& fileName, bool isResource) m_waveLength = (int) fileWave.Length(); - m_waveData = (byte*)::GlobalLock(::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, m_waveLength)); + m_waveData = (wxByte*)::GlobalLock(::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, m_waveLength)); if (!m_waveData) return FALSE; @@ -103,13 +114,26 @@ bool wxWave::Create(const wxString& fileName, bool isResource) } } +bool wxWave::Create(int size, const wxByte* data) +{ + Free(); + m_isResource = FALSE; + m_waveLength=size; + m_waveData = (wxByte*)::GlobalLock(::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, m_waveLength)); + if (!m_waveData) + return FALSE; + + for (int i=0; i