Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
772539a8
Commit
772539a8
authored
May 02, 2003
by
Robert Reif
Committed by
Alexandre Julliard
May 02, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move all tests to outside the loop when setting volume.
Add traces to functions.
parent
6ad96214
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
23 deletions
+77
-23
mixer.c
dlls/dsound/mixer.c
+57
-21
primary.c
dlls/dsound/primary.c
+20
-2
No files found.
dlls/dsound/mixer.c
View file @
772539a8
...
...
@@ -256,12 +256,14 @@ static INT DSOUND_MixerNorm(IDirectSoundBufferImpl *dsb, BYTE *buf, INT len)
static
void
DSOUND_MixerVol
(
IDirectSoundBufferImpl
*
dsb
,
BYTE
*
buf
,
INT
len
)
{
INT
i
,
inc
=
dsb
->
dsound
->
wfx
.
wBitsPerSample
>>
3
;
INT
i
;
BYTE
*
bpc
=
buf
;
INT16
*
bps
=
(
INT16
*
)
buf
;
TRACE
(
"(%p) left = %lx, right = %lx
\n
"
,
dsb
,
dsb
->
cvolpan
.
dwTotalLeftAmpFactor
,
dsb
->
cvolpan
.
dwTotalRightAmpFactor
);
TRACE
(
"(%p,%p,%d)
\n
"
,
dsb
,
buf
,
len
);
TRACE
(
"left = %lx, right = %lx
\n
"
,
dsb
->
cvolpan
.
dwTotalLeftAmpFactor
,
dsb
->
cvolpan
.
dwTotalRightAmpFactor
);
if
((
!
(
dsb
->
dsbd
.
dwFlags
&
DSBCAPS_CTRLPAN
)
||
(
dsb
->
cvolpan
.
lPan
==
0
))
&&
(
!
(
dsb
->
dsbd
.
dwFlags
&
DSBCAPS_CTRLVOLUME
)
||
(
dsb
->
cvolpan
.
lVolume
==
0
))
&&
!
(
dsb
->
dsbd
.
dwFlags
&
DSBCAPS_CTRL3D
))
...
...
@@ -271,30 +273,60 @@ static void DSOUND_MixerVol(IDirectSoundBufferImpl *dsb, BYTE *buf, INT len)
/* with a mono primary buffer, it could sound very weird using */
/* this method. Oh well, tough patooties. */
for
(
i
=
0
;
i
<
len
;
i
+=
inc
)
{
INT
val
;
switch
(
inc
)
{
switch
(
dsb
->
dsound
->
wfx
.
wBitsPerSample
)
{
case
8
:
/* 8-bit WAV is unsigned, but we need to operate */
/* on signed data for this to work properly */
switch
(
dsb
->
dsound
->
wfx
.
nChannels
)
{
case
1
:
/* 8-bit WAV is unsigned, but we need to operate */
/* on signed data for this to work properly */
val
=
*
bpc
-
128
;
val
=
((
val
*
(
i
&
inc
?
dsb
->
cvolpan
.
dwTotalRightAmpFactor
:
dsb
->
cvolpan
.
dwTotalLeftAmpFactor
))
>>
16
)
;
*
bpc
=
val
+
128
;
bpc
++
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
INT
val
=
*
bpc
-
128
;
val
=
(
val
*
dsb
->
cvolpan
.
dwTotalLeftAmpFactor
)
>>
16
;
*
bpc
=
val
+
128
;
bpc
++
;
}
break
;
case
2
:
/* 16-bit WAV is signed -- much better */
val
=
*
bps
;
val
=
((
val
*
((
i
&
inc
)
?
dsb
->
cvolpan
.
dwTotalRightAmpFactor
:
dsb
->
cvolpan
.
dwTotalLeftAmpFactor
))
>>
16
);
*
bps
=
val
;
bps
++
;
for
(
i
=
0
;
i
<
len
;
i
+=
2
)
{
INT
val
=
*
bpc
-
128
;
val
=
(
val
*
dsb
->
cvolpan
.
dwTotalLeftAmpFactor
)
>>
16
;
*
bpc
++
=
val
+
128
;
val
=
*
bpc
-
128
;
val
=
(
val
*
dsb
->
cvolpan
.
dwTotalRightAmpFactor
)
>>
16
;
*
bpc
=
val
+
128
;
bpc
++
;
}
break
;
default:
/* Very ugly! */
FIXME
(
"MixerVol had a nasty error
\n
"
)
;
FIXME
(
"doesn't support %d channels
\n
"
,
dsb
->
dsound
->
wfx
.
nChannels
);
break
;
}
break
;
case
16
:
/* 16-bit WAV is signed -- much better */
switch
(
dsb
->
dsound
->
wfx
.
nChannels
)
{
case
1
:
for
(
i
=
0
;
i
<
len
;
i
+=
2
)
{
*
bps
=
(
*
bps
*
dsb
->
cvolpan
.
dwTotalLeftAmpFactor
)
>>
16
;
bps
++
;
}
break
;
case
2
:
for
(
i
=
0
;
i
<
len
;
i
+=
4
)
{
*
bps
=
(
*
bps
*
dsb
->
cvolpan
.
dwTotalLeftAmpFactor
)
>>
16
;
bps
++
;
*
bps
=
(
*
bps
*
dsb
->
cvolpan
.
dwTotalRightAmpFactor
)
>>
16
;
bps
++
;
}
break
;
default:
FIXME
(
"doesn't support %d channels
\n
"
,
dsb
->
dsound
->
wfx
.
nChannels
);
break
;
}
break
;
default:
FIXME
(
"doesn't support %d bit samples
\n
"
,
dsb
->
dsound
->
wfx
.
wBitsPerSample
);
break
;
}
}
...
...
@@ -321,6 +353,8 @@ static DWORD DSOUND_MixInBuffer(IDirectSoundBufferImpl *dsb, DWORD writepos, DWO
BYTE
*
buf
,
*
ibuf
,
*
obuf
;
INT16
*
ibufs
,
*
obufs
;
TRACE
(
"%p,%ld,%ld)
\n
"
,
dsb
,
writepos
,
fraglen
);
len
=
fraglen
;
if
(
!
(
dsb
->
playflags
&
DSBPLAY_LOOPING
))
{
temp
=
MulDiv
(
dsb
->
dsound
->
wfx
.
nAvgBytesPerSec
,
dsb
->
buflen
,
...
...
@@ -808,6 +842,8 @@ void DSOUND_PerformMix(void)
BOOL
forced
;
HRESULT
hres
;
TRACE
(
"()
\n
"
);
RtlAcquireResourceShared
(
&
(
dsound
->
lock
),
TRUE
);
if
(
!
dsound
||
!
dsound
->
ref
)
{
...
...
dlls/dsound/primary.c
View file @
772539a8
...
...
@@ -50,6 +50,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dsound);
void
DSOUND_RecalcPrimary
(
IDirectSoundImpl
*
This
)
{
DWORD
sw
;
TRACE
(
"(%p)
\n
"
,
This
);
sw
=
This
->
wfx
.
nChannels
*
(
This
->
wfx
.
wBitsPerSample
/
8
);
if
(
This
->
hwbuf
)
{
...
...
@@ -69,6 +70,7 @@ void DSOUND_RecalcPrimary(IDirectSoundImpl *This)
static
HRESULT
DSOUND_PrimaryOpen
(
IDirectSoundImpl
*
This
)
{
HRESULT
err
=
DS_OK
;
TRACE
(
"(%p)
\n
"
,
This
);
/* are we using waveOut stuff? */
if
(
!
This
->
hwbuf
)
{
...
...
@@ -129,6 +131,8 @@ static HRESULT DSOUND_PrimaryOpen(IDirectSoundImpl *This)
static
void
DSOUND_PrimaryClose
(
IDirectSoundImpl
*
This
)
{
TRACE
(
"(%p)
\n
"
,
This
);
/* are we using waveOut stuff? */
if
(
!
This
->
hwbuf
)
{
unsigned
c
;
...
...
@@ -144,6 +148,7 @@ static void DSOUND_PrimaryClose(IDirectSoundImpl *This)
HRESULT
DSOUND_PrimaryCreate
(
IDirectSoundImpl
*
This
)
{
HRESULT
err
=
DS_OK
;
TRACE
(
"(%p)
\n
"
,
This
);
This
->
buflen
=
This
->
wfx
.
nAvgBytesPerSec
;
...
...
@@ -182,6 +187,8 @@ HRESULT DSOUND_PrimaryCreate(IDirectSoundImpl *This)
HRESULT
DSOUND_PrimaryDestroy
(
IDirectSoundImpl
*
This
)
{
TRACE
(
"(%p)
\n
"
,
This
);
DSOUND_PrimaryClose
(
This
);
if
(
This
->
hwbuf
)
{
if
(
IDsDriverBuffer_Release
(
This
->
hwbuf
)
==
0
)
...
...
@@ -198,6 +205,8 @@ HRESULT DSOUND_PrimaryDestroy(IDirectSoundImpl *This)
HRESULT
DSOUND_PrimaryPlay
(
IDirectSoundImpl
*
This
)
{
HRESULT
err
=
DS_OK
;
TRACE
(
"(%p)
\n
"
,
This
);
if
(
This
->
hwbuf
)
err
=
IDsDriverBuffer_Play
(
This
->
hwbuf
,
0
,
0
,
DSBPLAY_LOOPING
);
else
...
...
@@ -208,8 +217,7 @@ HRESULT DSOUND_PrimaryPlay(IDirectSoundImpl *This)
HRESULT
DSOUND_PrimaryStop
(
IDirectSoundImpl
*
This
)
{
HRESULT
err
=
DS_OK
;
TRACE
(
"
\n
"
);
TRACE
(
"(%p)
\n
"
,
This
);
if
(
This
->
hwbuf
)
{
err
=
IDsDriverBuffer_Stop
(
This
->
hwbuf
);
...
...
@@ -239,6 +247,8 @@ HRESULT DSOUND_PrimaryStop(IDirectSoundImpl *This)
HRESULT
DSOUND_PrimaryGetPosition
(
IDirectSoundImpl
*
This
,
LPDWORD
playpos
,
LPDWORD
writepos
)
{
TRACE
(
"(%p,%p,%p)
\n
"
,
This
,
playpos
,
writepos
);
if
(
This
->
hwbuf
)
{
HRESULT
err
=
IDsDriverBuffer_GetPosition
(
This
->
hwbuf
,
playpos
,
writepos
);
if
(
err
)
return
err
;
...
...
@@ -277,6 +287,7 @@ static HRESULT WINAPI PrimaryBufferImpl_SetFormat(
IDirectSoundBufferImpl
**
dsb
;
HRESULT
err
=
DS_OK
;
int
i
;
TRACE
(
"(%p,%p)
\n
"
,
This
,
wfex
);
if
(
This
->
dsound
->
priolevel
==
DSSCL_NORMAL
)
{
TRACE
(
"failed priority check!
\n
"
);
...
...
@@ -874,6 +885,8 @@ HRESULT WINAPI PrimaryBuffer_Create(
{
PrimaryBufferImpl
*
dsb
;
TRACE
(
"%p,%p,%p)
\n
"
,
This
,
pdsb
,
dsbd
);
if
(
dsbd
->
lpwfxFormat
)
return
DSERR_INVALIDPARAM
;
...
...
@@ -885,6 +898,11 @@ HRESULT WINAPI PrimaryBuffer_Create(
memcpy
(
&
dsb
->
dsbd
,
dsbd
,
sizeof
(
*
dsbd
));
TRACE
(
"Created primary buffer at %p
\n
"
,
dsb
);
TRACE
(
"(formattag=0x%04x,chans=%d,samplerate=%ld,"
"bytespersec=%ld,blockalign=%d,bitspersamp=%d,cbSize=%d)
\n
"
,
This
->
wfx
.
wFormatTag
,
This
->
wfx
.
nChannels
,
This
->
wfx
.
nSamplesPerSec
,
This
->
wfx
.
nAvgBytesPerSec
,
This
->
wfx
.
nBlockAlign
,
This
->
wfx
.
wBitsPerSample
,
This
->
wfx
.
cbSize
);
if
(
dsbd
->
dwFlags
&
DSBCAPS_CTRL3D
)
{
/* FIXME: IDirectSound3DListener */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment