git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25463
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
bool wxSoundBackendSDL::Play(wxSoundData *data, unsigned flags)
{
+ Stop();
+
int format;
if (data->m_bitsPerSample == 8)
format = AUDIO_U8;
format = AUDIO_S16LSB;
else
return false;
-
- SDL_LockAudio();
bool needsOpen = true;
if (m_audioOpen)
}
}
- Stop();
-
if (needsOpen)
{
m_spec.format = format;
m_spec.freq = data->m_samplingRate;
m_spec.channels = data->m_channels;
if (!OpenAudio())
- {
- SDL_UnlockAudio();
return false;
- }
}
-
+
+ SDL_LockAudio();
m_playing = true;
m_pos = 0;
m_loop = (flags & wxSOUND_LOOP);
m_data = data;
data->IncRef();
+ SDL_UnlockAudio();
SDL_PauseAudio(0);
- SDL_UnlockAudio();
// wait until playback finishes if called in sync mode:
if (!(flags & wxSOUND_ASYNC))
{
SDL_LockAudio();
SDL_PauseAudio(1);
+ m_playing = false;
if (m_data)
{
m_data->DecRef();