renamed wxWave to wxSound

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25475 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2004-02-02 13:42:04 +00:00
parent f156e20c8e
commit 315ebf688c
10 changed files with 113 additions and 120 deletions

View File

@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wave.cpp
// Purpose: wxWave class implementation: optional
// Name: sound.cpp
// Purpose: wxSound class implementation: optional
// Author: Stefan Csomor
// Modified by:
// Created: 1998-01-01
@@ -10,14 +10,14 @@
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "wave.h"
#pragma implementation "sound.h"
#endif
#include "wx/object.h"
#include "wx/string.h"
#include "wx/wave.h"
#include "wx/sound.h"
#if wxUSE_WAVE
#if wxUSE_SOUND
#ifdef __WXMAC__
#include "wx/mac/private.h"
@@ -26,30 +26,30 @@
#endif
#endif
wxWave::wxWave()
wxSound::wxSound()
: m_sndChan(0), m_hSnd(NULL), m_waveLength(0), m_isResource(true)
{
}
wxWave::wxWave(const wxString& sFileName, bool isResource)
wxSound::wxSound(const wxString& sFileName, bool isResource)
: m_sndChan(0), m_hSnd(NULL), m_waveLength(0), m_isResource(true)
{
Create(sFileName, isResource);
}
wxWave::~wxWave()
wxSound::~wxSound()
{
FreeData();
}
wxWave::wxWave(int size, const wxByte* data)
wxSound::wxSound(int size, const wxByte* data)
: m_sndChan(0), m_hSnd(NULL), m_waveLength(0), m_isResource(false)
{
//TODO convert data
}
bool wxWave::Create(const wxString& fileName, bool isResource)
bool wxSound::Create(const wxString& fileName, bool isResource)
{
bool ret = false;
m_sndname = fileName;
@@ -133,7 +133,7 @@ bool wxWave::Create(const wxString& fileName, bool isResource)
//don't know what to do with looped, wth
bool wxWave::Play(bool async, bool looped) const
bool wxSound::DoPlay(unsigned flags) const
{
bool ret = false;
@@ -145,7 +145,7 @@ bool wxWave::Play(bool async, bool looped) const
hSnd = (SndListHandle) GetNamedResource('snd ', snd);
if ((hSnd != NULL) && (SndPlay((SndChannelPtr)m_sndChan, (SndListHandle) hSnd, async) == noErr))
if ((hSnd != NULL) && (SndPlay((SndChannelPtr)m_sndChan, (SndListHandle) hSnd, (flags & wxSOUND_ASYNC)) == noErr))
ret = true;
}
@@ -153,7 +153,7 @@ bool wxWave::Play(bool async, bool looped) const
}
bool wxWave::FreeData()
bool wxSound::FreeData()
{
bool ret = false;

View File

@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wave.cpp
// Purpose: wxWave class implementation: optional
// Name: sound.cpp
// Purpose: wxSound class implementation: optional
// Author: Stefan Csomor
// Modified by:
// Created: 1998-01-01
@@ -10,14 +10,14 @@
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "wave.h"
#pragma implementation "sound.h"
#endif
#include "wx/object.h"
#include "wx/string.h"
#include "wx/wave.h"
#include "wx/sound.h"
#if wxUSE_WAVE
#if wxUSE_SOUND
#ifdef __WXMAC__
#include "wx/mac/private.h"
@@ -26,30 +26,30 @@
#endif
#endif
wxWave::wxWave()
wxSound::wxSound()
: m_sndChan(0), m_hSnd(NULL), m_waveLength(0), m_isResource(true)
{
}
wxWave::wxWave(const wxString& sFileName, bool isResource)
wxSound::wxSound(const wxString& sFileName, bool isResource)
: m_sndChan(0), m_hSnd(NULL), m_waveLength(0), m_isResource(true)
{
Create(sFileName, isResource);
}
wxWave::~wxWave()
wxSound::~wxSound()
{
FreeData();
}
wxWave::wxWave(int size, const wxByte* data)
wxSound::wxSound(int size, const wxByte* data)
: m_sndChan(0), m_hSnd(NULL), m_waveLength(0), m_isResource(false)
{
//TODO convert data
}
bool wxWave::Create(const wxString& fileName, bool isResource)
bool wxSound::Create(const wxString& fileName, bool isResource)
{
bool ret = false;
m_sndname = fileName;
@@ -133,7 +133,7 @@ bool wxWave::Create(const wxString& fileName, bool isResource)
//don't know what to do with looped, wth
bool wxWave::Play(bool async, bool looped) const
bool wxSound::DoPlay(unsigned flags) const
{
bool ret = false;
@@ -145,7 +145,7 @@ bool wxWave::Play(bool async, bool looped) const
hSnd = (SndListHandle) GetNamedResource('snd ', snd);
if ((hSnd != NULL) && (SndPlay((SndChannelPtr)m_sndChan, (SndListHandle) hSnd, async) == noErr))
if ((hSnd != NULL) && (SndPlay((SndChannelPtr)m_sndChan, (SndListHandle) hSnd, (flags & wxSOUND_ASYNC)) == noErr))
ret = true;
}
@@ -153,7 +153,7 @@ bool wxWave::Play(bool async, bool looped) const
}
bool wxWave::FreeData()
bool wxSound::FreeData()
{
bool ret = false;

View File

@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wave.cpp
// Purpose: wxWave
// Name: sound.cpp
// Purpose: wxSound
// Author: Julian Smart
// Modified by:
// Created: 04/01/98
@@ -10,7 +10,7 @@
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "wave.h"
#pragma implementation "sound.h"
#endif
// For compilers that support precompilation, includes "wx.h".
@@ -20,14 +20,14 @@
#pragma hdrstop
#endif
#if wxUSE_WAVE
#if wxUSE_SOUND
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "wx/file.h"
#include "wx/msw/wave.h"
#include "wx/sound.h"
#include "wx/msw/private.h"
#include <windowsx.h>
@@ -38,29 +38,29 @@
#include <mmsystem.h>
#endif
wxWave::wxWave()
: m_waveData(NULL), m_waveLength(0), m_isResource(FALSE)
wxSound::wxSound()
: m_waveData(NULL), m_waveLength(0), m_isResource(false)
{
}
wxWave::wxWave(const wxString& sFileName, bool isResource)
wxSound::wxSound(const wxString& sFileName, bool isResource)
: 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)
wxSound::wxSound(int size, const wxByte* data)
: m_waveData(NULL), m_waveLength(0), m_isResource(false)
{
Create(size, data);
}
wxWave::~wxWave()
wxSound::~wxSound()
{
Free();
}
bool wxWave::Create(const wxString& fileName, bool isResource)
bool wxSound::Create(const wxString& fileName, bool isResource)
{
Free();
@@ -69,17 +69,9 @@ bool wxWave::Create(const wxString& fileName, bool isResource)
m_isResource = TRUE;
HRSRC hresInfo;
#if defined(__WIN32__)
#ifdef _UNICODE
hresInfo = ::FindResourceW((HMODULE) wxhInstance, fileName, wxT("WAVE"));
#else
hresInfo = ::FindResourceA((HMODULE) wxhInstance, fileName, wxT("WAVE"));
#endif
#else
hresInfo = ::FindResource((HMODULE) wxhInstance, fileName, wxT("WAVE"));
#endif
if (!hresInfo)
return FALSE;
return false;
HGLOBAL waveData = ::LoadResource((HMODULE) wxhInstance, hresInfo);
@@ -89,65 +81,61 @@ bool wxWave::Create(const wxString& fileName, bool isResource)
m_waveLength = (int) ::SizeofResource((HMODULE) wxhInstance, hresInfo);
}
return (m_waveData ? TRUE : FALSE);
return (m_waveData ? true : false);
}
else
{
m_isResource = FALSE;
m_isResource = false;
wxFile fileWave;
if (!fileWave.Open(fileName, wxFile::read))
return FALSE;
return false;
m_waveLength = (int) fileWave.Length();
m_waveData = (wxByte*)GlobalLock(GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, m_waveLength));
if (!m_waveData)
return FALSE;
return false;
fileWave.Read(m_waveData, m_waveLength);
return TRUE;
return true;
}
}
bool wxWave::Create(int size, const wxByte* data)
bool wxSound::Create(int size, const wxByte* data)
{
Free();
m_isResource = FALSE;
m_isResource = true;
m_waveLength=size;
m_waveData = (wxByte*)GlobalLock(GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, m_waveLength));
if (!m_waveData)
return FALSE;
return false;
for (int i=0; i<size; i++) m_waveData[i] = data[i];
return TRUE;
return true;
}
bool wxWave::Play(bool async, bool looped) const
bool wxSound::DoPlay(unsigned flags) const
{
if (!IsOk())
return FALSE;
return false;
#ifdef __WIN32__
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 |
SND_NODEFAULT | (async ? SND_ASYNC : SND_SYNC) | (looped ? (SND_LOOP | SND_ASYNC) : 0)) != 0 );
#endif
return (::PlaySound((LPCTSTR)m_waveData, NULL,
SND_MEMORY | SND_NODEFAULT |
((flags & wxSOUND_ASYNC) ? SND_ASYNC : SND_SYNC) |
((flags & wxSOUND_LOOP) ? (SND_LOOP | SND_ASYNC) : 0))
!= 0);
}
bool wxWave::Free()
bool wxSound::Free()
{
if (m_waveData)
{
#ifdef __WXWINCE__
HGLOBAL waveData = (HGLOBAL) m_waveData;
#elif defined(__WIN32__)
HGLOBAL waveData = GlobalHandle(m_waveData);
#else
HGLOBAL waveData = GlobalPtrHandle(m_waveData);
HGLOBAL waveData = GlobalHandle(m_waveData);
#endif
if (waveData)
@@ -164,10 +152,15 @@ bool wxWave::Free()
m_waveData = NULL;
m_waveLength = 0;
return TRUE;
return true;
}
}
return FALSE;
return false;
}
#endif // wxUSE_WAVE
/*static*/ void wxSound::Stop()
{
::PlaySound(NULL, NULL, 0);
}
#endif // wxUSE_SOUND

View File

@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wave.cpp
// Purpose: wxWave class implementation: optional
// Name: sound.cpp
// Purpose: wxSound class implementation: optional
// Author: David Webster
// Modified by:
// Created: 10/17/99
@@ -17,7 +17,7 @@
#endif
#include "wx/file.h"
#include "wx/os2/wave.h"
#include "wx/sound.h"
#define INCL_32 /* force 32 bit compile */
#define INCL_GPIBITMAPS
#define INCL_DOSFILEMGR
@@ -31,29 +31,29 @@
#include <os2medef.h>
#include <mmioos2.h>
wxWave::wxWave()
wxSound::wxSound()
: m_waveData(NULL), m_waveLength(0), m_isResource(FALSE)
{
}
wxWave::wxWave(const wxString& sFileName, bool isResource)
wxSound::wxSound(const wxString& sFileName, bool isResource)
: m_waveData(NULL), m_waveLength(0), m_isResource(isResource)
{
Create(sFileName, isResource);
}
wxWave::wxWave(int size, const wxByte* data)
wxSound::wxSound(int size, const wxByte* data)
: m_waveData(NULL), m_waveLength(0), m_isResource(FALSE)
{
Create(size, data);
}
wxWave::~wxWave()
wxSound::~wxSound()
{
Free();
}
bool wxWave::Create(const wxString& fileName, bool isResource)
bool wxSound::Create(const wxString& fileName, bool isResource)
{
Free();
@@ -108,7 +108,7 @@ bool wxWave::Create(const wxString& fileName, bool isResource)
}
}
bool wxWave::Create(int size, const wxByte* data)
bool wxSound::Create(int size, const wxByte* data)
{
Free();
m_isResource = FALSE;
@@ -121,7 +121,7 @@ bool wxWave::Create(int size, const wxByte* data)
return TRUE;
}
bool wxWave::Play(bool async, bool looped) const
bool wxSound::DoPlay(unsigned flags) const
{
if (!IsOk())
return FALSE;
@@ -133,7 +133,7 @@ bool wxWave::Play(bool async, bool looped) const
return FALSE;
}
bool wxWave::Free()
bool wxSound::Free()
{
if (m_waveData)
{

View File

@@ -13989,23 +13989,23 @@ EXPORTS
wxExecute__FRC8wxStringiP9wxProcess
;From object file: ..\os2\wave.cpp
;PUBDEFs (Symbols available from object file):
;wxWave::Create(const wxString&,unsigned long)
Create__6wxWaveFRC8wxStringUl
__vft6wxWave8wxObject
;wxWave::~wxWave()
__dt__6wxWaveFv
;wxWave::Free()
Free__6wxWaveFv
;wxWave::wxWave(const wxString&,unsigned long)
__ct__6wxWaveFRC8wxStringUl
;wxWave::wxWave(int,const unsigned char*)
__ct__6wxWaveFiPCUc
;wxWave::Create(int,const unsigned char*)
Create__6wxWaveFiPCUc
;wxWave::Play(unsigned long,unsigned long) const
Play__6wxWaveCFUlT1
;wxWave::wxWave()
__ct__6wxWaveFv
;wxSound::Create(const wxString&,unsigned long)
Create__6wxSoundFRC8wxStringUl
__vft6wxSound8wxObject
;wxSound::~wxSound()
__dt__6wxSoundFv
;wxSound::Free()
Free__6wxSoundFv
;wxSound::wxSound(const wxString&,unsigned long)
__ct__6wxSoundFRC8wxStringUl
;wxSound::wxSound(int,const unsigned char*)
__ct__6wxSoundFiPCUc
;wxSound::Create(int,const unsigned char*)
Create__6wxSoundFiPCUc
;wxSound::Play(unsigned long,unsigned long) const
Play__6wxSoundCFUlT1
;wxSound::wxSound()
__ct__6wxSoundFv
;From object file: ..\os2\window.cpp
;PUBDEFs (Symbols available from object file):
;wxFindWinFromHandle(unsigned long)