]> git.saurik.com Git - wxWidgets.git/blobdiff - src/unix/sound_sdl.cpp
removed Win16 code (patch 905241), last version with remains of Win16 support tagged...
[wxWidgets.git] / src / unix / sound_sdl.cpp
index ca2e35113ed0cfc3087ec6bd2b2307400f6dad06..16377aed4dbdd336537748ab5e16d3e67008136e 100644 (file)
@@ -5,7 +5,7 @@
 // Modified by:
 // Created:     2004/01/31
 // RCS-ID:      $Id$
 // Modified by:
 // Created:     2004/01/31
 // RCS-ID:      $Id$
-// Copyright:   (c) 2004, Vaclav Slavik
+// Copyright:   (c) 2004, Open Source Applications Foundation
 // Licence:    wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // Licence:    wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
@@ -18,7 +18,7 @@
 #pragma hdrstop
 #endif
 
 #pragma hdrstop
 #endif
 
-#if wxUSE_WAVE && wxUSE_LIBSDL
+#if wxUSE_SOUND && wxUSE_LIBSDL
 
 #include <SDL.h>
 
 
 #include <SDL.h>
 
@@ -56,8 +56,7 @@ END_DECLARE_EVENT_TYPES()
     DECLARE_EVENT_TABLE_ENTRY(wxEVT_SOUND_BACKEND_SDL_NOTIFICATION, \
                               -1,                       \
                               -1,                       \
     DECLARE_EVENT_TABLE_ENTRY(wxEVT_SOUND_BACKEND_SDL_NOTIFICATION, \
                               -1,                       \
                               -1,                       \
-                              (wxObjectEventFunction)   \
-                              (wxSoundBackendSDLNotificationFunction)& func, \
+                              (wxObjectEventFunction)  wxStaticCastEvent( wxSoundBackendSDLNotificationFunction, & func ), \
                               (wxObject *) NULL ),
 
 IMPLEMENT_DYNAMIC_CLASS(wxSoundBackendSDLNotification, wxEvtHandler)
                               (wxObject *) NULL ),
 
 IMPLEMENT_DYNAMIC_CLASS(wxSoundBackendSDLNotification, wxEvtHandler)
@@ -82,9 +81,12 @@ public:
     int GetPriority() const { return 9; }
     bool IsAvailable() const;
     bool HasNativeAsyncPlayback() const { return true; }
     int GetPriority() const { return 9; }
     bool IsAvailable() const;
     bool HasNativeAsyncPlayback() const { return true; }
-    bool Play(wxSoundData *data, unsigned flags);
+    bool Play(wxSoundData *data, unsigned flags,
+              volatile wxSoundPlaybackStatus *status);
 
     void FillAudioBuffer(Uint8 *stream, int len);
 
     void FillAudioBuffer(Uint8 *stream, int len);
+    void FinishedPlayback();
+    
     void Stop();
     bool IsPlaying() const { return m_playing; }
     
     void Stop();
     bool IsPlaying() const { return m_playing; }
     
@@ -113,7 +115,7 @@ private:
     {
         wxLogTrace(_T("sound"),
                    _T("received playback status change notification"));
     {
         wxLogTrace(_T("sound"),
                    _T("received playback status change notification"));
-        m_backend->Stop();
+        m_backend->FinishedPlayback();
     }
     wxSoundBackendSDL *m_backend;
 
     }
     wxSoundBackendSDL *m_backend;
 
@@ -191,6 +193,12 @@ void wxSoundBackendSDL::FillAudioBuffer(Uint8 *stream, int len)
     }
 }
 
     }
 }
 
+void wxSoundBackendSDL::FinishedPlayback()
+{
+    if (!m_playing)
+        Stop();
+}
+
 bool wxSoundBackendSDL::OpenAudio()
 {
     if (!m_audioOpen)
 bool wxSoundBackendSDL::OpenAudio()
 {
     if (!m_audioOpen)
@@ -236,7 +244,8 @@ void wxSoundBackendSDL::CloseAudio()
     }
 }
 
     }
 }
 
-bool wxSoundBackendSDL::Play(wxSoundData *data, unsigned flags)
+bool wxSoundBackendSDL::Play(wxSoundData *data, unsigned flags,
+                             volatile wxSoundPlaybackStatus *WXUNUSED(status))
 {
     Stop();
     
 {
     Stop();
     
@@ -273,6 +282,7 @@ bool wxSoundBackendSDL::Play(wxSoundData *data, unsigned flags)
     }
     
     SDL_LockAudio();
     }
     
     SDL_LockAudio();
+    wxLogTrace(_T("sound"), _T("playing new sound"));
     m_playing = true;
     m_pos = 0;
     m_loop = (flags & wxSOUND_LOOP);
     m_playing = true;
     m_pos = 0;
     m_loop = (flags & wxSOUND_LOOP);
@@ -286,7 +296,7 @@ bool wxSoundBackendSDL::Play(wxSoundData *data, unsigned flags)
     if (!(flags & wxSOUND_ASYNC))
     {
         wxLogTrace(_T("sound"), _T("waiting for sample to finish"));
     if (!(flags & wxSOUND_ASYNC))
     {
         wxLogTrace(_T("sound"), _T("waiting for sample to finish"));
-        while (m_playing)
+        while (m_playing && m_data == data)
         {
 #if wxUSE_THREADS
             // give the playback thread a chance to add event to pending
         {
 #if wxUSE_THREADS
             // give the playback thread a chance to add event to pending
@@ -324,4 +334,4 @@ extern "C" wxSoundBackend *wxCreateSoundBackendSDL()
     return new wxSoundBackendSDL();
 }
 
     return new wxSoundBackendSDL();
 }
 
-#endif // wxUSE_WAVE && wxUSE_LIBSDL
+#endif // wxUSE_SOUND && wxUSE_LIBSDL