Fixed the erroneous looping in audio streaming games like Eternal Darkness and Zoids: Battle Legends. Thanks for the tip, tueidj.
Fixes issue 5378.
This commit is contained in:
parent
0fc390b552
commit
7038a841bd
|
@ -203,7 +203,9 @@ static UDICFG m_DICFG;
|
||||||
|
|
||||||
static u32 AudioStart;
|
static u32 AudioStart;
|
||||||
static u32 AudioPos;
|
static u32 AudioPos;
|
||||||
|
static u32 CurrentStart;
|
||||||
static u32 AudioLength;
|
static u32 AudioLength;
|
||||||
|
static u32 CurrentLength;
|
||||||
|
|
||||||
u32 g_ErrorCode = 0;
|
u32 g_ErrorCode = 0;
|
||||||
bool g_bDiscInside = false;
|
bool g_bDiscInside = false;
|
||||||
|
@ -351,33 +353,46 @@ bool DVDRead(u32 _iDVDOffset, u32 _iRamAddress, u32 _iLength)
|
||||||
|
|
||||||
bool DVDReadADPCM(u8* _pDestBuffer, u32 _iNumSamples)
|
bool DVDReadADPCM(u8* _pDestBuffer, u32 _iNumSamples)
|
||||||
{
|
{
|
||||||
|
_iNumSamples &= ~31;
|
||||||
|
|
||||||
if (AudioPos == 0)
|
if (AudioPos == 0)
|
||||||
{
|
{
|
||||||
//MessageBox(0,"DVD: Trying to stream from 0", "bah", 0);
|
|
||||||
memset(_pDestBuffer, 0, _iNumSamples); // probably __AI_SRC_INIT :P
|
memset(_pDestBuffer, 0, _iNumSamples); // probably __AI_SRC_INIT :P
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
_iNumSamples &= ~31;
|
else
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lk(dvdread_section);
|
std::lock_guard<std::mutex> lk(dvdread_section);
|
||||||
VolumeHandler::ReadToPtr(_pDestBuffer, AudioPos, _iNumSamples);
|
VolumeHandler::ReadToPtr(_pDestBuffer, AudioPos, _iNumSamples);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// FIX THIS
|
|
||||||
//
|
|
||||||
// loop check
|
// loop check
|
||||||
//
|
if (g_bStream)
|
||||||
AudioPos += _iNumSamples;
|
|
||||||
if (AudioPos >= AudioStart + AudioLength)
|
|
||||||
{
|
{
|
||||||
g_bStream = false; // Starfox Adventures
|
AudioPos += _iNumSamples;
|
||||||
AudioPos = AudioStart;
|
|
||||||
NGCADPCM::InitFilter();
|
|
||||||
}
|
|
||||||
|
|
||||||
//WARN_LOG(DVDINTERFACE,"ReadADPCM");
|
if (AudioPos >= CurrentStart + CurrentLength)
|
||||||
return true;
|
{
|
||||||
|
if (AudioStart == 0 || AudioLength == 0)
|
||||||
|
{
|
||||||
|
AudioPos = 0;
|
||||||
|
CurrentStart = 0;
|
||||||
|
CurrentLength = 0;
|
||||||
|
g_bStream = false; // Starfox Adventures
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AudioPos = AudioStart;
|
||||||
|
CurrentStart = AudioStart;
|
||||||
|
CurrentLength = AudioLength;
|
||||||
|
NGCADPCM::InitFilter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//WARN_LOG(DVDINTERFACE,"ReadADPCM");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Read32(u32& _uReturnValue, const u32 _iAddress)
|
void Read32(u32& _uReturnValue, const u32 _iAddress)
|
||||||
|
@ -813,21 +828,20 @@ void ExecuteCommand(UDICR& _DICR)
|
||||||
// m_DICMDBUF[2].Hex = Length of the stream
|
// m_DICMDBUF[2].Hex = Length of the stream
|
||||||
case 0xE1:
|
case 0xE1:
|
||||||
{
|
{
|
||||||
// ugly hack to catch the disable command
|
if (!g_bStream)
|
||||||
if (m_DICMDBUF[1].Hex != 0)
|
|
||||||
{
|
{
|
||||||
AudioPos = m_DICMDBUF[1].Hex << 2;
|
AudioPos = m_DICMDBUF[1].Hex << 2;
|
||||||
AudioStart = AudioPos;
|
CurrentStart = AudioPos;
|
||||||
AudioLength = m_DICMDBUF[2].Hex;
|
CurrentLength = m_DICMDBUF[2].Hex;
|
||||||
NGCADPCM::InitFilter();
|
NGCADPCM::InitFilter();
|
||||||
|
|
||||||
g_bStream = true;
|
g_bStream = true;
|
||||||
|
|
||||||
WARN_LOG(DVDINTERFACE, "(Audio) Stream subcmd = %02x offset = %08x length=%08x",
|
|
||||||
m_DICMDBUF[0].CMDBYTE1, AudioPos, AudioLength);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
WARN_LOG(DVDINTERFACE, "(Audio) Off?");
|
AudioStart = m_DICMDBUF[1].Hex << 2;
|
||||||
|
AudioLength = m_DICMDBUF[2].Hex;
|
||||||
|
|
||||||
|
WARN_LOG(DVDINTERFACE, "(Audio) Stream subcmd = %02x offset = %08x length=%08x",
|
||||||
|
m_DICMDBUF[0].CMDBYTE1, AudioPos, AudioLength);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue