Remove audio mutexes
This commit is contained in:
		
							parent
							
								
									40c1872245
								
							
						
					
					
						commit
						2b7f78d239
					
				
					 3 changed files with 19 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -323,26 +323,34 @@ void ALStream::startStream(float offset)
 | 
			
		|||
 | 
			
		||||
void ALStream::pauseStream()
 | 
			
		||||
{
 | 
			
		||||
#ifndef __EMSCRIPTEN__
 | 
			
		||||
	SDL_LockMutex(pauseMut);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	if (AL::Source::getState(alSrc) != AL_PLAYING)
 | 
			
		||||
		preemptPause = true;
 | 
			
		||||
	else
 | 
			
		||||
		AL::Source::pause(alSrc);
 | 
			
		||||
 | 
			
		||||
#ifndef __EMSCRIPTEN__
 | 
			
		||||
	SDL_UnlockMutex(pauseMut);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ALStream::resumeStream()
 | 
			
		||||
{
 | 
			
		||||
#ifndef __EMSCRIPTEN__
 | 
			
		||||
	SDL_LockMutex(pauseMut);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	if (preemptPause)
 | 
			
		||||
		preemptPause = false;
 | 
			
		||||
	else
 | 
			
		||||
		AL::Source::play(alSrc);
 | 
			
		||||
 | 
			
		||||
#ifndef __EMSCRIPTEN__
 | 
			
		||||
	SDL_UnlockMutex(pauseMut);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ALStream::checkStopped()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -231,12 +231,16 @@ void AudioStream::fadeOut(int duration)
 | 
			
		|||
 * protected by a 'lock'/'unlock' pair */
 | 
			
		||||
void AudioStream::lockStream()
 | 
			
		||||
{
 | 
			
		||||
#ifndef __EMSCRIPTEN__
 | 
			
		||||
	SDL_LockMutex(streamMut);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AudioStream::unlockStream()
 | 
			
		||||
{
 | 
			
		||||
#ifndef __EMSCRIPTEN__
 | 
			
		||||
	SDL_UnlockMutex(streamMut);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AudioStream::setVolume(VolumeType type, float value)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -40,7 +40,6 @@
 | 
			
		|||
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct ALCFunctions
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -586,11 +585,10 @@ void EventThread::requestShowCursor(bool mode)
 | 
			
		|||
	SDL_PushEvent(&event);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
void EventThread::showMessageBox(const char *body, int flags)
 | 
			
		||||
{
 | 
			
		||||
	msgBoxDone.clear();
 | 
			
		||||
	printf(body);
 | 
			
		||||
	printf("Message: %s", body);
 | 
			
		||||
	/* Prevent endless loops */
 | 
			
		||||
	resetInputStates();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -718,25 +716,31 @@ SyncPoint::Util::~Util()
 | 
			
		|||
 | 
			
		||||
void SyncPoint::Util::lock()
 | 
			
		||||
{
 | 
			
		||||
#ifndef __EMSCRIPTEN__
 | 
			
		||||
	locked.set();
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SyncPoint::Util::unlock(bool multi)
 | 
			
		||||
{
 | 
			
		||||
#ifndef __EMSCRIPTEN__
 | 
			
		||||
	locked.clear();
 | 
			
		||||
 | 
			
		||||
	if (multi)
 | 
			
		||||
		SDL_CondBroadcast(cond);
 | 
			
		||||
	else
 | 
			
		||||
		SDL_CondSignal(cond);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SyncPoint::Util::waitForUnlock()
 | 
			
		||||
{
 | 
			
		||||
#ifndef __EMSCRIPTEN__
 | 
			
		||||
	SDL_LockMutex(mut);
 | 
			
		||||
 | 
			
		||||
	while (locked)
 | 
			
		||||
		SDL_CondWait(cond, mut);
 | 
			
		||||
 | 
			
		||||
	SDL_UnlockMutex(mut);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue