oops, more fixes needed

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25463 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2004-02-02 00:02:03 +00:00
parent 342dc9287c
commit 98840d95db

View File

@@ -238,6 +238,8 @@ void wxSoundBackendSDL::CloseAudio()
bool wxSoundBackendSDL::Play(wxSoundData *data, unsigned flags) bool wxSoundBackendSDL::Play(wxSoundData *data, unsigned flags)
{ {
Stop();
int format; int format;
if (data->m_bitsPerSample == 8) if (data->m_bitsPerSample == 8)
format = AUDIO_U8; format = AUDIO_U8;
@@ -246,8 +248,6 @@ bool wxSoundBackendSDL::Play(wxSoundData *data, unsigned flags)
else else
return false; return false;
SDL_LockAudio();
bool needsOpen = true; bool needsOpen = true;
if (m_audioOpen) if (m_audioOpen)
{ {
@@ -263,28 +263,24 @@ bool wxSoundBackendSDL::Play(wxSoundData *data, unsigned flags)
} }
} }
Stop();
if (needsOpen) if (needsOpen)
{ {
m_spec.format = format; m_spec.format = format;
m_spec.freq = data->m_samplingRate; m_spec.freq = data->m_samplingRate;
m_spec.channels = data->m_channels; m_spec.channels = data->m_channels;
if (!OpenAudio()) if (!OpenAudio())
{
SDL_UnlockAudio();
return false; return false;
} }
}
SDL_LockAudio();
m_playing = true; m_playing = true;
m_pos = 0; m_pos = 0;
m_loop = (flags & wxSOUND_LOOP); m_loop = (flags & wxSOUND_LOOP);
m_data = data; m_data = data;
data->IncRef(); data->IncRef();
SDL_UnlockAudio();
SDL_PauseAudio(0); SDL_PauseAudio(0);
SDL_UnlockAudio();
// wait until playback finishes if called in sync mode: // wait until playback finishes if called in sync mode:
if (!(flags & wxSOUND_ASYNC)) if (!(flags & wxSOUND_ASYNC))
@@ -314,6 +310,7 @@ void wxSoundBackendSDL::Stop()
{ {
SDL_LockAudio(); SDL_LockAudio();
SDL_PauseAudio(1); SDL_PauseAudio(1);
m_playing = false;
if (m_data) if (m_data)
{ {
m_data->DecRef(); m_data->DecRef();