Revert "Rewrite some code for ease of reading"

sorry, it got less readable now

This reverts commit 5448068426.
This commit is contained in:
John Lorentzson 2025-04-24 15:50:26 +02:00
parent 5448068426
commit a86f5df428

View file

@ -34,22 +34,25 @@ static inline void soundWait() {
audio_info_t audioInfo; audio_info_t audioInfo;
ioctl(sndfp, AUDIO_GETINFO, &audioInfo); ioctl(sndfp, AUDIO_GETINFO, &audioInfo);
int playedBefore = audioInfo.play.samples; int playedBefore = audioInfo.play.samples;
while(audioInfo.play.samples - playedBefore < samplesPerGo) { int playedNow = audioInfo.play.samples;
while(playedNow - playedBefore < samplesPerGo) {
Backend_Delay(10); Backend_Delay(10);
ioctl(sndfp, AUDIO_GETINFO, &audioInfo); ioctl(sndfp, AUDIO_GETINFO, &audioInfo);
playedNow = audioInfo.play.samples;
} }
} }
static inline void feedOutSound(long* mix) { static inline void feedOutSound(long* mix) {
for(int i = 0; i < samplesPerGo * 2; i++) { for(int i = 0; i < samplesPerGo * 2; i++) {
short sample = mix[i];
if(mix[i] > 0x7FFF) { if(mix[i] > 0x7FFF) {
mix[i] = 0x7FFF; sample = 0x7FFF;
} }
else if(mix[i] < -0x7FFF) { if(mix[i] < -0x7FFF) {
mix[i] = -0x7FFF; sample = -0x7FFF;
} }
fputc((mix[i] >> 8) & 0xFF, sndfile); fputc((sample >> 8) & 0xFF, sndfile);
fputc(mix[i] & 0xFF, sndfile); fputc(sample & 0xFF, sndfile);
} }
} }