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>
(cherry picked from commit fc84b8675a)
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
oldstable
Nikola Pavlica 2019-04-23 20:04:23 +02:00 committed by Michael Stefaniuc
parent 6c105094e4
commit 43f2cc6372
3 changed files with 54 additions and 0 deletions

View File

@ -251,6 +251,53 @@ void put_surround512stereo(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD c
}
}
void put_surround712stereo(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel, float value)
{
/* based on analyzing a recording of a dsound downmix */
switch(channel){
case 6: /* back left */
value *= 0.24f;
dsb->put_aux(dsb, pos, 0, value);
break;
case 4: /* surround left */
value *= 0.24f;
dsb->put_aux(dsb, pos, 0, value);
break;
case 0: /* front left */
value *= 1.0f;
dsb->put_aux(dsb, pos, 0, value);
break;
case 7: /* back right */
value *= 0.24f;
dsb->put_aux(dsb, pos, 1, value);
break;
case 5: /* surround right */
value *= 0.24f;
dsb->put_aux(dsb, pos, 1, value);
break;
case 1: /* front right */
value *= 1.0f;
dsb->put_aux(dsb, pos, 1, value);
break;
case 2: /* centre */
value *= 0.7;
dsb->put_aux(dsb, pos, 0, value);
dsb->put_aux(dsb, pos, 1, value);
break;
case 3:
/* LFE is totally ignored in dsound when downmixing to 2 channels */
break;
}
}
void put_quad2stereo(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel, float value)
{
/* based on pulseaudio's downmix algorithm */

View File

@ -179,6 +179,7 @@ void put_stereo2quad(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel
void put_mono2surround51(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel, float value) DECLSPEC_HIDDEN;
void put_stereo2surround51(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel, float value) DECLSPEC_HIDDEN;
void put_surround512stereo(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel, float value) DECLSPEC_HIDDEN;
void put_surround712stereo(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel, float value) DECLSPEC_HIDDEN;
void put_quad2stereo(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel, float value) DECLSPEC_HIDDEN;
HRESULT secondarybuffer_create(DirectSoundDevice *device, const DSBUFFERDESC *dsbd,

View File

@ -179,6 +179,12 @@ void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb)
dsb->put = put_surround512stereo;
dsb->put_aux = putieee32_sum;
}
else if (ichannels == 8 && ochannels == 2)
{
dsb->mix_channels = 8;
dsb->put = put_surround712stereo;
dsb->put_aux = putieee32_sum;
}
else if (ichannels == 4 && ochannels == 2)
{
dsb->mix_channels = 4;