X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0f358732e44d89af3d83c4b77e19d0963afa7c7e..e58989615283771efcaa9e798568772ef5fcfb0c:/src/msw/wave.cpp diff --git a/src/msw/wave.cpp b/src/msw/wave.cpp index 23f09f7c47..610ef77cef 100644 --- a/src/msw/wave.cpp +++ b/src/msw/wave.cpp @@ -5,8 +5,8 @@ // Modified by: // Created: 04/01/98 // RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Copyright: (c) Julian Smart +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -20,6 +20,8 @@ #pragma hdrstop #endif +#if wxUSE_WAVE + #ifndef WX_PRECOMP #include "wx/wx.h" #endif @@ -28,15 +30,12 @@ #include "wx/msw/wave.h" #include "wx/msw/private.h" -#include #include -#ifndef __GNUWIN32__ -#include -#endif - -#ifdef __GNUWIN32__ -#include "wx/msw/gnuwin32/extra.h" +#if defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__) + #include "wx/msw/gnuwin32/extra.h" +#else + #include #endif wxWave::wxWave() @@ -50,7 +49,7 @@ wxWave::wxWave(const wxString& sFileName, bool isResource) Create(sFileName, isResource); } -wxWave::wxWave(int size, const byte* data) +wxWave::wxWave(int size, const wxByte* data) : m_waveData(NULL), m_waveLength(0), m_isResource(FALSE) { Create(size, data); @@ -70,10 +69,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__) +#ifdef _UNICODE + hresInfo = ::FindResourceW((HMODULE) wxhInstance, fileName, wxT("WAVE")); #else - hresInfo = ::FindResource((HMODULE) wxhInstance, fileName, "WAVE"); + hresInfo = ::FindResourceA((HMODULE) wxhInstance, fileName, wxT("WAVE")); +#endif +#else + hresInfo = ::FindResource((HMODULE) wxhInstance, fileName, wxT("WAVE")); #endif if (!hresInfo) return FALSE; @@ -82,7 +85,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); } @@ -98,7 +101,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; @@ -108,12 +111,12 @@ bool wxWave::Create(const wxString& fileName, bool isResource) } } -bool wxWave::Create(int size, const byte* data) +bool wxWave::Create(int size, const wxByte* data) { Free(); m_isResource = FALSE; m_waveLength=size; - 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; @@ -127,7 +130,7 @@ bool wxWave::Play(bool async, bool looped) const return FALSE; #ifdef __WIN32__ - return ( ::PlaySound((LPCSTR)m_waveData, NULL, SND_MEMORY | + return ( ::PlaySound((LPCTSTR)m_waveData, NULL, SND_MEMORY | SND_NODEFAULT | (async ? SND_ASYNC : SND_SYNC) | (looped ? (SND_LOOP | SND_ASYNC) : 0)) != 0 ); #else return ( ::sndPlaySound((LPCSTR)m_waveData, SND_MEMORY | @@ -139,20 +142,24 @@ bool wxWave::Free() { if (m_waveData) { -#ifdef __WIN32__ - HGLOBAL waveData = ::GlobalHandle(m_waveData); +#ifdef __WXWINCE__ + HGLOBAL waveData = (HGLOBAL) m_waveData; +#elif defined(__WIN32__) + HGLOBAL waveData = GlobalHandle(m_waveData); #else HGLOBAL waveData = GlobalPtrHandle(m_waveData); #endif if (waveData) { - if (m_isResource) +#ifndef __WXWINCE__ + if (m_isResource) ::FreeResource(waveData); else +#endif { - ::GlobalUnlock(waveData); - ::GlobalFree(waveData); + GlobalUnlock(waveData); + GlobalFree(waveData); } m_waveData = NULL; @@ -163,4 +170,4 @@ bool wxWave::Free() return FALSE; } - +#endif // wxUSE_WAVE