Added missing #if wxUSE_WAVE

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@18305 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2002-12-17 21:26:21 +00:00
parent 1eab83f91a
commit 3d9d488655
3 changed files with 48 additions and 39 deletions

View File

@@ -17,6 +17,8 @@
#pragma interface "wave.h" #pragma interface "wave.h"
#endif #endif
#if wxUSE_WAVE
#include "wx/object.h" #include "wx/object.h"
class WXDLLEXPORT wxWave : public wxObject class WXDLLEXPORT wxWave : public wxObject
@@ -38,12 +40,13 @@ protected:
private: private:
void* m_sndChan; void* m_sndChan;
wxString m_sndname; wxString m_sndname;
void* m_hSnd; void* m_hSnd;
int m_waveLength; int m_waveLength;
bool m_isResource; bool m_isResource;
}; };
#endif
#endif #endif
// _WX_WAVE_H_ // _WX_WAVE_H_

View File

@@ -17,6 +17,8 @@
#include "wx/string.h" #include "wx/string.h"
#include "wx/wave.h" #include "wx/wave.h"
#if wxUSE_WAVE
#ifdef __WXMAC__ #ifdef __WXMAC__
#include "wx/mac/private.h" #include "wx/mac/private.h"
#ifndef __DARWIN__ #ifndef __DARWIN__
@@ -57,7 +59,7 @@ bool wxWave::Create(const wxString& fileName, bool isResource)
ret = true; ret = true;
else else
{ /* { /*
if (sndChan) if (sndChan)
{ // we're playing { // we're playing
FSClose(SndRefNum); FSClose(SndRefNum);
SndRefNum = 0; SndRefNum = 0;
@@ -66,7 +68,7 @@ bool wxWave::Create(const wxString& fileName, bool isResource)
sndChan = 0; sndChan = 0;
KillTimer(0,timerID); KillTimer(0,timerID);
} }
if (!lpSnd) if (!lpSnd)
return true; return true;
@@ -81,14 +83,14 @@ bool wxWave::Create(const wxString& fileName, bool isResource)
sndChan->qLength = 128; sndChan->qLength = 128;
if (noErr != SndNewChannel (&sndChan, sampledSynth, initMono | initNoInterp, 0)) if (noErr != SndNewChannel (&sndChan, sampledSynth, initMono | initNoInterp, 0))
{ {
free(sndChan); free(sndChan);
sndChan = 0; sndChan = 0;
return false; return false;
} }
if (!(SndRefNum = MacOpenSndFile ((char *)lpSnd))) if (!(SndRefNum = MacOpenSndFile ((char *)lpSnd)))
{ {
SndDisposeChannel(sndChan, TRUE); SndDisposeChannel(sndChan, TRUE);
free(sndChan); free(sndChan);
@@ -102,7 +104,7 @@ bool wxWave::Create(const wxString& fileName, bool isResource)
if (fdwSound & SND_ASYNC) if (fdwSound & SND_ASYNC)
async = true; async = true;
if (SndStartFilePlay(sndChan, SndRefNum, 0, 81920, 0, 0, 0, async) != noErr) if (SndStartFilePlay(sndChan, SndRefNum, 0, 81920, 0, 0, 0, async) != noErr)
{ {
FSClose (SndRefNum); FSClose (SndRefNum);
SndRefNum = 0; SndRefNum = 0;
@@ -112,11 +114,11 @@ bool wxWave::Create(const wxString& fileName, bool isResource)
return false; return false;
} }
if (async) if (async)
{ // haven't finish yet { // haven't finish yet
timerID = SetTimer(0, 0, 250, TimerCallBack); timerID = SetTimer(0, 0, 250, TimerCallBack);
} }
else else
{ {
FSClose (SndRefNum); FSClose (SndRefNum);
SndRefNum = 0; SndRefNum = 0;
@@ -125,7 +127,7 @@ bool wxWave::Create(const wxString& fileName, bool isResource)
sndChan = 0; sndChan = 0;
}*/ }*/
} }
return ret; return ret;
} }
@@ -135,8 +137,8 @@ bool wxWave::Play(bool async, bool looped) const
{ {
char lpSnd[32]; char lpSnd[32];
bool ret = false; bool ret = false;
if (m_isResource) if (m_isResource)
{ {
#if TARGET_CARBON #if TARGET_CARBON
c2pstrcpy((unsigned char *)lpSnd, m_sndname); c2pstrcpy((unsigned char *)lpSnd, m_sndname);
@@ -145,13 +147,13 @@ bool wxWave::Play(bool async, bool looped) const
c2pstr((char *) lpSnd); c2pstr((char *) lpSnd);
#endif #endif
SndListHandle hSnd; SndListHandle hSnd;
hSnd = (SndListHandle) GetNamedResource('snd ',(const unsigned char *) lpSnd); hSnd = (SndListHandle) GetNamedResource('snd ',(const unsigned char *) lpSnd);
if ((hSnd != NULL) && (SndPlay((SndChannelPtr)m_sndChan, (SndListHandle) hSnd, async) == noErr)) if ((hSnd != NULL) && (SndPlay((SndChannelPtr)m_sndChan, (SndListHandle) hSnd, async) == noErr))
ret = true; ret = true;
} }
return ret; return ret;
} }
@@ -159,7 +161,7 @@ bool wxWave::Play(bool async, bool looped) const
bool wxWave::FreeData() bool wxWave::FreeData()
{ {
bool ret = false; bool ret = false;
if (m_isResource) if (m_isResource)
{ {
m_sndname.Empty(); m_sndname.Empty();
@@ -167,9 +169,9 @@ bool wxWave::FreeData()
} }
else else
{ {
//TODO, //TODO,
} }
return ret; return ret;
} }
@@ -188,7 +190,7 @@ bool wxWave::FreeData()
// first, get the volume reference number for the file. Start by // first, get the volume reference number for the file. Start by
// making a Pstring with just the volume name // making a Pstring with just the volume name
strcpy ((char *) name, path); strcpy ((char *) name, path);
if (c = strchr ((char *) name, ':')) if (c = strchr ((char *) name, ':'))
{ {
c++; c++;
*c = '\0'; *c = '\0';
@@ -220,7 +222,7 @@ bool wxWave::FreeData()
void TimerCallBack(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime) void TimerCallBack(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime)
{ {
if(!sndChan) if(!sndChan)
{ {
KillTimer(0,timerID); KillTimer(0,timerID);
return; return;
@@ -243,3 +245,4 @@ void TimerCallBack(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime)
}*/ }*/
#endif

View File

@@ -17,6 +17,8 @@
#include "wx/string.h" #include "wx/string.h"
#include "wx/wave.h" #include "wx/wave.h"
#if wxUSE_WAVE
#ifdef __WXMAC__ #ifdef __WXMAC__
#include "wx/mac/private.h" #include "wx/mac/private.h"
#ifndef __DARWIN__ #ifndef __DARWIN__
@@ -57,7 +59,7 @@ bool wxWave::Create(const wxString& fileName, bool isResource)
ret = true; ret = true;
else else
{ /* { /*
if (sndChan) if (sndChan)
{ // we're playing { // we're playing
FSClose(SndRefNum); FSClose(SndRefNum);
SndRefNum = 0; SndRefNum = 0;
@@ -66,7 +68,7 @@ bool wxWave::Create(const wxString& fileName, bool isResource)
sndChan = 0; sndChan = 0;
KillTimer(0,timerID); KillTimer(0,timerID);
} }
if (!lpSnd) if (!lpSnd)
return true; return true;
@@ -81,14 +83,14 @@ bool wxWave::Create(const wxString& fileName, bool isResource)
sndChan->qLength = 128; sndChan->qLength = 128;
if (noErr != SndNewChannel (&sndChan, sampledSynth, initMono | initNoInterp, 0)) if (noErr != SndNewChannel (&sndChan, sampledSynth, initMono | initNoInterp, 0))
{ {
free(sndChan); free(sndChan);
sndChan = 0; sndChan = 0;
return false; return false;
} }
if (!(SndRefNum = MacOpenSndFile ((char *)lpSnd))) if (!(SndRefNum = MacOpenSndFile ((char *)lpSnd)))
{ {
SndDisposeChannel(sndChan, TRUE); SndDisposeChannel(sndChan, TRUE);
free(sndChan); free(sndChan);
@@ -102,7 +104,7 @@ bool wxWave::Create(const wxString& fileName, bool isResource)
if (fdwSound & SND_ASYNC) if (fdwSound & SND_ASYNC)
async = true; async = true;
if (SndStartFilePlay(sndChan, SndRefNum, 0, 81920, 0, 0, 0, async) != noErr) if (SndStartFilePlay(sndChan, SndRefNum, 0, 81920, 0, 0, 0, async) != noErr)
{ {
FSClose (SndRefNum); FSClose (SndRefNum);
SndRefNum = 0; SndRefNum = 0;
@@ -112,11 +114,11 @@ bool wxWave::Create(const wxString& fileName, bool isResource)
return false; return false;
} }
if (async) if (async)
{ // haven't finish yet { // haven't finish yet
timerID = SetTimer(0, 0, 250, TimerCallBack); timerID = SetTimer(0, 0, 250, TimerCallBack);
} }
else else
{ {
FSClose (SndRefNum); FSClose (SndRefNum);
SndRefNum = 0; SndRefNum = 0;
@@ -125,7 +127,7 @@ bool wxWave::Create(const wxString& fileName, bool isResource)
sndChan = 0; sndChan = 0;
}*/ }*/
} }
return ret; return ret;
} }
@@ -135,8 +137,8 @@ bool wxWave::Play(bool async, bool looped) const
{ {
char lpSnd[32]; char lpSnd[32];
bool ret = false; bool ret = false;
if (m_isResource) if (m_isResource)
{ {
#if TARGET_CARBON #if TARGET_CARBON
c2pstrcpy((unsigned char *)lpSnd, m_sndname); c2pstrcpy((unsigned char *)lpSnd, m_sndname);
@@ -145,13 +147,13 @@ bool wxWave::Play(bool async, bool looped) const
c2pstr((char *) lpSnd); c2pstr((char *) lpSnd);
#endif #endif
SndListHandle hSnd; SndListHandle hSnd;
hSnd = (SndListHandle) GetNamedResource('snd ',(const unsigned char *) lpSnd); hSnd = (SndListHandle) GetNamedResource('snd ',(const unsigned char *) lpSnd);
if ((hSnd != NULL) && (SndPlay((SndChannelPtr)m_sndChan, (SndListHandle) hSnd, async) == noErr)) if ((hSnd != NULL) && (SndPlay((SndChannelPtr)m_sndChan, (SndListHandle) hSnd, async) == noErr))
ret = true; ret = true;
} }
return ret; return ret;
} }
@@ -159,7 +161,7 @@ bool wxWave::Play(bool async, bool looped) const
bool wxWave::FreeData() bool wxWave::FreeData()
{ {
bool ret = false; bool ret = false;
if (m_isResource) if (m_isResource)
{ {
m_sndname.Empty(); m_sndname.Empty();
@@ -167,9 +169,9 @@ bool wxWave::FreeData()
} }
else else
{ {
//TODO, //TODO,
} }
return ret; return ret;
} }
@@ -188,7 +190,7 @@ bool wxWave::FreeData()
// first, get the volume reference number for the file. Start by // first, get the volume reference number for the file. Start by
// making a Pstring with just the volume name // making a Pstring with just the volume name
strcpy ((char *) name, path); strcpy ((char *) name, path);
if (c = strchr ((char *) name, ':')) if (c = strchr ((char *) name, ':'))
{ {
c++; c++;
*c = '\0'; *c = '\0';
@@ -220,7 +222,7 @@ bool wxWave::FreeData()
void TimerCallBack(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime) void TimerCallBack(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime)
{ {
if(!sndChan) if(!sndChan)
{ {
KillTimer(0,timerID); KillTimer(0,timerID);
return; return;
@@ -243,3 +245,4 @@ void TimerCallBack(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime)
}*/ }*/
#endif