[Audio] Code cleanup and slightly smaller buffer.

This commit is contained in:
Frank-74 2018-12-04 03:54:44 +00:00 committed by GitHub
parent 355be14ea3
commit 0e24ea1ca9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 21 deletions

View File

@ -85,14 +85,15 @@ EXPORT void CALL AiDacrateChanged(int SystemType)
WriteTrace(TraceAudioInterface, TraceNotice, "Unknown/reserved bits in AI_DACRATE_REG set. 0x%08X", *g_AudioInfo.AI_DACRATE_REG); WriteTrace(TraceAudioInterface, TraceNotice, "Unknown/reserved bits in AI_DACRATE_REG set. 0x%08X", *g_AudioInfo.AI_DACRATE_REG);
} }
uint32_t video_clock = 0; uint32_t video_clock = 0; int32_t BufferSize = 0; double audio_clock = 0; double framerate = 29.97;
switch (SystemType) switch (SystemType)
{ {
case SYSTEM_NTSC: video_clock = 48681812; break; case SYSTEM_NTSC: video_clock = 48681812; break;
case SYSTEM_PAL: video_clock = 49656530; break; case SYSTEM_PAL: video_clock = 49656530; framerate = 25; break;
case SYSTEM_MPAL: video_clock = 48628316; break; case SYSTEM_MPAL: video_clock = 48628316; break;
} }
uint32_t Frequency = video_clock / (g_Dacrate + 1); uint32_t Frequency = (video_clock / (g_Dacrate + 1));
if (Frequency < 4000) if (Frequency < 4000)
{ {
@ -101,28 +102,16 @@ EXPORT void CALL AiDacrateChanged(int SystemType)
} }
else else
{ {
int32_t BufferSize = 0; double audio_clock = 0; double framerate = 0; if (g_settings->FPSBuffer() == false && SystemType != SYSTEM_PAL)
if (g_settings->FPSBuffer() == true)
{ {
framerate = 59.94004; framerate = 30.475; // Needed for Body Harvest (U)
if (SystemType == SYSTEM_PAL) { framerate = 50; }
} }
else if (g_settings->TinyBuffer() == false)
{ {
framerate = 60.95; // Needed for Body Harvest (U) framerate = (framerate / 2);
if (SystemType == SYSTEM_PAL) { framerate = 50.79166; }
} }
if (g_settings->TinyBuffer() == true) audio_clock = (video_clock / framerate);
{ BufferSize = (int32_t)(audio_clock / (g_Dacrate + 1)) & ~0x1;
audio_clock = ((video_clock / framerate) * 2);
}
else
{
audio_clock = ((video_clock / framerate) * 4);
}
BufferSize = (int32_t)audio_clock / (g_Dacrate) + 1 & ~0x1;
g_SoundDriver->AI_SetFrequency(Frequency, BufferSize); g_SoundDriver->AI_SetFrequency(Frequency, BufferSize);
} }
} }