- bool needsReopen = true;
- // shut down playing of finished sound:
- wxSoundBackendSDLQueueEntry *e = m_queue.front();
- if (e->m_finished)
- {
- SDL_PauseAudio(1);
- e->m_data->DecRef();
- m_queue.pop_front();
- if (!m_queue.empty() &&
- e->m_spec.freq == m_queue.front()->m_spec.freq &&
- e->m_spec.channels == m_queue.front()->m_spec.channels &&
- e->m_spec.format == m_queue.front()->m_spec.format)
- {
- needsReopen = false;
- }
- else
- {
- SDL_CloseAudio();
- wxLogTrace(_T("sound"), _T("closed audio"));
- }
- delete e;
- }
- // start playing another one:
- if (!m_queue.empty())
- {
- wxSoundBackendSDLQueueEntry *e = m_queue.front();
- m_playing = true;
- wxLogTrace(_T("sound"), _T("playing sample %p"), e);
-
- if (needsReopen)
- {
- wxLogTrace(_T("sound"), _T("opening SDL audio..."));
- status = (SDL_OpenAudio(&e->m_spec, NULL) >= 0);
- if (status)
- {
-#if wxUSE_LOG_DEBUG
- char driver[256];
- SDL_AudioDriverName(driver, 256);
- wxLogTrace(_T("sound"), _T("opened audio, driver '%s'"),
- wxString(driver, wxConvLocal).c_str());
-#endif
- SDL_PauseAudio(0);
- }
- else
- {
- wxString err(SDL_GetError(), wxConvLocal);
- wxLogError(_("Couldn't open audio: %s"), err.c_str());
- m_queue.pop_front();
- delete e;
- }
- }
- else
- SDL_PauseAudio(0);
- }