Remove audio mutexes

This commit is contained in:
Varun Patil 2020-05-05 11:17:12 +05:30
parent 40c1872245
commit 2b7f78d239
3 changed files with 19 additions and 3 deletions

View File

@ -323,26 +323,34 @@ void ALStream::startStream(float offset)
void ALStream::pauseStream() void ALStream::pauseStream()
{ {
#ifndef __EMSCRIPTEN__
SDL_LockMutex(pauseMut); SDL_LockMutex(pauseMut);
#endif
if (AL::Source::getState(alSrc) != AL_PLAYING) if (AL::Source::getState(alSrc) != AL_PLAYING)
preemptPause = true; preemptPause = true;
else else
AL::Source::pause(alSrc); AL::Source::pause(alSrc);
#ifndef __EMSCRIPTEN__
SDL_UnlockMutex(pauseMut); SDL_UnlockMutex(pauseMut);
#endif
} }
void ALStream::resumeStream() void ALStream::resumeStream()
{ {
#ifndef __EMSCRIPTEN__
SDL_LockMutex(pauseMut); SDL_LockMutex(pauseMut);
#endif
if (preemptPause) if (preemptPause)
preemptPause = false; preemptPause = false;
else else
AL::Source::play(alSrc); AL::Source::play(alSrc);
#ifndef __EMSCRIPTEN__
SDL_UnlockMutex(pauseMut); SDL_UnlockMutex(pauseMut);
#endif
} }
void ALStream::checkStopped() void ALStream::checkStopped()

View File

@ -231,12 +231,16 @@ void AudioStream::fadeOut(int duration)
* protected by a 'lock'/'unlock' pair */ * protected by a 'lock'/'unlock' pair */
void AudioStream::lockStream() void AudioStream::lockStream()
{ {
#ifndef __EMSCRIPTEN__
SDL_LockMutex(streamMut); SDL_LockMutex(streamMut);
#endif
} }
void AudioStream::unlockStream() void AudioStream::unlockStream()
{ {
#ifndef __EMSCRIPTEN__
SDL_UnlockMutex(streamMut); SDL_UnlockMutex(streamMut);
#endif
} }
void AudioStream::setVolume(VolumeType type, float value) void AudioStream::setVolume(VolumeType type, float value)

View File

@ -40,7 +40,6 @@
#include <string.h> #include <string.h>
struct ALCFunctions struct ALCFunctions
{ {
@ -586,11 +585,10 @@ void EventThread::requestShowCursor(bool mode)
SDL_PushEvent(&event); SDL_PushEvent(&event);
} }
#include <stdio.h>
void EventThread::showMessageBox(const char *body, int flags) void EventThread::showMessageBox(const char *body, int flags)
{ {
msgBoxDone.clear(); msgBoxDone.clear();
printf(body); printf("Message: %s", body);
/* Prevent endless loops */ /* Prevent endless loops */
resetInputStates(); resetInputStates();
} }
@ -718,25 +716,31 @@ SyncPoint::Util::~Util()
void SyncPoint::Util::lock() void SyncPoint::Util::lock()
{ {
#ifndef __EMSCRIPTEN__
locked.set(); locked.set();
#endif
} }
void SyncPoint::Util::unlock(bool multi) void SyncPoint::Util::unlock(bool multi)
{ {
#ifndef __EMSCRIPTEN__
locked.clear(); locked.clear();
if (multi) if (multi)
SDL_CondBroadcast(cond); SDL_CondBroadcast(cond);
else else
SDL_CondSignal(cond); SDL_CondSignal(cond);
#endif
} }
void SyncPoint::Util::waitForUnlock() void SyncPoint::Util::waitForUnlock()
{ {
#ifndef __EMSCRIPTEN__
SDL_LockMutex(mut); SDL_LockMutex(mut);
while (locked) while (locked)
SDL_CondWait(cond, mut); SDL_CondWait(cond, mut);
SDL_UnlockMutex(mut); SDL_UnlockMutex(mut);
#endif
} }