Implement audio backend mutexes
This is apparently necessary, and I thought it was leading to the main game thread freezing, but after implementing and testing, that does not appear to be the case. Still, implementing these is correct, so it's best to have it done anyway.
This commit is contained in:
parent
c841d343a3
commit
9efce111c9
1 changed files with 10 additions and 0 deletions
|
@ -20,6 +20,9 @@
|
||||||
static const int bufferSize = 300;
|
static const int bufferSize = 300;
|
||||||
static const int samplingRate = 8000;
|
static const int samplingRate = 8000;
|
||||||
|
|
||||||
|
static pthread_mutex_t mixerMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
static pthread_mutex_t organyaMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
static int buffersWritten = 0;
|
static int buffersWritten = 0;
|
||||||
static int sndfp;
|
static int sndfp;
|
||||||
static FILE* sndfile;
|
static FILE* sndfile;
|
||||||
|
@ -118,6 +121,9 @@ unsigned long SoftwareMixerBackend_Init(void (*callback)(long *stream, size_t fr
|
||||||
audioInfo.play = info;
|
audioInfo.play = info;
|
||||||
ioctl(sndfp, AUDIO_SETINFO, &audioInfo);
|
ioctl(sndfp, AUDIO_SETINFO, &audioInfo);
|
||||||
|
|
||||||
|
pthread_mutex_init(&mixerMutex, NULL);
|
||||||
|
pthread_mutex_init(&organyaMutex, NULL);
|
||||||
|
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
pthread_attr_t thread_attr;
|
pthread_attr_t thread_attr;
|
||||||
pthread_attr_init(&thread_attr);
|
pthread_attr_init(&thread_attr);
|
||||||
|
@ -136,13 +142,17 @@ bool SoftwareMixerBackend_Start(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoftwareMixerBackend_LockMixerMutex(void) {
|
void SoftwareMixerBackend_LockMixerMutex(void) {
|
||||||
|
pthread_mutex_lock(&mixerMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoftwareMixerBackend_UnlockMixerMutex(void) {
|
void SoftwareMixerBackend_UnlockMixerMutex(void) {
|
||||||
|
pthread_mutex_unlock(&mixerMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoftwareMixerBackend_LockOrganyaMutex(void) {
|
void SoftwareMixerBackend_LockOrganyaMutex(void) {
|
||||||
|
pthread_mutex_lock(&organyaMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoftwareMixerBackend_UnlockOrganyaMutex(void) {
|
void SoftwareMixerBackend_UnlockOrganyaMutex(void) {
|
||||||
|
pthread_mutex_unlock(&organyaMutex);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue