X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9be32e8f2d2b7ada287f03a0e19e3a40db2e9770..ad0ac642d5764497804bee2caad4fc1f20fc6cea:/include/wx/unix/sound.h?ds=sidebyside diff --git a/include/wx/unix/sound.h b/include/wx/unix/sound.h index c85b0ef866..2ebb2e53c6 100644 --- a/include/wx/unix/sound.h +++ b/include/wx/unix/sound.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wave.h +// Name: sound.h // Purpose: wxSound class // Author: Julian Smart, Vaclav Slavik // Modified by: @@ -14,7 +14,7 @@ #include "wx/defs.h" -#if wxUSE_WAVE +#if wxUSE_SOUND #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma interface "sound.h" @@ -26,12 +26,12 @@ // wxSound: simple audio playback class // ---------------------------------------------------------------------------- -class wxSoundBackend; -class wxSound; -class wxDynamicLibrary; +class WXDLLIMPEXP_ADV wxSoundBackend; +class WXDLLIMPEXP_ADV wxSound; +class WXDLLIMPEXP_BASE wxDynamicLibrary; /// Sound data, as loaded from .wav file: -class wxSoundData +class WXDLLIMPEXP_ADV wxSoundData { public: wxSoundData() : m_refCnt(1) {} @@ -59,7 +59,7 @@ private: /// Simple sound class: -class wxSound : public wxSoundBase +class WXDLLIMPEXP_ADV wxSound : public wxSoundBase { public: wxSound(); @@ -73,12 +73,18 @@ public: bool Create(int size, const wxByte* data); bool IsOk() const { return m_data != NULL; } + + // Stop playing any sound + static void Stop(); + + // Returns true if a sound is being played + static bool IsPlaying(); // for internal use static void UnloadBackend(); protected: - bool DoPlay(unsigned flags); + bool DoPlay(unsigned flags) const; static void EnsureBackend(); void Free(); @@ -100,12 +106,22 @@ private: // ---------------------------------------------------------------------------- // This is interface to sound playing implementation. There are multiple -// sound architectures in use on Unix platforms and wxWindows can use several +// sound architectures in use on Unix platforms and wxWidgets can use several // of them for playback, depending on their availability at runtime; hence -// the need for backends. This class is for use by wxWindows and people writing -// additional backends only, it is _not_ for use by applications! +// the need for backends. This class is for use by wxWidgets and people writing +// additional backends only, it is _not_ for use by applications! + +// Structure that holds playback status information +struct wxSoundPlaybackStatus +{ + // playback is in progress + bool m_playing; + // main thread called wxSound::Stop() + bool m_stopRequested; +}; -class wxSoundBackend +// Audio backend interface +class WXDLLIMPEXP_ADV wxSoundBackend { public: virtual ~wxSoundBackend() {} @@ -121,16 +137,28 @@ public: virtual bool IsAvailable() const = 0; // Returns true if the backend is capable of playing sound asynchronously. - // If false, then wxWindows creates a playback thread and handles async + // If false, then wxWidgets creates a playback thread and handles async // playback, otherwise it is left up to the backend (will usually be more - // effective) + // effective). virtual bool HasNativeAsyncPlayback() const = 0; - - // Plays the sound. flags are same flags as those passed to wxSound::Play - virtual bool Play(wxSoundData *data, unsigned flags) = 0; + + // Plays the sound. flags are same flags as those passed to wxSound::Play. + // The function should periodically check the value of + // status->m_stopRequested and terminate if it is set to true (it may + // be modified by another thread) + virtual bool Play(wxSoundData *data, unsigned flags, + volatile wxSoundPlaybackStatus *status) = 0; + + // Stops playback (if something is played). + virtual void Stop() = 0; + + // Returns true if the backend is playing anything at the moment. + // (This method is never called for backends that don't support async + // playback.) + virtual bool IsPlaying() const = 0; }; -#endif // wxUSE_WAVE +#endif // wxUSE_SOUND #endif