X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2bda0e173844e8e0f8acf4e8ad8b5c26e5c6fe5d..f538710f0b798b21365fd614ba531055b225b115:/src/msw/wave.cpp diff --git a/src/msw/wave.cpp b/src/msw/wave.cpp index 8f54200b7b..52e5ebfe56 100644 --- a/src/msw/wave.cpp +++ b/src/msw/wave.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -20,38 +20,43 @@ #pragma hdrstop #endif +#if wxUSE_WAVE + #ifndef WX_PRECOMP -#include +#include "wx/wx.h" #endif -#include -#include -#include +#include "wx/file.h" +#include "wx/msw/wave.h" +#include "wx/msw/private.h" #include #include -#ifndef __GNUWIN32__ -#include -#endif - -#ifdef __GNUWIN32__ -#include +#if defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__) + #include "wx/msw/gnuwin32/extra.h" +#else + #include #endif -wxWave::wxWave(void) - : m_waveLength(0), m_isResource(FALSE), m_waveData(NULL) +wxWave::wxWave() + : 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(void) +wxWave::~wxWave() { Free(); } @@ -65,10 +70,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, 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; @@ -77,7 +86,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 +102,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 +112,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