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

Win32 refresh: audio drivers, priority changes #286

Open
wants to merge 3 commits into
base: beta
Choose a base branch
from

Conversation

sukibaby
Copy link
Contributor

@sukibaby sukibaby commented Jun 9, 2024

The main changes in this are: restructuring the thread priority and taking the heavy lifting off the audio driver, to improve consistency between different people's setups.

The thread priority restructuring follows this theory:

  1. Rendering thread, Audio mixing thread <- should run at Highest or Time Critical priority
  2. Audio decoding thread, audio streaming thread <- should run at Highest priority
  3. Main game thread <- should run at Normal or Above Normal priority
  4. Worker threads <- should run at Below Normal or Normal priority [worker threads were not changed in this PR]

arch/Sound/DSoundHelpers.cpp

  • Set the DirectSound buffer to 512KB instead of 64KB
  • General modernization

arch/Sound/RageSoundDriver_DSound_Software.cpp

  • Priority fixes

arch/Sound/RageSoundDriver_WaveOut.cpp

  • More buffers instead of larger buffers so that latency isn't affected
  • Priority fixes
  • General modernization

arch/Sound/RageSoundDriver_WDMKS.cpp

  • Allow the buffer size to adapt to the number of channels and maximum bytes per sample
  • Set one temporary buffer big enough to reuse multiple times instead of setting the buffer to ~2-4KB and reallocating it as needed
  • Keep track of the starting position of pBuf
  • Priority fixes

@sukibaby sukibaby force-pushed the win32refreshB branch 4 times, most recently from 3eb6811 to b7ba0d8 Compare June 9, 2024 14:43
Mostly buffer maintenance, style updates, and thread priority restructuring.

In WaveOut we are now using more buffers instead of larger buffers.

On the other hand in DirectSound the buffer is just made larger since it is usually handling decoding etc.
src/arch/Sound/DSoundHelpers.cpp Show resolved Hide resolved
if( m_iBufferBytesFilled >= m_iBufferSize )
return;
// Store the buffer size in a variable to avoid multiple calls
int storedSizeOfBuffer = m_iBufferSize;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems unnecessary. It doesn't look like we're changing it and also it's just a plain old data type so seems not required.

src/arch/Sound/DSoundHelpers.cpp Outdated Show resolved Hide resolved
src/arch/Sound/DSoundHelpers.h Outdated Show resolved Hide resolved
src/arch/Sound/RageSoundDriver_WDMKS.cpp Show resolved Hide resolved
**arch/Sound/DSoundHelpers.cpp**

* Set the DirectSound buffer to 512KB instead of 64KB

**arch/Sound/RageSoundDriver_DSound_Software.cpp**

* Priority fixes

**arch/Sound/RageSoundDriver_WaveOut.cpp**

* Priority fixes

**arch/Sound/RageSoundDriver_WDMKS.cpp**

* Allow the buffer size to adapt to the number of channels and maximum bytes per sample
* Set one temporary buffer big enough to reuse multiple times instead of setting the buffer to ~2-4KB and reallocating it as needed
* Keep track of the starting position of `pBuf`
* Priority fixes
* Win32_lean_and_mean
@sukibaby
Copy link
Contributor Author

Temporarily closing so this doesn't distract from more pressing PR's.

@sukibaby sukibaby closed this Jun 18, 2024
@sukibaby sukibaby reopened this Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants