forked from Ports/goldeneye-pc-port
GE's amMain feedback loop (src/audi.c:531) has a ~3 ms setpoint that PC scheduling jitter clears, so the SDL queue starves and the device pads playback with silence -> audio runs permanently ~2 % below real time. - F5 (the fix): audioGetAiLengthBytes() subtracts a 1024-frame (~46 ms) cushion before reporting, so the loop tops up while slack remains; audi.c's control law untouched (rule #2 clean). - F1: osAiGetLength reports AI_LEN_REG single-buffer semantics (bytes left in the buffer currently playing), not full SDL queue depth. - F3: Audio.QueueLimit 8192->2880 + non-silent drops on overflow. - F4: oversize-block invariant guard. - GE_D204=1 cheap audio-health monitor (rt/q/drop/max), safe to leave on; GE_D204_OLD restores pre-fix behaviour for A/B measurement. Measured A/B in one binary: rt 0.980 -> 1.000, queue min 0 -> 368, drop 0. Findings: docs/dev/findings.md D204.
39 lines
1.0 KiB
C
39 lines
1.0 KiB
C
#ifndef PORT_AUDIO_H
|
|
#define PORT_AUDIO_H
|
|
|
|
/*
|
|
* Audio: SDL audio device + buffer queueing.
|
|
* Modelled on the PD port's port/include/audio.h.
|
|
*
|
|
* libaudio (AL) runs on the CPU and produces mixed s16 stereo output. The AI
|
|
* (osAiSetNextBuffer / osAiGetLength / osAiSetFrequency) is mapped onto this
|
|
* layer, which queues the mixed samples to the SDL audio device.
|
|
*/
|
|
|
|
#include <PR/ultratypes.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Initialize the SDL audio device. Returns 0 on success. */
|
|
int audioInit(void);
|
|
void audioDestroy(void);
|
|
|
|
/* Number of samples (stereo s16 frames) currently queued. */
|
|
s32 audioGetSamplesBuffered(void);
|
|
|
|
/* D204/F1: emulate the N64 AI_LEN_REG -- bytes remaining in the buffer the
|
|
* DAC is *currently* playing, NOT the whole queue depth. src/audi.c does
|
|
* arithmetic on this value that only holds inside the N64's range. */
|
|
u32 audioGetAiLengthBytes(void);
|
|
|
|
/* Queue the next block of mixed samples (len is in bytes). */
|
|
void audioSetNextBuffer(const s16 *buf, u32 len);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* PORT_AUDIO_H */
|