Fix race condition when switching DSP tracks

This commit is contained in:
Jack Andersen 2017-01-18 16:29:49 -10:00
parent 3cc93ffd75
commit d17557398f
2 changed files with 6 additions and 8 deletions

View File

@ -85,19 +85,19 @@ struct SDSPStream : boo::IAudioVoiceCallback
if (remFileBytes < halfSize) if (remFileBytes < halfSize)
{ {
printf("Buffering %d from %d into %d\n", remFileBytes, xcc_fileCur + x10_info.x8_headerSize, buf); //printf("Buffering %d from %d into %d\n", remFileBytes, xcc_fileCur + x10_info.x8_headerSize, buf);
m_file->AsyncSeekRead(data, remFileBytes, m_file->AsyncSeekRead(data, remFileBytes,
ESeekOrigin::Begin, xcc_fileCur + x10_info.x8_headerSize); ESeekOrigin::Begin, xcc_fileCur + x10_info.x8_headerSize);
xcc_fileCur = x10_info.x14_loopStartByte; xcc_fileCur = x10_info.x14_loopStartByte;
u32 remBytes = halfSize - remFileBytes; u32 remBytes = halfSize - remFileBytes;
printf("Loop Buffering %d from %d into %d\n", remBytes, xcc_fileCur + x10_info.x8_headerSize, buf); //printf("Loop Buffering %d from %d into %d\n", remBytes, xcc_fileCur + x10_info.x8_headerSize, buf);
m_readReqs[buf] = m_file->AsyncSeekRead(data + remFileBytes, remBytes, m_readReqs[buf] = m_file->AsyncSeekRead(data + remFileBytes, remBytes,
ESeekOrigin::Begin, xcc_fileCur + x10_info.x8_headerSize); ESeekOrigin::Begin, xcc_fileCur + x10_info.x8_headerSize);
xcc_fileCur += remBytes; xcc_fileCur += remBytes;
} }
else else
{ {
printf("Buffering %d from %d into %d\n", halfSize, xcc_fileCur + x10_info.x8_headerSize, buf); //printf("Buffering %d from %d into %d\n", halfSize, xcc_fileCur + x10_info.x8_headerSize, buf);
m_readReqs[buf] = m_file->AsyncSeekRead(data, halfSize, m_readReqs[buf] = m_file->AsyncSeekRead(data, halfSize,
ESeekOrigin::Begin, xcc_fileCur + x10_info.x8_headerSize); ESeekOrigin::Begin, xcc_fileCur + x10_info.x8_headerSize);
xcc_fileCur += halfSize; xcc_fileCur += halfSize;
@ -115,7 +115,7 @@ struct SDSPStream : boo::IAudioVoiceCallback
if (remFileBytes < halfSize) if (remFileBytes < halfSize)
{ {
printf("Buffering %d from %d into %d\n", remFileBytes, xcc_fileCur + x10_info.x8_headerSize, buf); //printf("Buffering %d from %d into %d\n", remFileBytes, xcc_fileCur + x10_info.x8_headerSize, buf);
m_readReqs[buf] = m_file->AsyncSeekRead(data, remFileBytes, m_readReqs[buf] = m_file->AsyncSeekRead(data, remFileBytes,
ESeekOrigin::Begin, xcc_fileCur + x10_info.x8_headerSize); ESeekOrigin::Begin, xcc_fileCur + x10_info.x8_headerSize);
memset(data + remFileBytes, 0, halfSize - remFileBytes); memset(data + remFileBytes, 0, halfSize - remFileBytes);
@ -123,7 +123,7 @@ struct SDSPStream : boo::IAudioVoiceCallback
} }
else else
{ {
printf("Buffering %d from %d into %d\n", halfSize, xcc_fileCur + x10_info.x8_headerSize, buf); //printf("Buffering %d from %d into %d\n", halfSize, xcc_fileCur + x10_info.x8_headerSize, buf);
m_readReqs[buf] = m_file->AsyncSeekRead(data, halfSize, m_readReqs[buf] = m_file->AsyncSeekRead(data, halfSize,
ESeekOrigin::Begin, xcc_fileCur + x10_info.x8_headerSize); ESeekOrigin::Begin, xcc_fileCur + x10_info.x8_headerSize);
xcc_fileCur += halfSize; xcc_fileCur += halfSize;
@ -213,7 +213,6 @@ struct SDSPStream : boo::IAudioVoiceCallback
if (xec_readState != 2 || (xe0_curBuffer == 0 && m_curSample >= xdc_ringSamples / 2)) if (xec_readState != 2 || (xe0_curBuffer == 0 && m_curSample >= xdc_ringSamples / 2))
{ {
printf("Should fill 0\n");
if (!BufferStream()) if (!BufferStream())
{ {
memset(data, 0, frames * 2); memset(data, 0, frames * 2);
@ -246,7 +245,6 @@ struct SDSPStream : boo::IAudioVoiceCallback
if (leftoverSamples) if (leftoverSamples)
{ {
printf("Should fill 1\n");
BufferStream(); BufferStream();
m_curSample = 0; m_curSample = 0;
decompressChunk(leftoverSamples, data); decompressChunk(leftoverSamples, data);
@ -346,6 +344,7 @@ struct SDSPStream : boo::IAudioVoiceCallback
float coefs[8] = {}; float coefs[8] = {};
m_booVoice->setMonoChannelLevels(nullptr, coefs, true); m_booVoice->setMonoChannelLevels(nullptr, coefs, true);
xe8_silent = true; xe8_silent = true;
x0_active = false;
} }
static void Silence(u32 id) static void Silence(u32 id)

View File

@ -162,7 +162,6 @@ bool CMain::Proc()
{ {
CGBASupport::GlobalPoll(); CGBASupport::GlobalPoll();
xe8_b24_finished = m_archSupport->Update(); xe8_b24_finished = m_archSupport->Update();
CStreamAudioManager::Start(false, "Audio/min_x_wind_lp_01L.dsp|Audio/min_x_wind_lp_01R.dsp", 0x7f, true, 0.f, 0.f);
CStreamAudioManager::Update(1.f / 60.f); CStreamAudioManager::Update(1.f / 60.f);
return xe8_b24_finished; return xe8_b24_finished;
} }