]>
git.saurik.com Git - wxWidgets.git/blob - src/osx/sound_osx.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/sound_osx.cpp
3 // Purpose: wxSound class common osx code
4 // Author: Stefan Csomor
7 // RCS-ID: $Id: sound.cpp 61475 2009-07-20 16:47:54Z VZ $
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
20 #include "wx/object.h"
21 #include "wx/string.h"
29 #include "wx/vector.h"
31 class wxSoundTimer
: public wxTimer
34 wxSoundTimer(wxSoundData
* snd
)
39 virtual ~wxSoundTimer()
54 wxVector
<wxSoundData
*> s_soundsPlaying
;
56 wxSoundData::wxSoundData()
61 wxSoundData::~wxSoundData()
65 void wxSoundData::Stop()
75 //Time between timer calls
76 #define MOVIE_DELAY 100
78 void wxSoundData::SoundTask()
82 void wxSoundData::CreateAndStartTimer()
84 //Start timer and play movie asyncronously
85 m_pTimer
= new wxSoundTimer(this);
86 m_pTimer
->Start(MOVIE_DELAY
, wxTIMER_CONTINUOUS
);
94 wxSound::wxSound(const wxString
& sFileName
, bool isResource
)
97 Create(sFileName
, isResource
);
100 wxSound::wxSound(int size
, const wxByte
* data
)
103 Create( size
, data
);
116 bool wxSound::DoPlay(unsigned flags
) const
120 s_soundsPlaying
.push_back(m_data
);
121 if ( !m_data
->Play(flags
) )
122 s_soundsPlaying
.pop_back();
128 bool wxSound::IsPlaying()
130 return s_soundsPlaying
.size() > 0;
135 for ( wxVector
<wxSoundData
*>::reverse_iterator s
= s_soundsPlaying
.rbegin();
136 s
!= s_soundsPlaying
.rend(); ++s
)
142 // Notification when a sound has stopped
143 void wxSound::SoundStopped(const wxSoundData
* data
)
145 for ( wxVector
<wxSoundData
*>::iterator s
= s_soundsPlaying
.begin();
146 s
!= s_soundsPlaying
.end(); ++s
)
150 s_soundsPlaying
.erase(s
);