/////////////////////////////////////////////////////////////////////////////
// Name: sound.cpp
// Purpose: wxSound class implementation: optional
/////////////////////////////////////////////////////////////////////////////
// Name: sound.cpp
// Purpose: wxSound class implementation: optional
- wxQTTimer(Movie movie, bool bLoop) :
- m_movie(movie), m_bLoop(bLoop)
+ wxQTTimer(Movie movie, bool bLoop, bool& playing) :
+ m_movie(movie), m_bLoop(bLoop), m_pbPlaying(&playing)
- wxSMTimer(void* hSnd, void* pSndChannel, const bool& bLoop)
- : m_hSnd(hSnd), m_pSndChannel(pSndChannel), m_bLoop(bLoop)
- {
- }
+ wxSMTimer(void* hSnd, void* pSndChannel, const bool& bLoop, bool& playing)
+ : m_hSnd(hSnd), m_pSndChannel(pSndChannel), m_bLoop(bLoop), m_pbPlaying(&playing)
+ {
+ }
- Shutdown();
-
- //if the sound isn't playing anymore, see if it's looped,
- //and if so play it again, otherwise close things up
- if (stat.scChannelBusy == FALSE)
- {
- if (m_bLoop)
- {
- if(SndPlay((SndChannelPtr)m_pSndChannel, (SndListHandle) m_hSnd, true) != noErr)
- Shutdown();
- }
- else
- Shutdown();
+ Shutdown();
+
+ //if the sound isn't playing anymore, see if it's looped,
+ //and if so play it again, otherwise close things up
+ if (stat.scChannelBusy == FALSE)
+ {
+ if (m_bLoop)
+ {
+ if(SndPlay((SndChannelPtr)m_pSndChannel, (SndListHandle) m_hSnd, true) != noErr)
+ Shutdown();
+ }
+ else
+ Shutdown();
};
// ------------------------------------------------------------------
// wxSound
// ------------------------------------------------------------------
};
// ------------------------------------------------------------------
// wxSound
// ------------------------------------------------------------------
//-2093 no dll
if ((nError = InitializeQTML(0)) != noErr)
wxLogSysError(wxString::Format("Couldn't Initialize Quicktime-%i", nError));
//-2093 no dll
if ((nError = InitializeQTML(0)) != noErr)
wxLogSysError(wxString::Format("Couldn't Initialize Quicktime-%i", nError));
wxSound::wxSound(int size, const wxByte* data)
: m_hSnd((char*)data), m_waveLength(size), m_pTimer(NULL), m_type(wxSound_MEMORY)
{
wxSound::wxSound(int size, const wxByte* data)
: m_hSnd((char*)data), m_waveLength(size), m_pTimer(NULL), m_type(wxSound_MEMORY)
{
BlockMove(m_hSnd, *myHandle, m_waveLength);
err = PtrToHand(&myHandle, &dataRef, sizeof(Handle));
BlockMove(m_hSnd, *myHandle, m_waveLength);
err = PtrToHand(&myHandle, &dataRef, sizeof(Handle));
else if (memcmp(&m_hSnd[8], "AIFC", 4) == 0)
miComponent = OpenDefaultComponent(MovieImportType, kQTFileTypeAIFC);
else
else if (memcmp(&m_hSnd[8], "AIFC", 4) == 0)
miComponent = OpenDefaultComponent(MovieImportType, kQTFileTypeAIFC);
else
SetMovieVolume(movie, kFullVolume);
GoToBeginningOfMovie(movie);
SetMovieVolume(movie, kFullVolume);
GoToBeginningOfMovie(movie);
SndChannelPtr pSndChannel;
SndNewChannel(&pSndChannel, sampledSynth,
SndChannelPtr pSndChannel;
SndNewChannel(&pSndChannel, sampledSynth,
- {
- ((wxSMTimer*&)m_pTimer) = new wxSMTimer(pSndChannel, m_hSnd, flags & wxSOUND_LOOP ? 1 : 0);
-
- ((wxTimer*)m_pTimer)->Start(MOVIE_DELAY, wxTIMER_CONTINUOUS);
- }
- else
+ {
+ lastSoundTimer = ((wxSMTimer*&)m_pTimer)
+ = new wxSMTimer(pSndChannel, m_hSnd, flags & wxSOUND_LOOP ? 1 : 0,
+ lastSoundIsPlaying=true);
+
+ ((wxTimer*)m_pTimer)->Start(MOVIE_DELAY, wxTIMER_CONTINUOUS);
+ }
+ else
- //Note that ExitMovies() is not neccessary, but
- //the docs are fuzzy on whether or not TerminateQTML is
- ExitMovies();
+void* wxSound::GetHandle()
+{
+ if(m_type == wxSound_RESOURCE)
+ return (void*) ((wxSMTimer*)m_pTimer)->GetChannel();