class WXDLLEXPORT wxSound : public wxSoundBase
{
public:
- wxSound();
- wxSound(const wxString& fileName, bool isResource = FALSE);
- wxSound(int size, const wxByte* data);
- ~wxSound();
+ wxSound();
+ wxSound(const wxString& fileName, bool isResource = false);
+ wxSound(int size, const wxByte* data);
+ ~wxSound();
public:
- bool Create(const wxString& fileName, bool isResource = FALSE);
- bool IsOk() const { return m_hSnd != NULL; }
- static void Stop();
- static bool IsPlaying();
+ bool Create(const wxString& fileName, bool isResource = false);
+ bool IsOk() const { return m_hSnd != NULL; }
+ static void Stop();
+ static bool IsPlaying();
- inline WX_NSSound GetNSSound()
- { return m_hSnd; }
+ inline WX_NSSound GetNSSound()
+ { return m_hSnd; }
protected:
- bool DoPlay(unsigned flags) const;
+ bool DoPlay(unsigned flags) const;
private:
WX_NSSound m_hSnd; //NSSound handle
// Created: 2004-10-02
// RCS-ID: $Id$
// Copyright: (c) Ryan Norton
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
//
WX_NSSound lastSound=NULL;
-bool isLastSoundLooping = NO;
-bool isLastSoundInScope = NO;
+bool isLastSoundLooping = false;
+bool isLastSoundInScope = false;
// ========================================================================
// wxNSSoundDelegate
{
if (bOK && isLastSoundLooping)
[lastSound play];
- else if (isLastSoundInScope = NO)
+ else if (!isLastSoundInScope)
{
[lastSound release];
[self release];
// ------------------------------------------------------------------
wxSound::wxSound()
-: m_hSnd(NULL), m_waveLength(0)
+: m_hSnd(NULL)
+, m_waveLength(0)
{
}
wxSound::wxSound(const wxString& sFileName, bool isResource)
-: m_hSnd(NULL), m_waveLength(0)
+: m_hSnd(NULL)
+, m_waveLength(0)
{
Create(sFileName, isResource);
}
wxSound::wxSound(int size, const wxByte* data)
-: m_hSnd(NULL), m_waveLength(size)
+: m_hSnd(NULL)
+, m_waveLength(size)
{
NSData* theData = [[NSData alloc] dataWithBytesNoCopy:(void*)data length:size];
m_hSnd = [[NSSound alloc] initWithData:theData];
[m_cocoaSoundDelegate release];
}
else
- isLastSoundInScope = NO;
+ isLastSoundInScope = false;
}
bool wxSound::Create(const wxString& fileName, bool isResource)
if (isResource)
{
- //oftype could be @"snd" @"wav" or @"aiff", nil or @"" autodetects (?)
- m_hSnd = [[NSSound alloc] initWithContentsOfFile:
- [[NSBundle mainBundle] pathForResource:wxNSStringWithWxString(fileName) ofType:nil]
- byReference:NO];
+ //oftype could be @"snd" @"wav" or @"aiff"; nil or @"" autodetects (?)
+ m_hSnd = [[NSSound alloc]
+ initWithContentsOfFile:[[NSBundle mainBundle]
+ pathForResource:wxNSStringWithWxString(fileName)
+ ofType:nil]
+ byReference:YES];
}
else
m_hSnd = [[NSSound alloc] initWithContentsOfFile:wxNSStringWithWxString(fileName) byReference:YES];
bool wxSound::DoPlay(unsigned flags) const
{
- wxASSERT_MSG(!( (flags & wxSOUND_SYNC) && (flags & wxSOUND_LOOP)),
+ wxASSERT_MSG(!( (flags & wxSOUND_SYNC) && (flags & wxSOUND_LOOP)),
wxT("Invalid flag combination passed to wxSound::Play"));
Stop();
{
lastSound = m_hSnd;
isLastSoundLooping = (flags & wxSOUND_LOOP) == wxSOUND_LOOP;
- isLastSoundInScope = YES;
- [m_hSnd setDelegate:m_cocoaSoundDelegate];
+ isLastSoundInScope = true;
+ [m_hSnd setDelegate:m_cocoaSoundDelegate];
return [m_hSnd play];
}
else
{
[m_hSnd setDelegate:nil];
-
- //play until done
+
+ //play until done
bool bOK = [m_hSnd play];
-
- while ([m_hSnd isPlaying])
+
+ while ([m_hSnd isPlaying])
{
wxTheApp->Yield(false);
}
{
if (isLastSoundInScope)
{
- isLastSoundInScope = NO;
-
+ isLastSoundInScope = false;
+
//remember that even though we're
//programatically stopping it, the
- //delegate will still be called -
+ //delegate will still be called -
//so it will free the memory here
[((NSSound*&)lastSound) stop];
}
-
+
lastSound = nil;
}