Cocoa Port: Remove now obsolete locks from sound functions, since we now call SPU_Emulate_user() in the emulation thread again.

This commit is contained in:
rogerman 2017-12-07 23:00:28 -08:00
parent cee6867bd8
commit 1e36b36bef
4 changed files with 5 additions and 131 deletions

View File

@ -210,8 +210,6 @@
SPU_ChangeSoundCore(SNDCORE_DUMMY, 0);
}
rwlockAudioEmulateCore = self.rwlockProducer;
pthread_rwlock_unlock(self.rwlockProducer);
// Force the volume back to it's original setting.
@ -456,13 +454,6 @@
}
}
- (void) handleEmuFrameProcessed
{
SPU_Emulate_user();
[super handleEmuFrameProcessed];
}
- (void) handleSetVolume:(NSData *)volumeData
{
const float vol = *(float *)[volumeData bytes];

View File

@ -22,8 +22,6 @@
OERingBuffer *openEmuSoundInterfaceBuffer = nil;
static pthread_mutex_t *mutexAudioSampleReadWrite = NULL;
pthread_rwlock_t *rwlockAudioEmulateCore = NULL;
// Sound interface to the SPU
SoundInterface_struct SNDOpenEmu = {
@ -37,8 +35,8 @@ SoundInterface_struct SNDOpenEmu = {
SNDOpenEmuUnMuteAudio,
SNDOpenEmuSetVolume,
SNDOpenEmuClearBuffer,
SNDOpenEmuFetchSamples,
SNDOpenEmuPostProcessSamples
NULL,
NULL
};
SoundInterface_struct *SNDCoreList[] = {
@ -51,23 +49,12 @@ int SNDOpenEmuInit(int buffer_size)
{
[openEmuSoundInterfaceBuffer setLength:buffer_size * 4 / SPU_SAMPLE_SIZE];
if (mutexAudioSampleReadWrite == NULL)
{
mutexAudioSampleReadWrite = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
pthread_mutex_init(mutexAudioSampleReadWrite, NULL);
}
return 0;
}
void SNDOpenEmuDeInit()
{
if (mutexAudioSampleReadWrite != NULL)
{
pthread_mutex_destroy(mutexAudioSampleReadWrite);
free(mutexAudioSampleReadWrite);
mutexAudioSampleReadWrite = NULL;
}
// Do nothing.
}
int SNDOpenEmuReset()
@ -109,46 +96,3 @@ void SNDOpenEmuClearBuffer()
{
// Do nothing. The OpenEmu frontend will take care of this.
}
void SNDOpenEmuFetchSamples(s16 *sampleBuffer, size_t sampleCount, ESynchMode synchMode, ISynchronizingAudioBuffer *theSynchronizer)
{
if (mutexAudioSampleReadWrite == NULL)
{
return;
}
pthread_mutex_lock(mutexAudioSampleReadWrite);
SPU_DefaultFetchSamples(sampleBuffer, sampleCount, synchMode, theSynchronizer);
pthread_mutex_unlock(mutexAudioSampleReadWrite);
}
size_t SNDOpenEmuPostProcessSamples(s16 *postProcessBuffer, size_t requestedSampleCount, ESynchMode synchMode, ISynchronizingAudioBuffer *theSynchronizer)
{
size_t processedSampleCount = 0;
switch (synchMode)
{
case ESynchMode_DualSynchAsynch:
if (rwlockAudioEmulateCore != NULL)
{
pthread_rwlock_wrlock(rwlockAudioEmulateCore);
processedSampleCount = SPU_DefaultPostProcessSamples(postProcessBuffer, requestedSampleCount, synchMode, theSynchronizer);
pthread_rwlock_unlock(rwlockAudioEmulateCore);
}
break;
case ESynchMode_Synchronous:
if (mutexAudioSampleReadWrite != NULL)
{
pthread_mutex_lock(mutexAudioSampleReadWrite);
processedSampleCount = SPU_DefaultPostProcessSamples(postProcessBuffer, requestedSampleCount, synchMode, theSynchronizer);
pthread_mutex_unlock(mutexAudioSampleReadWrite);
}
break;
default:
break;
}
return processedSampleCount;
}

View File

@ -24,8 +24,6 @@
// Global sound playback manager
static CoreAudioOutput *coreAudioPlaybackManager = NULL;
static pthread_mutex_t *mutexAudioSampleReadWrite = NULL;
pthread_rwlock_t *rwlockAudioEmulateCore = NULL;
// Sound interface to the SPU
SoundInterface_struct SNDOSX = {
@ -39,8 +37,8 @@ SoundInterface_struct SNDOSX = {
SNDOSXUnMuteAudio,
SNDOSXSetVolume,
SNDOSXClearBuffer,
SNDOSXFetchSamples,
SNDOSXPostProcessSamples
NULL,
NULL
};
SoundInterface_struct *SNDCoreList[] = {
@ -55,12 +53,6 @@ int SNDOSXInit(int buffer_size)
coreAudioPlaybackManager = new CoreAudioOutput(buffer_size * 4 / SPU_SAMPLE_SIZE, SPU_SAMPLE_SIZE);
delete oldcoreAudioPlaybackManager;
if (mutexAudioSampleReadWrite == NULL)
{
mutexAudioSampleReadWrite = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
pthread_mutex_init(mutexAudioSampleReadWrite, NULL);
}
coreAudioPlaybackManager->start();
coreAudioPlaybackManager->pause();
@ -71,13 +63,6 @@ void SNDOSXDeInit()
{
delete coreAudioPlaybackManager;
coreAudioPlaybackManager = NULL;
if (mutexAudioSampleReadWrite != NULL)
{
pthread_mutex_destroy(mutexAudioSampleReadWrite);
free(mutexAudioSampleReadWrite);
mutexAudioSampleReadWrite = NULL;
}
}
int SNDOSXReset()
@ -177,46 +162,3 @@ void SNDOSXClearBuffer()
coreAudioPlaybackManager->clearBuffer();
}
void SNDOSXFetchSamples(s16 *sampleBuffer, size_t sampleCount, ESynchMode synchMode, ISynchronizingAudioBuffer *theSynchronizer)
{
if (mutexAudioSampleReadWrite == NULL)
{
return;
}
pthread_mutex_lock(mutexAudioSampleReadWrite);
SPU_DefaultFetchSamples(sampleBuffer, sampleCount, synchMode, theSynchronizer);
pthread_mutex_unlock(mutexAudioSampleReadWrite);
}
size_t SNDOSXPostProcessSamples(s16 *postProcessBuffer, size_t requestedSampleCount, ESynchMode synchMode, ISynchronizingAudioBuffer *theSynchronizer)
{
size_t processedSampleCount = 0;
switch (synchMode)
{
case ESynchMode_DualSynchAsynch:
if (rwlockAudioEmulateCore != NULL)
{
pthread_rwlock_wrlock(rwlockAudioEmulateCore);
processedSampleCount = SPU_DefaultPostProcessSamples(postProcessBuffer, requestedSampleCount, synchMode, theSynchronizer);
pthread_rwlock_unlock(rwlockAudioEmulateCore);
}
break;
case ESynchMode_Synchronous:
if (mutexAudioSampleReadWrite != NULL)
{
pthread_mutex_lock(mutexAudioSampleReadWrite);
processedSampleCount = SPU_DefaultPostProcessSamples(postProcessBuffer, requestedSampleCount, synchMode, theSynchronizer);
pthread_mutex_unlock(mutexAudioSampleReadWrite);
}
break;
default:
break;
}
return processedSampleCount;
}

View File

@ -26,7 +26,6 @@
#define SNDCORE_OSX 58325 //hopefully this is unique number
extern SoundInterface_struct SNDOSX; // Sound interface to the SPU
extern pthread_rwlock_t *rwlockAudioEmulateCore; // RWlock for the emulation core - used when mixing audio in Dual Synch/Asynch mode in post-process
// Core Audio functions for the sound interface
int SNDOSXInit(int buffer_size);
@ -40,7 +39,5 @@ void SNDOSXPauseAudio();
void SNDOSXUnpauseAudio();
void SNDOSXSetVolume(int volume);
void SNDOSXClearBuffer();
void SNDOSXFetchSamples(s16 *sampleBuffer, size_t sampleCount, ESynchMode synchMode, ISynchronizingAudioBuffer *theSynchronizer);
size_t SNDOSXPostProcessSamples(s16 *postProcessBuffer, size_t requestedSampleCount, ESynchMode synchMode, ISynchronizingAudioBuffer *theSynchronizer);
#endif // _OSXSOUNDINTERFACE_