X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0770c0a05faf7a863af7d8e7fd203401265d0fac..bc5c09a3aa3662137da2d781c0b101a598d2650d:/src/osx/core/sound.cpp diff --git a/src/osx/core/sound.cpp b/src/osx/core/sound.cpp index 066dcebd6c..386e62a561 100644 --- a/src/osx/core/sound.cpp +++ b/src/osx/core/sound.cpp @@ -1,11 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/osx/carbon/sound.cpp -// Purpose: wxSound class implementation: optional -// Author: Ryan Norton +// Name: src/osx/core/sound.cpp +// Purpose: wxSound class implementation using AudioToolbox +// Author: Stefan Csomor // Modified by: Stefan Csomor -// Created: 1998-01-01 +// Created: 2009-01-01 // RCS-ID: $Id: sound.cpp 61475 2009-07-20 16:47:54Z VZ $ -// Copyright: (c) Ryan Norton +// Copyright: (c) Stefan Csomor // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -56,11 +56,21 @@ wxOSXAudioToolboxSoundData::wxOSXAudioToolboxSoundData(const wxString& fileName) m_sndname = fileName; } -void wxOSXAudioToolboxSoundData::CompletionCallback(SystemSoundID mySSID, void * soundRef) +wxOSXAudioToolboxSoundData::~wxOSXAudioToolboxSoundData() +{ + DoStop(); +} + +void +wxOSXAudioToolboxSoundData::CompletionCallback(SystemSoundID WXUNUSED(mySSID), + void * soundRef) { wxOSXAudioToolboxSoundData* data = (wxOSXAudioToolboxSoundData*) soundRef; data->SoundCompleted(); + + if (data->IsMarkedForDeletion()) + delete data; } void wxOSXAudioToolboxSoundData::SoundCompleted() @@ -102,7 +112,7 @@ bool wxOSXAudioToolboxSoundData::Play(unsigned flags) wxCFRef url(CFURLCreateWithFileSystemPath(kCFAllocatorDefault, cfMutableString , kCFURLPOSIXPathStyle, false)); AudioServicesCreateSystemSoundID(url, &m_soundID); - AudioServicesAddSystemSoundCompletion( m_soundID, NULL, NULL, wxOSXAudioToolboxSoundData::CompletionCallback, (void *) this ); + AudioServicesAddSystemSoundCompletion( m_soundID, CFRunLoopGetCurrent(), NULL, wxOSXAudioToolboxSoundData::CompletionCallback, (void *) this ); bool sync = !(flags & wxSOUND_ASYNC); @@ -119,16 +129,16 @@ bool wxOSXAudioToolboxSoundData::Play(unsigned flags) return true; } -bool wxSound::Create(int size, const wxByte* data) +bool wxSound::Create(int WXUNUSED(size), const wxByte* WXUNUSED(data)) { + wxFAIL_MSG( "not implemented" ); + return false; } bool wxSound::Create(const wxString& fileName, bool isResource) { - if ( isResource ) - return false; - + wxCHECK_MSG( !isResource, false, "not implemented" ); m_data = new wxOSXAudioToolboxSoundData(fileName); return true;