mirror of
https://github.com/robmcmullen/apple2.git
synced 2024-06-02 08:41:36 +00:00
Added proper locking of conditional variable mutex
This commit is contained in:
parent
d0e4cf72ab
commit
941e583fe0
|
@ -95,7 +95,7 @@ return;
|
|||
conditional = SDL_CreateCond();
|
||||
mutex = SDL_CreateMutex();
|
||||
mutex2 = SDL_CreateMutex();// Let's try real signalling...
|
||||
SDL_mutexP(mutex); // Must lock the mutex for the cond to work properly...
|
||||
// SDL_mutexP(mutex); // Must lock the mutex for the cond to work properly...
|
||||
soundBufferPos = 0;
|
||||
sampleBase = 0;
|
||||
lastToggleCycles = 0;
|
||||
|
@ -266,7 +266,9 @@ Seems like it's OK now that I've fixed the buffer-less-than-length bug...
|
|||
// Hm.
|
||||
// This might not empty the buffer enough, causing hash and trash. !!! FIX !!!
|
||||
SDL_mutexV(mutex2);//Release it so sound thread can get it,
|
||||
SDL_mutexP(mutex); // Must lock the mutex for the cond to work properly...
|
||||
SDL_CondWait(conditional, mutex);//Sleep/wait for the sound thread
|
||||
SDL_mutexV(mutex); // Must unlock the mutex for the cond to work properly...
|
||||
SDL_mutexP(mutex2);//Re-lock it until we're done with it...
|
||||
|
||||
// currentPos = sampleBase + (uint32)((double)deltaCycles / CYCLES_PER_SAMPLE);
|
||||
|
@ -363,7 +365,9 @@ printf("SOUND: AdjustLastToggleCycles() start...\n");
|
|||
// Hm.
|
||||
// This might not empty the buffer enough, causing hash and trash. !!! FIX !!! [DONE]
|
||||
SDL_mutexV(mutex2);//Release it so sound thread can get it,
|
||||
SDL_mutexP(mutex); // Must lock the mutex for the cond to work properly...
|
||||
SDL_CondWait(conditional, mutex);//Sleep/wait for the sound thread
|
||||
SDL_mutexV(mutex); // Must unlock the mutex for the cond to work properly...
|
||||
SDL_mutexP(mutex2);//Re-lock it until we're done with it...
|
||||
|
||||
//HMM, this doesn't need to lock or recalculate this value
|
||||
|
|
Loading…
Reference in New Issue
Block a user