Assorted fixes -> works (module timing glitches).

This commit is contained in:
Christian Speckner 2018-01-25 22:48:00 +01:00
parent 8198f6ccaf
commit 4528b9067a
3 changed files with 11 additions and 9 deletions

View File

@ -24,6 +24,7 @@ using std::lock_guard;
AudioQueue::AudioQueue(uInt32 fragmentSize, uInt8 capacity, bool isStereo, uInt16 sampleRate)
: myFragmentSize(fragmentSize),
myIsStereo(isStereo),
mySampleRate(sampleRate),
myFragmentQueue(capacity),
myAllFragments(capacity + 2),
mySize(0),

View File

@ -45,7 +45,8 @@ SoundSDL2::SoundSDL2(OSystem& osystem)
// This fixes a bug most prevalent with ATI video cards in Windows,
// whereby sound stopped working after the first video change
SDL_AudioSpec desired;
desired.freq = myOSystem.settings().getInt("freq");
// desired.freq = myOSystem.settings().getInt("freq");
desired.freq = 48000;
desired.format = AUDIO_S16SYS;
desired.channels = 2;
desired.samples = myOSystem.settings().getInt("fragsize");
@ -213,17 +214,17 @@ void SoundSDL2::processFragment(Int16* stream, uInt32 length)
return;
}
bool isStereoTIA = myAudioQueue->isStereo();
bool isStereo = myHardwareSpec.channels == 2;
uInt32 sampleRateTIA = myAudioQueue->sampleRate();
uInt32 sampleRate = myHardwareSpec.freq;
uInt32 fragmentSize = myAudioQueue->fragmentSize();
uInt32 outputSamples = isStereo ? (length >> 1) : length;
const bool isStereoTIA = myAudioQueue->isStereo();
const bool isStereo = myHardwareSpec.channels == 2;
const uInt32 sampleRateTIA = myAudioQueue->sampleRate();
const uInt32 sampleRate = myHardwareSpec.freq;
const uInt32 fragmentSize = myAudioQueue->fragmentSize();
const uInt32 outputSamples = isStereo ? (length >> 1) : length;
for (uInt32 i = 0; i < outputSamples; i++) {
myTimeIndex += sampleRateTIA;
if (myTimeIndex > sampleRate) {
if (myTimeIndex >= sampleRate) {
myFragmentIndex += myTimeIndex / sampleRate;
myTimeIndex %= sampleRate;
}

View File

@ -139,5 +139,5 @@ void AudioChannel::audv(uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AudioChannel::audf(uInt8 value)
{
myAudc = value & 0x1f;
myAudf = value & 0x1f;
}