Cocoa OpenEmu Plug-in:

- Fix compiling by updating the sound processing code. Fixes bug #3549080 - http://sourceforge.net/tracker/?func=detail&aid=3549080&group_id=164579&atid=832291
This commit is contained in:
rogerman 2012-08-06 23:01:29 +00:00
parent 98329bf085
commit dae7f8f2dd
4 changed files with 68 additions and 2 deletions

View File

@ -22,4 +22,9 @@
#define DESMUME_COCOA
#define HAVE_OPENGL
#define HAVE_LIBZ
#if defined(__i386__) || defined(__x86_64__)
#define HAVE_JIT
#endif
#define PORT_VERSION "OpenEmu"

View File

@ -54,6 +54,7 @@
// Set up the emulation core
CommonSettings.advanced_timing = true;
CommonSettings.use_jit = false;
[CocoaDSCore startupCore];
// Set up the DS firmware using the internal firmware

View File

@ -41,6 +41,8 @@ void SNDOpenEmuMuteAudio();
void SNDOpenEmuUnMuteAudio();
void SNDOpenEmuSetVolume(int volume);
void SNDOpenEmuClearBuffer();
void SNDOpenEmuFetchSamples(s16 *sampleBuffer, size_t sampleCount, ESynchMode synchMode, ISynchronizingAudioBuffer *theSynchronizer);
size_t SNDOpenEmuPostProcessSamples(s16 *postProcessBuffer, size_t requestedSampleCount, ESynchMode synchMode, ISynchronizingAudioBuffer *theSynchronizer);
#ifdef __cplusplus
}

View File

@ -21,6 +21,8 @@
OERingBuffer *openEmuSoundInterfaceBuffer = nil;
static pthread_mutex_t *mutexAudioSampleReadWrite = NULL;
pthread_mutex_t *mutexAudioEmulateCore = NULL;
// Sound interface to the SPU
SoundInterface_struct SNDOpenEmu = {
@ -33,7 +35,9 @@ SoundInterface_struct SNDOpenEmu = {
SNDOpenEmuMuteAudio,
SNDOpenEmuUnMuteAudio,
SNDOpenEmuSetVolume,
SNDOpenEmuClearBuffer
SNDOpenEmuClearBuffer,
SNDOpenEmuFetchSamples,
SNDOpenEmuPostProcessSamples
};
SoundInterface_struct *SNDCoreList[] = {
@ -46,12 +50,23 @@ int SNDOpenEmuInit(int buffer_size)
{
[openEmuSoundInterfaceBuffer setLength:buffer_size];
if (mutexAudioSampleReadWrite == NULL)
{
mutexAudioSampleReadWrite = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
pthread_mutex_init(mutexAudioSampleReadWrite, NULL);
}
return 0;
}
void SNDOpenEmuDeInit()
{
// Do nothing. The OpenEmu frontend will take care of this.
if (mutexAudioSampleReadWrite != NULL)
{
pthread_mutex_destroy(mutexAudioSampleReadWrite);
free(mutexAudioSampleReadWrite);
mutexAudioSampleReadWrite = NULL;
}
}
int SNDOpenEmuReset()
@ -89,3 +104,46 @@ 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 (mutexAudioEmulateCore != NULL)
{
pthread_mutex_lock(mutexAudioEmulateCore);
processedSampleCount = SPU_DefaultPostProcessSamples(postProcessBuffer, requestedSampleCount, synchMode, theSynchronizer);
pthread_mutex_unlock(mutexAudioEmulateCore);
}
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;
}