Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
0195e019
Commit
0195e019
authored
Nov 07, 2011
by
Alexander E. Patrakov
Committed by
Alexandre Julliard
May 01, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dsound: Clean up MixToTemporary().
parent
74560c1d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
42 deletions
+19
-42
dsound_convert.c
dlls/dsound/dsound_convert.c
+1
-1
mixer.c
dlls/dsound/mixer.c
+18
-41
No files found.
dlls/dsound/dsound_convert.c
View file @
0195e019
...
...
@@ -66,8 +66,8 @@ static inline void src_advance(const void **src, UINT stride, INT *count, UINT *
ULONG
adv
=
(
*
freqAcc
>>
DSOUND_FREQSHIFT
);
*
freqAcc
&=
(
1
<<
DSOUND_FREQSHIFT
)
-
1
;
*
(
const
char
**
)
src
+=
adv
*
stride
;
*
count
-=
adv
;
}
*
count
-=
1
;
}
static
void
convert_8_to_8
(
const
void
*
src
,
void
*
dst
,
UINT
src_stride
,
...
...
dlls/dsound/mixer.c
View file @
0195e019
...
...
@@ -138,8 +138,6 @@ DWORD DSOUND_secpos_to_bufpos(const IDirectSoundBufferImpl *dsb, DWORD secpos, D
}
/** Convert a resampled pointer that fits for primary to a 'native' sample pointer
* freqAccNext is used here rather than freqAcc: In case the app wants to fill up to
* the play position it won't overwrite it
*/
static
DWORD
DSOUND_bufpos_to_secpos
(
const
IDirectSoundBufferImpl
*
dsb
,
DWORD
bufpos
)
{
...
...
@@ -148,12 +146,15 @@ static DWORD DSOUND_bufpos_to_secpos(const IDirectSoundBufferImpl *dsb, DWORD bu
DWORD64
acc
;
framelen
=
bufpos
/
oAdv
;
acc
=
framelen
*
(
DWORD64
)
dsb
->
freqAdjust
+
(
DWORD64
)
dsb
->
freqAcc
Next
;
acc
=
framelen
*
(
DWORD64
)
dsb
->
freqAdjust
+
(
DWORD64
)
dsb
->
freqAcc
;
acc
=
acc
>>
DSOUND_FREQSHIFT
;
pos
=
(
DWORD
)
acc
*
iAdv
;
if
(
pos
>=
dsb
->
buflen
)
/* Because of differences between freqAcc and freqAccNext, this might happen */
if
(
pos
>=
dsb
->
buflen
)
{
/* FIXME: can this happen at all? */
ERR
(
"pos >= dsb->buflen: %d >= %d, capping
\n
"
,
pos
,
dsb
->
buflen
);
pos
=
dsb
->
buflen
-
iAdv
;
}
TRACE
(
"Converted %d/%d to %d/%d
\n
"
,
bufpos
,
dsb
->
tmp_buffer_len
,
pos
,
dsb
->
buflen
);
return
pos
;
}
...
...
@@ -334,41 +335,32 @@ static inline DWORD DSOUND_BufPtrDiff(DWORD buflen, DWORD ptr1, DWORD ptr2)
*
* NOTE: writepos + len <= buflen. When called by mixer, MixOne makes sure of this.
*/
static
void
DSOUND_MixToTemporary
(
const
IDirectSoundBufferImpl
*
dsb
,
DWORD
writepos
,
DWORD
len
)
static
void
DSOUND_MixToTemporary
(
const
IDirectSoundBufferImpl
*
dsb
,
DWORD
tmp_
len
)
{
INT
size
;
BYTE
*
ibp
,
*
obp
,
*
obp_begin
;
BYTE
*
ibp
,
*
obp
;
INT
iAdvance
=
dsb
->
pwfx
->
nBlockAlign
;
INT
oAdvance
=
dsb
->
device
->
pwfx
->
nBlockAlign
;
DWORD
freqAcc
,
overshot
,
maxlen
;
assert
(
writepos
+
len
<=
dsb
->
buflen
);
if
(
writepos
+
len
<
dsb
->
buflen
)
len
+=
dsb
->
pwfx
->
nBlockAlign
;
DWORD
freqAcc
;
maxlen
=
DSOUND_secpos_to_bufpos
(
dsb
,
len
,
0
,
NULL
);
ibp
=
dsb
->
buffer
->
memory
+
writepos
;
if
(
dsb
->
device
->
tmp_buffer_len
<
maxlen
||
!
dsb
->
device
->
tmp_buffer
)
ibp
=
dsb
->
buffer
->
memory
+
dsb
->
sec_mixpos
;
if
(
dsb
->
device
->
tmp_buffer_len
<
tmp_len
||
!
dsb
->
device
->
tmp_buffer
)
{
dsb
->
device
->
tmp_buffer_len
=
max
len
;
dsb
->
device
->
tmp_buffer_len
=
tmp_
len
;
if
(
dsb
->
device
->
tmp_buffer
)
dsb
->
device
->
tmp_buffer
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
dsb
->
device
->
tmp_buffer
,
max
len
);
dsb
->
device
->
tmp_buffer
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
dsb
->
device
->
tmp_buffer
,
tmp_
len
);
else
dsb
->
device
->
tmp_buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
maxlen
);
obp_begin
=
dsb
->
device
->
tmp_buffer
;
dsb
->
device
->
tmp_buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
tmp_len
);
}
else
obp_begin
=
dsb
->
device
->
tmp_buffer
;
obp
=
dsb
->
device
->
tmp_buffer
;
TRACE
(
"(%p, %p)
\n
"
,
dsb
,
ibp
);
size
=
len
/
i
Advance
;
size
=
tmp_len
/
o
Advance
;
/* Check for same sample rate */
if
(
dsb
->
freq
==
dsb
->
device
->
pwfx
->
nSamplesPerSec
)
{
TRACE
(
"(%p) Same sample rate %d = primary %d
\n
"
,
dsb
,
dsb
->
freq
,
dsb
->
device
->
pwfx
->
nSamplesPerSec
);
obp
=
obp_begin
;
cp_fields
(
dsb
,
ibp
,
obp
,
iAdvance
,
oAdvance
,
size
,
0
,
1
<<
DSOUND_FREQSHIFT
);
return
;
...
...
@@ -377,22 +369,7 @@ static void DSOUND_MixToTemporary(const IDirectSoundBufferImpl *dsb, DWORD write
/* Mix in different sample rates */
TRACE
(
"(%p) Adjusting frequency: %d -> %d
\n
"
,
dsb
,
dsb
->
freq
,
dsb
->
device
->
pwfx
->
nSamplesPerSec
);
DSOUND_secpos_to_bufpos
(
dsb
,
writepos
,
dsb
->
sec_mixpos
,
&
freqAcc
);
overshot
=
freqAcc
>>
DSOUND_FREQSHIFT
;
if
(
overshot
)
{
if
(
overshot
>=
size
)
return
;
size
-=
overshot
;
writepos
+=
overshot
*
iAdvance
;
if
(
writepos
>=
dsb
->
buflen
)
return
;
ibp
=
dsb
->
buffer
->
memory
+
writepos
;
freqAcc
&=
(
1
<<
DSOUND_FREQSHIFT
)
-
1
;
TRACE
(
"Overshot: %d, freqAcc: %04x
\n
"
,
overshot
,
freqAcc
);
}
obp
=
obp_begin
;
DSOUND_secpos_to_bufpos
(
dsb
,
dsb
->
sec_mixpos
,
dsb
->
sec_mixpos
,
&
freqAcc
);
/* FIXME: Small problem here when we're overwriting buf_mixpos, it then STILL uses old freqAcc, not sure if it matters or not */
cp_fields
(
dsb
,
ibp
,
obp
,
iAdvance
,
oAdvance
,
size
,
freqAcc
,
dsb
->
freqAdjust
);
...
...
@@ -497,7 +474,7 @@ static DWORD DSOUND_MixInBuffer(IDirectSoundBufferImpl *dsb, DWORD writepos, DWO
}
/* Resample buffer to temporary buffer specifically allocated for this purpose, if needed */
DSOUND_MixToTemporary
(
dsb
,
dsb
->
sec_mixpos
,
DSOUND_bufpos_to_secpos
(
dsb
,
dsb
->
buf_mixpos
+
len
)
-
dsb
->
sec_mixpos
);
DSOUND_MixToTemporary
(
dsb
,
len
);
ibuf
=
dsb
->
device
->
tmp_buffer
;
/* Apply volume if needed */
...
...
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