Removed some extraneous whitespace.

Changed YES/NO to true/false; do not confuse BOOL (Objective-C) with bool (C++).
Changed some of the indentation to match that the rest of wxCocoa.

There was an if (isLastSoundInScope = NO) which I think was wrong not only
because it used NO rather than false but also because it's an assignment
rather than a test.  Changed it to if (!isLastSoundInScope).


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29972 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Elliott
2004-10-18 21:41:34 +00:00
parent c5b3143a47
commit 4fca6ee1a6
2 changed files with 39 additions and 34 deletions

View File

@@ -24,21 +24,21 @@
class WXDLLEXPORT wxSound : public wxSoundBase class WXDLLEXPORT wxSound : public wxSoundBase
{ {
public: public:
wxSound(); wxSound();
wxSound(const wxString& fileName, bool isResource = FALSE); wxSound(const wxString& fileName, bool isResource = false);
wxSound(int size, const wxByte* data); wxSound(int size, const wxByte* data);
~wxSound(); ~wxSound();
public: public:
bool Create(const wxString& fileName, bool isResource = FALSE); bool Create(const wxString& fileName, bool isResource = false);
bool IsOk() const { return m_hSnd != NULL; } bool IsOk() const { return m_hSnd != NULL; }
static void Stop(); static void Stop();
static bool IsPlaying(); static bool IsPlaying();
inline WX_NSSound GetNSSound() inline WX_NSSound GetNSSound()
{ return m_hSnd; } { return m_hSnd; }
protected: protected:
bool DoPlay(unsigned flags) const; bool DoPlay(unsigned flags) const;
private: private:
WX_NSSound m_hSnd; //NSSound handle WX_NSSound m_hSnd; //NSSound handle

View File

@@ -6,7 +6,7 @@
// Created: 2004-10-02 // Created: 2004-10-02
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Ryan Norton // Copyright: (c) Ryan Norton
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -32,8 +32,8 @@
// //
WX_NSSound lastSound=NULL; WX_NSSound lastSound=NULL;
bool isLastSoundLooping = NO; bool isLastSoundLooping = false;
bool isLastSoundInScope = NO; bool isLastSoundInScope = false;
// ======================================================================== // ========================================================================
// wxNSSoundDelegate // wxNSSoundDelegate
@@ -52,7 +52,7 @@ bool isLastSoundInScope = NO;
{ {
if (bOK && isLastSoundLooping) if (bOK && isLastSoundLooping)
[lastSound play]; [lastSound play];
else if (isLastSoundInScope = NO) else if (!isLastSoundInScope)
{ {
[lastSound release]; [lastSound release];
[self release]; [self release];
@@ -66,18 +66,21 @@ bool isLastSoundInScope = NO;
// ------------------------------------------------------------------ // ------------------------------------------------------------------
wxSound::wxSound() wxSound::wxSound()
: m_hSnd(NULL), m_waveLength(0) : m_hSnd(NULL)
, m_waveLength(0)
{ {
} }
wxSound::wxSound(const wxString& sFileName, bool isResource) wxSound::wxSound(const wxString& sFileName, bool isResource)
: m_hSnd(NULL), m_waveLength(0) : m_hSnd(NULL)
, m_waveLength(0)
{ {
Create(sFileName, isResource); Create(sFileName, isResource);
} }
wxSound::wxSound(int size, const wxByte* data) 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]; NSData* theData = [[NSData alloc] dataWithBytesNoCopy:(void*)data length:size];
m_hSnd = [[NSSound alloc] initWithData:theData]; m_hSnd = [[NSSound alloc] initWithData:theData];
@@ -93,7 +96,7 @@ wxSound::~wxSound()
[m_cocoaSoundDelegate release]; [m_cocoaSoundDelegate release];
} }
else else
isLastSoundInScope = NO; isLastSoundInScope = false;
} }
bool wxSound::Create(const wxString& fileName, bool isResource) bool wxSound::Create(const wxString& fileName, bool isResource)
@@ -104,10 +107,12 @@ bool wxSound::Create(const wxString& fileName, bool isResource)
if (isResource) if (isResource)
{ {
//oftype could be @"snd" @"wav" or @"aiff", nil or @"" autodetects (?) //oftype could be @"snd" @"wav" or @"aiff"; nil or @"" autodetects (?)
m_hSnd = [[NSSound alloc] initWithContentsOfFile: m_hSnd = [[NSSound alloc]
[[NSBundle mainBundle] pathForResource:wxNSStringWithWxString(fileName) ofType:nil] initWithContentsOfFile:[[NSBundle mainBundle]
byReference:NO]; pathForResource:wxNSStringWithWxString(fileName)
ofType:nil]
byReference:YES];
} }
else else
m_hSnd = [[NSSound alloc] initWithContentsOfFile:wxNSStringWithWxString(fileName) byReference:YES]; m_hSnd = [[NSSound alloc] initWithContentsOfFile:wxNSStringWithWxString(fileName) byReference:YES];
@@ -129,15 +134,15 @@ bool wxSound::DoPlay(unsigned flags) const
{ {
lastSound = m_hSnd; lastSound = m_hSnd;
isLastSoundLooping = (flags & wxSOUND_LOOP) == wxSOUND_LOOP; isLastSoundLooping = (flags & wxSOUND_LOOP) == wxSOUND_LOOP;
isLastSoundInScope = YES; isLastSoundInScope = true;
[m_hSnd setDelegate:m_cocoaSoundDelegate]; [m_hSnd setDelegate:m_cocoaSoundDelegate];
return [m_hSnd play]; return [m_hSnd play];
} }
else else
{ {
[m_hSnd setDelegate:nil]; [m_hSnd setDelegate:nil];
//play until done //play until done
bool bOK = [m_hSnd play]; bool bOK = [m_hSnd play];
while ([m_hSnd isPlaying]) while ([m_hSnd isPlaying])
@@ -157,7 +162,7 @@ void wxSound::Stop()
{ {
if (isLastSoundInScope) if (isLastSoundInScope)
{ {
isLastSoundInScope = NO; isLastSoundInScope = false;
//remember that even though we're //remember that even though we're
//programatically stopping it, the //programatically stopping it, the