koitsu wrote:
I can assure you that in the future you will get hounded and scolded for this.
Perhaps. But you're the first since this functionality was introduced in 4/11
koitsu wrote:
If someone clever figures it out, they're going to go "what the hell is changing my power profile setting?!?!?!" Nobody is EVER going to consider that an emulator is the cause.
The temporary power scheme name is "nemulator" and the description is "Copy of %s scheme. Used by nemulator to disable processor throttling." I do have one change in the works though: if nemulator starts up and detects that the nemulator scheme is already in use, indicating an unclean shutdown, it will revert to the scheme that was in use before the previous scheme change.
koitsu wrote:
if existing emulators don't need to do this (I can list off quite a few), why does yours?
I'm unaware of any other emulator that simultaneously provides smooth video output (no tearing, no stuttering) and glitch-free audio. It's a differentiating feature of nemulator and one that I wish that you could try firsthand. I think it's a worthwhile trade-off.
koitsu wrote:
Can you explain, verbosely, why it is you need to disable these CPU features?
I'll try. To recap, emulators generate video and audio output at slightly different frequencies. To keep everything in sync, most emulators block on audio output, effectively locking the frame rate to the audio output rate. This results in glitch-free audio output, but tearing or stuttering video output.
Alternately, an emulator could lock to 60Hz vsync to provide artifact-free video output, but there will be audio glitches when the audio output buffer over-/under-runs.
To address this issue, nemulator uses vsync for timing (except when it doesn't, but that's a different discussion), and dynamically adjusts the audio frequency to match the current frame rate. Video is output at a consistent 60Hz, audio output is never blocked waiting on the output buffer to drain, and the audio buffer is never under-run.
In order to determine the difference in audio generation and playback rates, I check the playback and write cursor positions of the sound card's primary output buffer. If the distance between the two pointers is consistent -- the goal -- that means that the buffer is being drained at the same rate that it's being filled. If it's not, audio frequency is adjusted to compensate.
So, why does processor throttling interfere with this? When processor throttling is enabled, processor frequency -- and therefore the time between vsync occurring and the audio buffer being filled -- will vary depending on system load. Usually, this 'jitter' isn't too bad, and can be accounted for. But on occasion, there will be large differences that can result in under-runs. Here's an example. The red line represents the number of bytes between the playback and write cursors:
With processor throttling disabled, latency is much more consistent, and large differences generally don't occur:
There's a couple of ways to account for the increased jitter with throttling enabled. I can increase the buffer size, but that can result in noticeable latency between video and audio (e.g., you hear Mario jump later then it happens on-screen). I can make larger/faster adjustments to audio frequency, but that can result in noticeable pitch changes.
So, at the end of the day, temporarily disabling processor throttling provides the best results. I agree that there are downsides, but I think the benefits outweigh those.