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
f88f3d41
Commit
f88f3d41
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: Replace convert() functions with get() and put().
parent
0195e019
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
39 deletions
+50
-39
dsound_convert.c
dlls/dsound/dsound_convert.c
+0
-0
dsound_private.h
dlls/dsound/dsound_private.h
+8
-4
mixer.c
dlls/dsound/mixer.c
+42
-35
No files found.
dlls/dsound/dsound_convert.c
View file @
f88f3d41
This diff is collapsed.
Click to expand it.
dlls/dsound/dsound_private.h
View file @
f88f3d41
...
...
@@ -52,8 +52,10 @@ typedef struct DirectSoundDevice DirectSoundDevice;
typedef
struct
DirectSoundCaptureDevice
DirectSoundCaptureDevice
;
/* dsound_convert.h */
typedef
void
(
*
bitsconvertfunc
)(
const
void
*
,
void
*
,
UINT
,
UINT
,
INT
,
UINT
,
UINT
);
extern
const
bitsconvertfunc
convertbpp
[
5
][
4
]
DECLSPEC_HIDDEN
;
typedef
float
(
*
bitsgetfunc
)(
const
IDirectSoundBufferImpl
*
,
DWORD
,
DWORD
);
typedef
void
(
*
bitsputfunc
)(
const
IDirectSoundBufferImpl
*
,
DWORD
,
DWORD
,
float
);
extern
const
bitsgetfunc
getbpp
[
5
]
DECLSPEC_HIDDEN
;
extern
const
bitsputfunc
putbpp
[
4
]
DECLSPEC_HIDDEN
;
typedef
void
(
*
mixfunc
)(
const
void
*
,
void
*
,
unsigned
);
extern
const
mixfunc
mixfunctions
[
4
]
DECLSPEC_HIDDEN
;
typedef
void
(
*
normfunc
)(
const
void
*
,
void
*
,
unsigned
);
...
...
@@ -190,8 +192,10 @@ struct IDirectSoundBufferImpl
DS3DBUFFER
ds3db_ds3db
;
LONG
ds3db_lVolume
;
BOOL
ds3db_need_recalc
;
/* IKsPropertySet fields */
bitsconvertfunc
convert
;
/* Used for bit depth conversion */
bitsgetfunc
get
;
bitsputfunc
put
;
struct
list
entry
;
};
...
...
dlls/dsound/mixer.c
View file @
f88f3d41
...
...
@@ -200,10 +200,8 @@ void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb)
dsb
->
freqAcc
=
dsb
->
freqAccNext
=
0
;
dsb
->
freqneeded
=
needresample
;
if
(
ieee
)
dsb
->
convert
=
convertbpp
[
4
][
dsb
->
device
->
pwfx
->
wBitsPerSample
/
8
-
1
];
else
dsb
->
convert
=
convertbpp
[
dsb
->
pwfx
->
wBitsPerSample
/
8
-
1
][
dsb
->
device
->
pwfx
->
wBitsPerSample
/
8
-
1
];
dsb
->
get
=
ieee
?
getbpp
[
4
]
:
getbpp
[
dsb
->
pwfx
->
wBitsPerSample
/
8
-
1
];
dsb
->
put
=
putbpp
[
dsb
->
device
->
pwfx
->
wBitsPerSample
/
8
-
1
];
if
(
needremix
)
{
...
...
@@ -274,37 +272,47 @@ void DSOUND_CheckEvent(const IDirectSoundBufferImpl *dsb, DWORD playpos, int len
* Copy a single frame from the given input buffer to the given output buffer.
* Translate 8 <-> 16 bits and mono <-> stereo
*/
static
inline
void
cp_fields
(
const
IDirectSoundBufferImpl
*
dsb
,
const
BYTE
*
ibuf
,
BYTE
*
obuf
,
static
inline
void
cp_fields
(
const
IDirectSoundBufferImpl
*
dsb
,
const
BYTE
*
ibuf
,
UINT
istride
,
UINT
ostride
,
UINT
count
,
UINT
freqAcc
,
UINT
adj
)
{
DirectSoundDevice
*
device
=
dsb
->
device
;
INT
istep
=
dsb
->
pwfx
->
wBitsPerSample
/
8
,
ostep
=
device
->
pwfx
->
wBitsPerSample
/
8
;
if
(
device
->
pwfx
->
nChannels
==
dsb
->
pwfx
->
nChannels
||
(
device
->
pwfx
->
nChannels
==
2
&&
dsb
->
pwfx
->
nChannels
==
6
)
||
(
device
->
pwfx
->
nChannels
==
8
&&
dsb
->
pwfx
->
nChannels
==
2
)
||
(
device
->
pwfx
->
nChannels
==
6
&&
dsb
->
pwfx
->
nChannels
==
2
))
{
dsb
->
convert
(
ibuf
,
obuf
,
istride
,
ostride
,
count
,
freqAcc
,
adj
);
if
(
device
->
pwfx
->
nChannels
==
2
||
dsb
->
pwfx
->
nChannels
==
2
)
dsb
->
convert
(
ibuf
+
istep
,
obuf
+
ostep
,
istride
,
ostride
,
count
,
freqAcc
,
adj
);
return
;
}
if
(
device
->
pwfx
->
nChannels
==
1
&&
dsb
->
pwfx
->
nChannels
==
2
)
{
dsb
->
convert
(
ibuf
,
obuf
,
istride
,
ostride
,
count
,
freqAcc
,
adj
);
return
;
float
value
;
ULONG
adv
;
DWORD
ipos
=
dsb
->
sec_mixpos
,
opos
=
0
;
while
(
count
--
>
0
)
{
if
(
device
->
pwfx
->
nChannels
==
dsb
->
pwfx
->
nChannels
||
(
device
->
pwfx
->
nChannels
==
2
&&
dsb
->
pwfx
->
nChannels
==
6
)
||
(
device
->
pwfx
->
nChannels
==
8
&&
dsb
->
pwfx
->
nChannels
==
2
)
||
(
device
->
pwfx
->
nChannels
==
6
&&
dsb
->
pwfx
->
nChannels
==
2
))
{
value
=
dsb
->
get
(
dsb
,
ipos
,
0
);
dsb
->
put
(
dsb
,
opos
,
0
,
value
);
if
(
device
->
pwfx
->
nChannels
==
2
||
dsb
->
pwfx
->
nChannels
==
2
)
{
value
=
dsb
->
get
(
dsb
,
ipos
,
1
);
dsb
->
put
(
dsb
,
opos
,
1
,
value
);
}
}
if
(
device
->
pwfx
->
nChannels
==
1
&&
dsb
->
pwfx
->
nChannels
==
2
)
{
float
val
=
(
dsb
->
get
(
dsb
,
ipos
,
0
)
+
dsb
->
get
(
dsb
,
ipos
,
1
))
/
2
.;
dsb
->
put
(
dsb
,
opos
,
0
,
val
);
}
if
(
device
->
pwfx
->
nChannels
==
2
&&
dsb
->
pwfx
->
nChannels
==
1
)
{
value
=
dsb
->
get
(
dsb
,
ipos
,
0
);
dsb
->
put
(
dsb
,
opos
,
0
,
value
);
dsb
->
put
(
dsb
,
opos
,
1
,
value
);
}
freqAcc
+=
adj
;
adv
=
(
freqAcc
>>
DSOUND_FREQSHIFT
);
freqAcc
&=
(
1
<<
DSOUND_FREQSHIFT
)
-
1
;
ipos
+=
adv
*
istride
;
opos
+=
ostride
;
}
if
(
device
->
pwfx
->
nChannels
==
2
&&
dsb
->
pwfx
->
nChannels
==
1
)
{
dsb
->
convert
(
ibuf
,
obuf
,
istride
,
ostride
,
count
,
freqAcc
,
adj
);
dsb
->
convert
(
ibuf
,
obuf
+
ostep
,
istride
,
ostride
,
count
,
freqAcc
,
adj
);
return
;
}
WARN
(
"Unable to remap channels: device=%u, buffer=%u
\n
"
,
device
->
pwfx
->
nChannels
,
dsb
->
pwfx
->
nChannels
);
}
/**
...
...
@@ -338,7 +346,7 @@ static inline DWORD DSOUND_BufPtrDiff(DWORD buflen, DWORD ptr1, DWORD ptr2)
static
void
DSOUND_MixToTemporary
(
const
IDirectSoundBufferImpl
*
dsb
,
DWORD
tmp_len
)
{
INT
size
;
BYTE
*
ibp
,
*
obp
;
BYTE
*
ibp
;
INT
iAdvance
=
dsb
->
pwfx
->
nBlockAlign
;
INT
oAdvance
=
dsb
->
device
->
pwfx
->
nBlockAlign
;
DWORD
freqAcc
;
...
...
@@ -352,7 +360,6 @@ static void DSOUND_MixToTemporary(const IDirectSoundBufferImpl *dsb, DWORD tmp_l
else
dsb
->
device
->
tmp_buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
tmp_len
);
}
obp
=
dsb
->
device
->
tmp_buffer
;
TRACE
(
"(%p, %p)
\n
"
,
dsb
,
ibp
);
size
=
tmp_len
/
oAdvance
;
...
...
@@ -362,7 +369,7 @@ static void DSOUND_MixToTemporary(const IDirectSoundBufferImpl *dsb, DWORD tmp_l
TRACE
(
"(%p) Same sample rate %d = primary %d
\n
"
,
dsb
,
dsb
->
freq
,
dsb
->
device
->
pwfx
->
nSamplesPerSec
);
cp_fields
(
dsb
,
ibp
,
obp
,
iAdvance
,
oAdvance
,
size
,
0
,
1
<<
DSOUND_FREQSHIFT
);
cp_fields
(
dsb
,
ibp
,
iAdvance
,
oAdvance
,
size
,
0
,
1
<<
DSOUND_FREQSHIFT
);
return
;
}
...
...
@@ -372,7 +379,7 @@ static void DSOUND_MixToTemporary(const IDirectSoundBufferImpl *dsb, DWORD tmp_l
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
);
cp_fields
(
dsb
,
ibp
,
iAdvance
,
oAdvance
,
size
,
freqAcc
,
dsb
->
freqAdjust
);
}
/** Apply volume to the given soundbuffer from (primary) position writepos and length len
...
...
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