Rewrite some code for ease of reading
This commit is contained in:
parent
b1d3549723
commit
5448068426
1 changed files with 7 additions and 10 deletions
|
@ -34,25 +34,22 @@ static inline void soundWait() {
|
|||
audio_info_t audioInfo;
|
||||
ioctl(sndfp, AUDIO_GETINFO, &audioInfo);
|
||||
int playedBefore = audioInfo.play.samples;
|
||||
int playedNow = audioInfo.play.samples;
|
||||
while(playedNow - playedBefore < samplesPerGo) {
|
||||
while(audioInfo.play.samples - playedBefore < samplesPerGo) {
|
||||
Backend_Delay(10);
|
||||
ioctl(sndfp, AUDIO_GETINFO, &audioInfo);
|
||||
playedNow = audioInfo.play.samples;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void feedOutSound(long* mix) {
|
||||
for(int i = 0; i < samplesPerGo * 2; i++) {
|
||||
short sample = mix[i];
|
||||
if(mix[i] > 0x7FFF) {
|
||||
sample = 0x7FFF;
|
||||
mix[i] = 0x7FFF;
|
||||
}
|
||||
if(mix[i] < -0x7FFF) {
|
||||
sample = -0x7FFF;
|
||||
else if(mix[i] < -0x7FFF) {
|
||||
mix[i] = -0x7FFF;
|
||||
}
|
||||
fputc((sample >> 8) & 0xFF, sndfile);
|
||||
fputc(sample & 0xFF, sndfile);
|
||||
fputc((mix[i] >> 8) & 0xFF, sndfile);
|
||||
fputc(mix[i] & 0xFF, sndfile);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue