X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3a818b15a1887257cc9f7bca82ae69c7ab014fbc..6bc176b4ab7ed858d558546bcdd0a05229b64a3b:/src/unix/sound_sdl.cpp diff --git a/src/unix/sound_sdl.cpp b/src/unix/sound_sdl.cpp index 16377aed4d..512f1d987d 100644 --- a/src/unix/sound_sdl.cpp +++ b/src/unix/sound_sdl.cpp @@ -1,21 +1,19 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: sound_sdl.cpp +// Name: src/unix/sound_sdl.cpp // Purpose: wxSound backend using SDL // Author: Vaclav Slavik // Modified by: // Created: 2004/01/31 // RCS-ID: $Id$ // Copyright: (c) 2004, Open Source Applications Foundation -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // for compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#include "wx/setup.h" - #if defined(__BORLANDC__) -#pragma hdrstop + #pragma hdrstop #endif #if wxUSE_SOUND && wxUSE_LIBSDL @@ -27,10 +25,10 @@ #include "wx/intl.h" #include "wx/log.h" #include "wx/utils.h" + #include "wx/module.h" #endif #include "wx/thread.h" -#include "wx/module.h" #include "wx/sound.h" // ---------------------------------------------------------------------------- @@ -42,25 +40,23 @@ class wxSoundBackendSDLNotification : public wxEvent public: DECLARE_DYNAMIC_CLASS(wxSoundBackendSDLNotification) wxSoundBackendSDLNotification(); - wxEvent *Clone() const { return new wxSoundBackendSDLNotification(*this); } + wxEvent *Clone() const { return new wxSoundBackendSDLNotification(*this); } }; typedef void (wxEvtHandler::*wxSoundBackendSDLNotificationFunction) (wxSoundBackendSDLNotification&); -BEGIN_DECLARE_EVENT_TYPES() - DECLARE_LOCAL_EVENT_TYPE(wxEVT_SOUND_BACKEND_SDL_NOTIFICATION, -1) -END_DECLARE_EVENT_TYPES() +wxDECLARE_LOCAL_EVENT( wxEVT_SOUND_BACKEND_SDL_NOTIFICATION, wxSoundBackendSDLNotification ) #define EVT_SOUND_BACKEND_SDL_NOTIFICATON(func) \ DECLARE_EVENT_TABLE_ENTRY(wxEVT_SOUND_BACKEND_SDL_NOTIFICATION, \ -1, \ -1, \ - (wxObjectEventFunction) wxStaticCastEvent( wxSoundBackendSDLNotificationFunction, & func ), \ + wxEVENT_HANDLER_CAST( wxSoundBackendSDLNotificationFunction, func ), \ (wxObject *) NULL ), IMPLEMENT_DYNAMIC_CLASS(wxSoundBackendSDLNotification, wxEvtHandler) -DEFINE_EVENT_TYPE(wxEVT_SOUND_BACKEND_SDL_NOTIFICATION) +wxDEFINE_EVENT( wxEVT_SOUND_BACKEND_SDL_NOTIFICATION, wxSoundBackendSDLNotification ) wxSoundBackendSDLNotification::wxSoundBackendSDLNotification() { @@ -72,11 +68,11 @@ class wxSoundBackendSDLEvtHandler; class wxSoundBackendSDL : public wxSoundBackend { public: - wxSoundBackendSDL() + wxSoundBackendSDL() : m_initialized(false), m_playing(false), m_audioOpen(false), m_data(NULL), m_evtHandler(NULL) {} virtual ~wxSoundBackendSDL(); - + wxString GetName() const { return _T("Simple DirectMedia Layer"); } int GetPriority() const { return 9; } bool IsAvailable() const; @@ -86,14 +82,14 @@ public: void FillAudioBuffer(Uint8 *stream, int len); void FinishedPlayback(); - + void Stop(); bool IsPlaying() const { return m_playing; } - + private: bool OpenAudio(); void CloseAudio(); - + bool m_initialized; bool m_playing, m_audioOpen; // playback information: @@ -205,19 +201,19 @@ bool wxSoundBackendSDL::OpenAudio() { if (!m_evtHandler) m_evtHandler = new wxSoundBackendSDLEvtHandler(this); - + m_spec.silence = 0; m_spec.samples = 4096; m_spec.size = 0; m_spec.callback = wx_sdl_audio_callback; m_spec.userdata = (void*)this; - + wxLogTrace(_T("sound"), _T("opening SDL audio...")); if (SDL_OpenAudio(&m_spec, NULL) >= 0) { #if wxUSE_LOG_DEBUG char driver[256]; - SDL_AudioDriverName(driver, 256); + SDL_AudioDriverName(driver, 256); wxLogTrace(_T("sound"), _T("opened audio, driver '%s'"), wxString(driver, wxConvLocal).c_str()); #endif @@ -248,7 +244,7 @@ bool wxSoundBackendSDL::Play(wxSoundData *data, unsigned flags, volatile wxSoundPlaybackStatus *WXUNUSED(status)) { Stop(); - + int format; if (data->m_bitsPerSample == 8) format = AUDIO_U8; @@ -271,7 +267,7 @@ bool wxSoundBackendSDL::Play(wxSoundData *data, unsigned flags, CloseAudio(); } } - + if (needsOpen) { m_spec.format = format; @@ -280,7 +276,7 @@ bool wxSoundBackendSDL::Play(wxSoundData *data, unsigned flags, if (!OpenAudio()) return false; } - + SDL_LockAudio(); wxLogTrace(_T("sound"), _T("playing new sound")); m_playing = true; @@ -304,7 +300,7 @@ bool wxSoundBackendSDL::Play(wxSoundData *data, unsigned flags, if (wxThread::IsMain()) wxMutexGuiLeave(); #endif - wxUsleep(10); + wxMilliSleep(10); #if wxUSE_THREADS if (wxThread::IsMain()) wxMutexGuiEnter();