diff --git a/Source/HLEAudio/AudioBuffer.cpp b/Source/HLEAudio/AudioBuffer.cpp index 1f423a12c..a97cca72c 100644 --- a/Source/HLEAudio/AudioBuffer.cpp +++ b/Source/HLEAudio/AudioBuffer.cpp @@ -136,9 +136,6 @@ asm("sync"); if (write_ptr >= mBufferEnd) write_ptr = mBufferBegin; -#ifdef DAEDALUS_PSP - -#else while (write_ptr == read_ptr) { // The buffer is full - spin until the read pointer advances. // Note - spends a lot of time here if program is running @@ -147,11 +144,11 @@ asm("sync"); // ToDo: Adjust Audio Frequency/ Look at Turok in this regard. // We might want to put a Sleep in when executing on the SC? // Give time to other threads when using SYNC mode. - // ThreadYield(); + sceKernelDelayThread(50); read_ptr = mReadPtr; } -#endif + *write_ptr = out; } diff --git a/Source/HLEAudio/Plugin/PSP/AudioPluginPSP.cpp b/Source/HLEAudio/Plugin/PSP/AudioPluginPSP.cpp index a6f2cc7fc..168bfa155 100644 --- a/Source/HLEAudio/Plugin/PSP/AudioPluginPSP.cpp +++ b/Source/HLEAudio/Plugin/PSP/AudioPluginPSP.cpp @@ -157,17 +157,9 @@ static int audioOutput(SceSize args, void *argp) sceKernelWaitSema( mSemaphoretwo, 1, nullptr ); - - sceKernelDcacheInvalidateRange((void *)mei, sizeof(me_struct)); - asm("sync"); - BeginME( mei, (int)&Audio_Ucode, (int)NULL, -1, NULL, -1, NULL); - asm("sync"); - while (CheckME(mei) != 1) { - sceKernelDcacheInvalidateRange((void *)mei, sizeof(me_struct)); - asm("sync"); sceKernelDelayThread(50); // Yield to other threads to avoid 100% CPU usage } @@ -185,20 +177,14 @@ static int audiobuffer(SceSize args, void *argp) sceKernelWaitSema( mSemaphorethree, 1, nullptr ); - sceKernelDcacheInvalidateRange((void *)mei, sizeof(me_struct)); - asm("sync"); while (CheckME(mei) != 1) { - sceKernelDcacheInvalidateRange((void *)mei, sizeof(me_struct)); - asm("sync"); sceKernelDelayThread(50); // Yield to other threads to avoid 100% CPU usage } - sceKernelWaitSema( mSemaphore, 1, nullptr ); - + gAudioPlugin->LenChangedME(); - sceKernelSignalSema( mSemaphore, 1 ); } @@ -214,19 +200,8 @@ int BufferThid = sceKernelCreateThread("audiobuffer", audiobuffer, 0x15, 0x1800, void AudioPluginPSP::FillBuffer(Sample * buffer, u32 num_samples) { - sceKernelWaitSema( mSemaphore, 1, nullptr ); - - dcache_inv_range( mAudioBuffer, sizeof( CAudioBuffer ) ); - asm("sync"); - mAudioBufferUncached->Drain( buffer, num_samples ); - dcache_wbinv_range_unaligned( mAudioBuffer, mAudioBuffer+sizeof( CAudioBuffer ) ); - asm("sync"); - - sceKernelSignalSema( mSemaphore, 1 ); - - } @@ -246,7 +221,8 @@ AudioPluginPSP::AudioPluginPSP() mAudioBuffer = new( mem ) CAudioBuffer( kAudioBufferSize ); mAudioBufferUncached = (CAudioBuffer*)make_uncached_ptr(mem); // Ideally we could just invalidate this range? - dcache_wbinv_range_unaligned( mAudioBuffer, mAudioBuffer+sizeof( CAudioBuffer ) ); + sceKernelDcacheWritebackAll(); + asm("sync"); #ifdef DAEDALUS_PSP_USE_ME InitialiseMediaEngine(); @@ -345,8 +321,6 @@ EProcessResult AudioPluginPSP::ProcessAList() case APM_ENABLED_ASYNC: { //signal the audio thread to kick off a audioucode HLE task. - sceKernelDcacheWritebackAll(); - asm("sync"); sceKernelSignalSema( mSemaphoretwo, 1 ); if(audiothreadactive == false){ audiothreadactive = true; diff --git a/Source/SysPSP/PRX/MediaEngine/main.c b/Source/SysPSP/PRX/MediaEngine/main.c index 3b2520ec0..19de200c1 100644 --- a/Source/SysPSP/PRX/MediaEngine/main.c +++ b/Source/SysPSP/PRX/MediaEngine/main.c @@ -102,12 +102,16 @@ static void me_loop(volatile struct me_struct *mei) while (1); // loop forever until ME reset } - +#define vrp volatile u32* +#define vrg(addr) (*((vrp)(addr))) int InitME(volatile struct me_struct *mei) { unsigned int k1; + vrg(0xbc100004) = 0xffffffff; + + k1 = pspSdkSetK1(0); if (mei == 0)