Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSound: use DSound notifications to produce sound. #256

Merged
merged 1 commit into from May 24, 2014

Conversation

magumagu
Copy link
Contributor

@magumagu magumagu commented Apr 9, 2014

Pretty straightforward; IDirectSoundNotify lets you register for
notifications after a certain amount of sound has played, so use that
instead of depending on Update() notifications from the CPU thread.

Also, while I'm here, reduce the buffer size by a factor of 4; this seems
to reduce the latency, although the difference is sort of subtle.

Pretty straightforward; IDirectSoundNotify lets you register for
notifications after a certain amount of sound has played, so use that
instead of depending on Update() notifications from the CPU thread.

Also, while I'm here, reduce the buffer size by a factor of 4; this seems
to reduce the latency, although the difference is sort of subtle.
@shuffle2
Copy link
Contributor

The IDirectSoundNotify concept LGTM.
However, BUFSIZE(0x2000) is not evenly divisible by 3, will that be a problem, or is the last interval being longer OK?
I'm not sure how lower BUFSIZE affects people on faster/slower hardware; are we protected from under/overflow?

@magumagu
Copy link
Contributor Author

It doesn't really matter whether the intervals are precisely the same size; we just fill the buffer every time the notification triggers.

The DSound buffer is circular, and we always just fill the buffer, so overflow is fundamentally impossible. If we don't fill the buffer in time, the sound will get interrupted... but that's unlikely to happen very often even with a weak CPU. The OS scheduler should give the sound thread enough CPU time because it's sleeping most of its time. (Dolphin's Mixer class has its own independent buffer which can overflow and underflow... but it handles all of that internally, so it isn't really relevant here.)

shuffle2 added a commit that referenced this pull request May 24, 2014
DSound: use DSound notifications to produce sound.
@shuffle2 shuffle2 merged commit ca30029 into dolphin-emu:master May 24, 2014
@magumagu magumagu deleted the dsound-notify branch May 26, 2014 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants