Don't use timer inside wxSound in wxOSX/Cocoa.

The timer is only used by Carbon code, there is no need for it in Cocoa, so
don't complicate things by starting it unnecessarily.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76324 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-04-12 22:56:17 +00:00
parent 48b21dee76
commit 5276dfa416
2 changed files with 23 additions and 4 deletions

View File

@@ -27,19 +27,25 @@ public :
virtual bool Play(unsigned int flags) = 0;
// stops the sound and deletes the optional timer
virtual void Stop();
// can be called by a timer for repeated tasks during playback
virtual void SoundTask();
// mark this to be deleted
virtual void MarkForDeletion();
virtual bool IsMarkedForDeletion() const { return m_markedForDeletion; }
// does the true work of stopping and cleaning up
virtual void DoStop() = 0;
#if wxOSX_USE_CARBON
// can be called by a timer for repeated tasks during playback
virtual void SoundTask();
protected :
void CreateAndStartTimer();
unsigned int m_flags;
wxSoundTimer* m_pTimer;
#endif // wxOSX_USE_CARBON
protected:
unsigned int m_flags;
bool m_markedForDeletion;
} ;

View File

@@ -20,13 +20,16 @@
#include "wx/string.h"
#include "wx/intl.h"
#include "wx/log.h"
#include "wx/timer.h"
#endif
#include "wx/file.h"
#include "wx/vector.h"
#if wxOSX_USE_CARBON
#include "wx/timer.h"
class wxSoundTimer : public wxTimer
{
public:
@@ -52,11 +55,15 @@ protected:
wxSoundData* m_sound;
};
#endif // wxOSX_USE_CARBON
wxVector<wxSoundData*> s_soundsPlaying;
wxSoundData::wxSoundData()
{
#if wxOSX_USE_CARBON
m_pTimer = NULL;
#endif // wxOSX_USE_CARBON
m_markedForDeletion = false;
}
@@ -72,9 +79,13 @@ void wxSoundData::MarkForDeletion()
void wxSoundData::Stop()
{
DoStop();
#if wxOSX_USE_CARBON
wxDELETE(m_pTimer);
#endif // wxOSX_USE_CARBON
}
#if wxOSX_USE_CARBON
//Time between timer calls
#define MOVIE_DELAY 100
@@ -89,6 +100,8 @@ void wxSoundData::CreateAndStartTimer()
m_pTimer->Start(MOVIE_DELAY, wxTIMER_CONTINUOUS);
}
#endif // wxOSX_USE_CARBON
wxSound::wxSound()
{
Init();