Commit Graph

169 Commits

Author SHA1 Message Date
Florian Will 835dfaab02 dsound: Skip resampling/mixing inaudible buffers.
In some situations, "ZUSI 3" has a lot of secondary buffers in the
PLAYING state, but most of these buffers have a really low volume, so
these buffers are multiplied by 0 before mixing (and possibly after
resampling). There can be hundreds of inaudible buffers at the same
time.

In these situations, the dsound mixthread is unable to mix fast enough,
resulting in sound stuttering and generally poor performance.

To resolve this performance issue, skip the mixing (and possibly
resampling) step for all inaudible secondary buffers.

Signed-off-by: Florian Will <florian.will@gmail.com>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-06 22:55:07 +01:00
Eduard Permyakov 975d0632a1 dsound: Commit next audio chunk between play cursor and write cursor to playing.
This region of the audio buffer is forbidden to be written to by the
DirectSound specification. The documentation states: "The write cursor
is the point after which it is safe to write data into the buffer. The
block between the play cursor and the write cursor is already committed
to be played, and cannot be changed safely." However, some applications
still do this, which has lead to audio glitches only when using the Wine
DirectSound implementation. Experiments showed that the native DirctSound
implementation will still play the old audio the first time around when the
buffer region gets overwritten. Use an approach of copying the next forbidden
region into a "committed buffer" to add the same behavior to the Wine
implementation.

Out of performance considerations, only copy data to the committed buffer
when we detect that an overwrite is possible (i.e. the current mixing
region of the buffer gets locked).

Signed-off-by: Eduard Permyakov <epermyakov@codeweavers.com>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-20 22:48:41 +02:00
Zebediah Figura e091903999 dsound: Use an SRW lock for the buffer lock.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-02-03 20:48:04 +01:00
Zebediah Figura 1308700843 dsound: Use an SRW lock for buffer_list_lock.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48408
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-02-03 20:48:04 +01:00
Michael Cronenworth fba65a1537 dsound: Global variable compatibility update for gcc 10.
Signed-off-by: Michael Cronenworth <mike@cchtml.com>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-01-24 18:13:58 +01:00
Alexandre Julliard 3e80b93f90 dsound: Build with msvcrt.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-06-03 10:34:35 +02:00
Nikola Pavlica fc84b8675a dsound: Added 7.1 to stereo downmix.
Signed-off-by: Nikola Pavlica <pavlica.nikola@gmail.com>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-04-25 17:28:11 +02:00
Jacek Caban e8fd1c73b2 dsound: Wait on thread handle instead of dedicated event in DirectSoundDevice_Release.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-11-26 18:52:44 +01:00
Dmitry Timoshkov c39121fc97 dsound: Fix a memory leak.
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-06-22 22:52:08 +02:00
Huw Davies 134b684fd9 dsound: Use frame rather than byte counts to clarify the mixing.
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-03-01 23:35:40 +01:00
Andrew Eikum 1def346bab dsound: Support downmixing quadraphonic to stereo.
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-19 23:42:06 +09:00
Andrew Eikum 88dd3b4f6e dsound: Support downmixing 5.1 to stereo.
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-19 23:42:02 +09:00
Maarten Lankhorst db316c1243 dsound: Remove unconditional memory allocation in mixing thread.
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-18 10:36:56 +09:00
Maarten Lankhorst 5b0914ece9 dsound: Remove state machine from render buffer.
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-18 10:36:54 +09:00
Maarten Lankhorst 2fb97be187 dsound: Prevent reopening device from leaving dsound object in invalid state.
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-18 10:36:52 +09:00
Sebastian Lackner 65bab6a5fe dsound: Get rid of no longer needed mix_buffer_len field.
This was missing in 09890d7142.

Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-16 22:59:11 +09:00
Maarten Lankhorst 09890d7142 dsound: Mix float natively.
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-14 14:39:52 +09:00
Maarten Lankhorst 95287ac2df dsound: Use AudioClient for position.
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-14 14:39:52 +09:00
Maarten Lankhorst 569ed159b0 dsound: Use AudioClient buffer statistics.
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-14 14:39:52 +09:00
Michael Stefaniuc bb72548f38 dsound: Use a better name for IDirectSoundBufferImpl_Create().
Signed-off-by: Michael Stefaniuc <mstefani@redhat.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2015-12-22 13:50:45 +01:00
Aric Stewart 0aea30e44c dsound: Do not wait on mixer thread exit on dsound release.
This fixes a loader deadlock if the dsound object is being released
during a dll unload.
2015-03-18 19:35:43 +09:00
Mark Harmstone 17056b9f30 dsound: Implement SetFX. 2015-03-10 23:53:40 +09:00
Mark Harmstone e6ae73359f dsound: Keep track of locked bytes. 2015-03-10 23:53:17 +09:00
Francois Gouget dfaef5306f dsound: Reorder the interfaces to remove the need for forward declarations. 2015-01-20 11:12:01 +01:00
Francois Gouget 82c298ee6e dsound: Make DSOUND_FindSpeakerConfig() static. 2015-01-20 11:11:52 +01:00
Mark Harmstone b5aec2e40f dsound: Degrade speaker config if too many channels. 2015-01-13 17:51:38 +01:00
Mark Harmstone 77b2ab21f4 dsound: Support 5.1 sound. 2015-01-09 17:37:50 +01:00
Mark Harmstone 3ba100d81c dsound: Support quadraphonic sound. 2015-01-09 17:37:48 +01:00
Mark Harmstone c4e3079766 dsound: Parse speaker config. 2015-01-07 23:48:26 +01:00
Marton Balint 6d009b988b dsound: Convert freqAdjust and freqAcc to integers.
Fixes resampling errors caused by truncating floating point numbers.
2014-12-29 22:20:30 +01:00
Mark Harmstone 25b13178de dsound: Use array for channel volumes. 2014-12-29 12:15:50 +01:00
Mark Harmstone b7a2f0879c dsound: Remove unused struct entries. 2014-12-29 12:14:56 +01:00
Andrew Eikum d5e648dc2f dsound: For capture, use MMDevAPI event API instead of timers. 2013-08-21 19:55:59 +02:00
Maarten Lankhorst f5abeb8471 dsound: Use a thread instead of a timer for greater precision. 2012-12-27 18:47:53 +01:00
Maarten Lankhorst 605cd62c7d dsound: Create a primary_pwfx separately from pwfx. 2012-11-22 14:53:14 +01:00
Michael Stefaniuc cea6329483 dsound: DirectSoundDevice_RemoveBuffer() cannot fail. 2012-09-26 10:58:48 +02:00
Michael Stefaniuc 1440b25267 dsound: Inline some of the IDirectSound helpers. 2012-09-06 15:45:31 +02:00
Michael Stefaniuc ebf33fff47 dsound: Move the capture structs declarations to the .c file. 2012-08-31 09:54:47 +02:00
Michael Stefaniuc 1555aebf1e dsound: Cleanup IKsPrivatePropertySetImpl_Create(). 2012-08-24 10:25:58 +02:00
Francois Gouget e2c50d762c dsound: Make dumpCooperativeLevel() static. 2012-08-21 17:47:47 +02:00
Michael Stefaniuc 850b294efa dsound: Add COM aggregation to DirectSoundCapture for internal use. 2012-08-16 11:39:49 +02:00
Michael Stefaniuc 9cb53818e8 dsound: Add COM aggregation to DirectSound for internal use. 2012-08-16 11:39:36 +02:00
Michael Stefaniuc 885e205ade dsound: Cleanup the DirectSoundFullDuplex create functions. 2012-08-16 11:38:44 +02:00
Michael Stefaniuc 9383affe87 dsound: IDirectSoundCapture / IUnknown use separate refcounts. 2012-08-16 11:38:17 +02:00
Michael Stefaniuc b8ffb4930f dsound: Merge the DirectSoundCapture create functions. 2012-08-16 11:38:08 +02:00
Michael Stefaniuc 9cc62d321c dsound: Handle IDirectSound by the IDirectSound8 implementation. 2012-07-19 16:01:48 +02:00
Michael Stefaniuc 6fecd3d642 dsound: Merge IDirectSound8 into the main DirectSound object. 2012-07-19 16:01:47 +02:00
Michael Stefaniuc bf4481d3f0 dsound: Merge the DirectSound create functions. 2012-07-19 16:01:46 +02:00
Michael Stefaniuc 8978a4b51b dsound: Merge IUnknown into the main DirectSound object. 2012-07-19 16:01:45 +02:00
Michael Stefaniuc 4992e6a515 dsound: Merge the two IUnknown/IDirectSound implementations for DirectSound. 2012-07-19 16:01:43 +02:00