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
b8d6b310
Commit
b8d6b310
authored
Feb 16, 2005
by
Robert Reif
Committed by
Alexandre Julliard
Feb 16, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed invalid buffer size by rounding up to next multiple of
nBlockAlign. Added test to verify buffer rounding behavior.
parent
373dc890
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
13 deletions
+81
-13
buffer.c
dlls/dsound/buffer.c
+7
-2
ds3d.c
dlls/dsound/tests/ds3d.c
+2
-1
ds3d8.c
dlls/dsound/tests/ds3d8.c
+2
-1
dsound.c
dlls/dsound/tests/dsound.c
+56
-4
dsound8.c
dlls/dsound/tests/dsound8.c
+13
-4
dsound_test.h
dlls/dsound/tests/dsound_test.h
+1
-1
No files found.
dlls/dsound/buffer.c
View file @
b8d6b310
...
...
@@ -1060,9 +1060,14 @@ HRESULT WINAPI IDirectSoundBufferImpl_Create(
CopyMemory
(
dsb
->
pwfx
,
wfex
,
cp_size
);
dsb
->
buflen
=
dsbd
->
dwBufferBytes
;
dsb
->
freq
=
dsbd
->
lpwfxFormat
->
nSamplesPerSec
;
if
(
dsbd
->
dwBufferBytes
%
dsbd
->
lpwfxFormat
->
nBlockAlign
)
dsb
->
buflen
=
dsbd
->
dwBufferBytes
+
(
dsbd
->
lpwfxFormat
->
nBlockAlign
-
(
dsbd
->
dwBufferBytes
%
dsbd
->
lpwfxFormat
->
nBlockAlign
));
else
dsb
->
buflen
=
dsbd
->
dwBufferBytes
;
dsb
->
freq
=
dsbd
->
lpwfxFormat
->
nSamplesPerSec
;
dsb
->
notify
=
NULL
;
dsb
->
notifies
=
NULL
;
dsb
->
nrofnotifies
=
0
;
...
...
dlls/dsound/tests/ds3d.c
View file @
b8d6b310
...
...
@@ -713,7 +713,8 @@ static HRESULT test_secondary(LPGUID lpGuid, int play,
else
bufdesc
.
dwFlags
|=
(
DSBCAPS_CTRLFREQUENCY
|
DSBCAPS_CTRLVOLUME
|
DSBCAPS_CTRLPAN
);
bufdesc
.
dwBufferBytes
=
wfx
.
nAvgBytesPerSec
*
BUFFER_LEN
/
1000
;
bufdesc
.
dwBufferBytes
=
align
(
wfx
.
nAvgBytesPerSec
*
BUFFER_LEN
/
1000
,
wfx
.
nBlockAlign
);
bufdesc
.
lpwfxFormat
=&
wfx
;
if
(
winetest_interactive
)
{
trace
(
" Testing a %s%ssecondary buffer %s%s%s%sat %ldx%dx%d "
...
...
dlls/dsound/tests/ds3d8.c
View file @
b8d6b310
...
...
@@ -615,7 +615,8 @@ static HRESULT test_secondary8(LPGUID lpGuid, int play,
else
bufdesc
.
dwFlags
|=
(
DSBCAPS_CTRLFREQUENCY
|
DSBCAPS_CTRLVOLUME
|
DSBCAPS_CTRLPAN
);
bufdesc
.
dwBufferBytes
=
wfx
.
nAvgBytesPerSec
*
BUFFER_LEN
/
1000
;
bufdesc
.
dwBufferBytes
=
align
(
wfx
.
nAvgBytesPerSec
*
BUFFER_LEN
/
1000
,
wfx
.
nBlockAlign
);
bufdesc
.
lpwfxFormat
=&
wfx
;
if
(
has_3d
)
{
/* a stereo 3D buffer should fail */
...
...
dlls/dsound/tests/dsound.c
View file @
b8d6b310
...
...
@@ -305,7 +305,8 @@ static HRESULT test_dsound(LPGUID lpGuid)
ZeroMemory
(
&
bufdesc
,
sizeof
(
bufdesc
));
bufdesc
.
dwSize
=
sizeof
(
bufdesc
);
bufdesc
.
dwFlags
=
DSBCAPS_GETCURRENTPOSITION2
|
DSBCAPS_CTRL3D
;
bufdesc
.
dwBufferBytes
=
wfx
.
nAvgBytesPerSec
*
BUFFER_LEN
/
1000
;
bufdesc
.
dwBufferBytes
=
align
(
wfx
.
nAvgBytesPerSec
*
BUFFER_LEN
/
1000
,
wfx
.
nBlockAlign
);
bufdesc
.
lpwfxFormat
=&
wfx
;
rc
=
IDirectSound_CreateSoundBuffer
(
dso
,
&
bufdesc
,
&
secondary
,
NULL
);
ok
(
rc
==
DS_OK
&&
secondary
!=
NULL
,
...
...
@@ -573,7 +574,8 @@ static HRESULT test_primary_secondary(LPGUID lpGuid)
ZeroMemory
(
&
bufdesc
,
sizeof
(
bufdesc
));
bufdesc
.
dwSize
=
sizeof
(
bufdesc
);
bufdesc
.
dwFlags
=
DSBCAPS_GETCURRENTPOSITION2
;
bufdesc
.
dwBufferBytes
=
wfx
.
nAvgBytesPerSec
*
BUFFER_LEN
/
1000
;
bufdesc
.
dwBufferBytes
=
align
(
wfx
.
nAvgBytesPerSec
*
BUFFER_LEN
/
1000
,
wfx
.
nBlockAlign
);
bufdesc
.
lpwfxFormat
=&
wfx2
;
if
(
winetest_interactive
)
{
trace
(
" Testing a primary buffer at %ldx%dx%d with a "
...
...
@@ -672,7 +674,8 @@ static HRESULT test_secondary(LPGUID lpGuid)
ZeroMemory
(
&
bufdesc
,
sizeof
(
bufdesc
));
bufdesc
.
dwSize
=
sizeof
(
bufdesc
);
bufdesc
.
dwFlags
=
DSBCAPS_GETCURRENTPOSITION2
;
bufdesc
.
dwBufferBytes
=
wfx
.
nAvgBytesPerSec
*
BUFFER_LEN
/
1000
;
bufdesc
.
dwBufferBytes
=
align
(
wfx
.
nAvgBytesPerSec
*
BUFFER_LEN
/
1000
,
wfx
.
nBlockAlign
);
rc
=
IDirectSound_CreateSoundBuffer
(
dso
,
&
bufdesc
,
&
secondary
,
NULL
);
ok
(
rc
==
DSERR_INVALIDPARAM
,
"IDirectSound_CreateSoundBuffer() "
"should have returned DSERR_INVALIDPARAM, returned: %s
\n
"
,
...
...
@@ -684,7 +687,8 @@ static HRESULT test_secondary(LPGUID lpGuid)
ZeroMemory
(
&
bufdesc
,
sizeof
(
bufdesc
));
bufdesc
.
dwSize
=
sizeof
(
bufdesc
);
bufdesc
.
dwFlags
=
DSBCAPS_GETCURRENTPOSITION2
;
bufdesc
.
dwBufferBytes
=
wfx
.
nAvgBytesPerSec
*
BUFFER_LEN
/
1000
;
bufdesc
.
dwBufferBytes
=
align
(
wfx
.
nAvgBytesPerSec
*
BUFFER_LEN
/
1000
,
wfx
.
nBlockAlign
);
bufdesc
.
lpwfxFormat
=&
wfx
;
if
(
winetest_interactive
)
{
trace
(
" Testing a secondary buffer at %ldx%dx%d "
...
...
@@ -727,6 +731,53 @@ EXIT:
return
rc
;
}
static
HRESULT
test_block_align
(
LPGUID
lpGuid
)
{
HRESULT
rc
;
LPDIRECTSOUND
dso
=
NULL
;
LPDIRECTSOUNDBUFFER
secondary
=
NULL
;
DSBUFFERDESC
bufdesc
;
DSBCAPS
dsbcaps
;
WAVEFORMATEX
wfx
;
int
ref
;
/* Create the DirectSound object */
rc
=
DirectSoundCreate
(
lpGuid
,
&
dso
,
NULL
);
ok
(
rc
==
DS_OK
||
rc
==
DSERR_NODRIVER
||
rc
==
DSERR_ALLOCATED
,
"DirectSoundCreate() failed: %s
\n
"
,
DXGetErrorString8
(
rc
));
if
(
rc
!=
DS_OK
)
return
rc
;
init_format
(
&
wfx
,
WAVE_FORMAT_PCM
,
11025
,
16
,
2
);
ZeroMemory
(
&
bufdesc
,
sizeof
(
bufdesc
));
bufdesc
.
dwSize
=
sizeof
(
bufdesc
);
bufdesc
.
dwFlags
=
DSBCAPS_GETCURRENTPOSITION2
;
bufdesc
.
dwBufferBytes
=
wfx
.
nAvgBytesPerSec
+
1
;
bufdesc
.
lpwfxFormat
=&
wfx
;
rc
=
IDirectSound_CreateSoundBuffer
(
dso
,
&
bufdesc
,
&
secondary
,
NULL
);
ok
(
rc
==
DS_OK
,
"IDirectSound_CreateSoundBuffer() "
"should have returned DS_OK, returned: %s
\n
"
,
DXGetErrorString8
(
rc
));
if
(
rc
==
DS_OK
&&
secondary
!=
NULL
)
{
rc
=
IDirectSoundBuffer_GetCaps
(
secondary
,
&
dsbcaps
);
ok
(
rc
==
DS_OK
,
"IDirectSoundBuffer_GetCaps() should have returned DS_OK, "
"returned: %s
\n
"
,
DXGetErrorString8
(
rc
));
ok
(
dsbcaps
.
dwBufferBytes
==
(
wfx
.
nAvgBytesPerSec
+
4
),
"Buffer size not a multiple of nBlockAlign
\n
"
);
ref
=
IDirectSoundBuffer_Release
(
secondary
);
ok
(
ref
==
0
,
"IDirectSoundBuffer_Release() secondary has %d references, "
"should have 0
\n
"
,
ref
);
}
ref
=
IDirectSound_Release
(
dso
);
ok
(
ref
==
0
,
"IDirectSound_Release() has %d references, should have 0
\n
"
,
ref
);
if
(
ref
!=
0
)
return
DSERR_GENERIC
;
return
rc
;
}
static
BOOL
WINAPI
dsenum_callback
(
LPGUID
lpGuid
,
LPCSTR
lpcstrDescription
,
LPCSTR
lpcstrModule
,
LPVOID
lpContext
)
{
...
...
@@ -738,6 +789,7 @@ static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
else
if
(
rc
==
DSERR_ALLOCATED
)
trace
(
" Already In Use
\n
"
);
else
{
test_block_align
(
lpGuid
);
test_primary
(
lpGuid
);
test_primary_secondary
(
lpGuid
);
test_secondary
(
lpGuid
);
...
...
dlls/dsound/tests/dsound8.c
View file @
b8d6b310
...
...
@@ -38,6 +38,11 @@
static
HRESULT
(
WINAPI
*
pDirectSoundCreate8
)(
LPCGUID
,
LPDIRECTSOUND8
*
,
LPUNKNOWN
)
=
NULL
;
int
align
(
int
length
,
int
align
)
{
return
(
length
/
align
)
*
align
;
}
static
void
IDirectSound8_test
(
LPDIRECTSOUND8
dso
,
BOOL
initialized
,
LPCGUID
lpGuid
)
{
...
...
@@ -315,7 +320,8 @@ static HRESULT test_dsound8(LPGUID lpGuid)
ZeroMemory
(
&
bufdesc
,
sizeof
(
bufdesc
));
bufdesc
.
dwSize
=
sizeof
(
bufdesc
);
bufdesc
.
dwFlags
=
DSBCAPS_GETCURRENTPOSITION2
|
DSBCAPS_CTRL3D
;
bufdesc
.
dwBufferBytes
=
wfx
.
nAvgBytesPerSec
*
BUFFER_LEN
/
1000
;
bufdesc
.
dwBufferBytes
=
align
(
wfx
.
nAvgBytesPerSec
*
BUFFER_LEN
/
1000
,
wfx
.
nBlockAlign
);
bufdesc
.
lpwfxFormat
=&
wfx
;
rc
=
IDirectSound8_CreateSoundBuffer
(
dso
,
&
bufdesc
,
&
secondary
,
NULL
);
ok
(
rc
==
DS_OK
&&
secondary
!=
NULL
,
...
...
@@ -594,7 +600,8 @@ static HRESULT test_primary_secondary8(LPGUID lpGuid)
ZeroMemory
(
&
bufdesc
,
sizeof
(
bufdesc
));
bufdesc
.
dwSize
=
sizeof
(
bufdesc
);
bufdesc
.
dwFlags
=
DSBCAPS_GETCURRENTPOSITION2
;
bufdesc
.
dwBufferBytes
=
wfx
.
nAvgBytesPerSec
*
BUFFER_LEN
/
1000
;
bufdesc
.
dwBufferBytes
=
align
(
wfx
.
nAvgBytesPerSec
*
BUFFER_LEN
/
1000
,
wfx
.
nBlockAlign
);
bufdesc
.
lpwfxFormat
=&
wfx2
;
if
(
winetest_interactive
)
{
trace
(
" Testing a primary buffer at %ldx%dx%d with a "
...
...
@@ -693,7 +700,8 @@ static HRESULT test_secondary8(LPGUID lpGuid)
ZeroMemory
(
&
bufdesc
,
sizeof
(
bufdesc
));
bufdesc
.
dwSize
=
sizeof
(
bufdesc
);
bufdesc
.
dwFlags
=
DSBCAPS_GETCURRENTPOSITION2
;
bufdesc
.
dwBufferBytes
=
wfx
.
nAvgBytesPerSec
*
BUFFER_LEN
/
1000
;
bufdesc
.
dwBufferBytes
=
align
(
wfx
.
nAvgBytesPerSec
*
BUFFER_LEN
/
1000
,
wfx
.
nBlockAlign
);
rc
=
IDirectSound8_CreateSoundBuffer
(
dso
,
&
bufdesc
,
&
secondary
,
NULL
);
ok
(
rc
==
DSERR_INVALIDPARAM
,
"IDirectSound8_CreateSoundBuffer() "
"should have returned DSERR_INVALIDPARAM, returned: %s
\n
"
,
...
...
@@ -705,7 +713,8 @@ static HRESULT test_secondary8(LPGUID lpGuid)
ZeroMemory
(
&
bufdesc
,
sizeof
(
bufdesc
));
bufdesc
.
dwSize
=
sizeof
(
bufdesc
);
bufdesc
.
dwFlags
=
DSBCAPS_GETCURRENTPOSITION2
;
bufdesc
.
dwBufferBytes
=
wfx
.
nAvgBytesPerSec
*
BUFFER_LEN
/
1000
;
bufdesc
.
dwBufferBytes
=
align
(
wfx
.
nAvgBytesPerSec
*
BUFFER_LEN
/
1000
,
wfx
.
nBlockAlign
);
bufdesc
.
lpwfxFormat
=&
wfx
;
if
(
winetest_interactive
)
{
trace
(
" Testing a secondary buffer at %ldx%dx%d "
...
...
dlls/dsound/tests/dsound_test.h
View file @
b8d6b310
...
...
@@ -50,7 +50,6 @@ static const unsigned int formats[][4]={
#define TIME_SLICE 31
#define BUFFER_LEN 400
extern
char
*
wave_generate_la
(
WAVEFORMATEX
*
,
double
,
DWORD
*
);
extern
HWND
get_hwnd
(
void
);
extern
void
init_format
(
WAVEFORMATEX
*
,
int
,
int
,
int
,
int
);
...
...
@@ -61,3 +60,4 @@ extern void test_buffer8(LPDIRECTSOUND8,LPDIRECTSOUNDBUFFER,
BOOL
,
BOOL
,
LONG
,
BOOL
,
LONG
,
BOOL
,
double
,
BOOL
,
LPDIRECTSOUND3DLISTENER
,
BOOL
,
BOOL
);
extern
const
char
*
getDSBCAPS
(
DWORD
xmask
);
extern
int
align
(
int
length
,
int
align
);
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