Try to make DTK rewrite handle events the same way as the old code.
This commit is contained in:
parent
a282f181cd
commit
1f604e87be
|
@ -56,6 +56,7 @@ This file mainly deals with the [Drive I/F], however [AIDFR] controls
|
|||
#include "Core/CoreTiming.h"
|
||||
#include "Core/HW/AudioInterface.h"
|
||||
#include "Core/HW/CPU.h"
|
||||
#include "Core/HW/DVDInterface.h"
|
||||
#include "Core/HW/MMIO.h"
|
||||
#include "Core/HW/ProcessorInterface.h"
|
||||
#include "Core/HW/SystemTimers.h"
|
||||
|
@ -202,6 +203,9 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
|
|||
m_Control.PSTAT = tmpAICtrl.PSTAT;
|
||||
g_LastCPUTime = CoreTiming::GetTicks();
|
||||
|
||||
// Tell Drive Interface to start/stop streaming
|
||||
DVDInterface::g_bStream = tmpAICtrl.PSTAT;
|
||||
|
||||
CoreTiming::RemoveEvent(et_AI);
|
||||
CoreTiming::ScheduleEvent(((int)GetAIPeriod() / 2), et_AI);
|
||||
}
|
||||
|
@ -306,9 +310,4 @@ u64 GetAIPeriod()
|
|||
return period;
|
||||
}
|
||||
|
||||
bool IsAISPlaying()
|
||||
{
|
||||
return m_Control.PSTAT;
|
||||
}
|
||||
|
||||
} // end of namespace AudioInterface
|
||||
|
|
|
@ -27,6 +27,4 @@ unsigned int GetAIDSampleRate();
|
|||
|
||||
void GenerateAISInterrupt();
|
||||
|
||||
bool IsAISPlaying();
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -303,7 +303,7 @@ void DTKStreamingCallback(u64 userdata, int cyclesLate)
|
|||
static const int NUM_SAMPLES = 48000 / 2000 * 7; // 3.5ms of 48kHz samples
|
||||
short tempPCM[NUM_SAMPLES * 2];
|
||||
unsigned samples_processed;
|
||||
if (AudioInterface::IsAISPlaying())
|
||||
if (g_bStream)
|
||||
{
|
||||
samples_processed = ProcessDTKSamples(tempPCM, NUM_SAMPLES);
|
||||
}
|
||||
|
@ -314,29 +314,10 @@ void DTKStreamingCallback(u64 userdata, int cyclesLate)
|
|||
}
|
||||
soundStream->GetMixer()->PushStreamingSamples(tempPCM, samples_processed);
|
||||
|
||||
// If we reached the end of the audio, stop.
|
||||
if (!g_bStream)
|
||||
return;
|
||||
|
||||
int ticks_to_dtk = int(SystemTimers::GetTicksPerSecond() * u64(samples_processed) / 48000);
|
||||
CoreTiming::ScheduleEvent(ticks_to_dtk - cyclesLate, dtk);
|
||||
}
|
||||
|
||||
void StartDTKStreaming()
|
||||
{
|
||||
// We wait 100ms before we actually start streaming to try to simulate
|
||||
// seek time. Not completely accurate, but better than starting the
|
||||
// stream instantly.
|
||||
g_bStream = true;
|
||||
CoreTiming::ScheduleEvent(SystemTimers::GetTicksPerSecond() / 10, dtk);
|
||||
}
|
||||
|
||||
void StopDTKStreaming()
|
||||
{
|
||||
g_bStream = false;
|
||||
CoreTiming::RemoveAllEvents(dtk);
|
||||
}
|
||||
|
||||
void Init()
|
||||
{
|
||||
m_DISR.Hex = 0;
|
||||
|
@ -364,6 +345,8 @@ void Init()
|
|||
|
||||
tc = CoreTiming::RegisterEvent("TransferComplete", TransferComplete);
|
||||
dtk = CoreTiming::RegisterEvent("StreamingTimer", DTKStreamingCallback);
|
||||
|
||||
CoreTiming::ScheduleEvent(0, dtk);
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
|
@ -955,11 +938,11 @@ void ExecuteCommand()
|
|||
CurrentStart = pos;
|
||||
CurrentLength = length;
|
||||
NGCADPCM::InitFilter();
|
||||
StartDTKStreaming();
|
||||
}
|
||||
|
||||
LoopStart = pos;
|
||||
LoopLength = length;
|
||||
g_bStream = (m_DICMDBUF[0].CMDBYTE1 == 0); // This command can start/stop the stream
|
||||
|
||||
// Stop stream
|
||||
if (m_DICMDBUF[0].CMDBYTE1 == 1)
|
||||
|
@ -969,8 +952,6 @@ void ExecuteCommand()
|
|||
LoopLength = 0;
|
||||
CurrentStart = 0;
|
||||
CurrentLength = 0;
|
||||
if (g_bStream)
|
||||
StopDTKStreaming();
|
||||
}
|
||||
|
||||
WARN_LOG(DVDINTERFACE, "(Audio) Stream subcmd = %08x offset = %08x length=%08x",
|
||||
|
@ -1020,11 +1001,13 @@ void ExecuteCommand()
|
|||
if (m_DICMDBUF[0].CMDBYTE1 == 1)
|
||||
{
|
||||
// TODO: What is this actually supposed to do?
|
||||
g_bStream = true;
|
||||
WARN_LOG(DVDINTERFACE, "(Audio): Audio enabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: What is this actually supposed to do?
|
||||
g_bStream = false;
|
||||
WARN_LOG(DVDINTERFACE, "(Audio): Audio disabled");
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -33,9 +33,7 @@ void ClearCoverInterrupt();
|
|||
|
||||
// DVD Access Functions
|
||||
bool DVDRead(u32 _iDVDOffset, u32 _iRamAddress, u32 _iLength);
|
||||
// For AudioInterface
|
||||
bool DVDReadADPCM(u8* _pDestBuffer, u32 _iNumSamples);
|
||||
|
||||
extern bool g_bStream;
|
||||
|
||||
// Not sure about endianness here. I'll just name them like this...
|
||||
enum DIErrorLow
|
||||
|
|
Loading…
Reference in New Issue