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
287a6e84
Commit
287a6e84
authored
Dec 02, 2011
by
Andrew Eikum
Committed by
Alexandre Julliard
Dec 05, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dsound: Validate format in primary buffer's SetFormat().
parent
dfbe6645
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
145 additions
and
0 deletions
+145
-0
primary.c
dlls/dsound/primary.c
+6
-0
dsound.c
dlls/dsound/tests/dsound.c
+139
-0
No files found.
dlls/dsound/primary.c
View file @
287a6e84
...
...
@@ -374,6 +374,12 @@ HRESULT primarybuffer_SetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX passe
passed_fmt
->
nAvgBytesPerSec
,
passed_fmt
->
nBlockAlign
,
passed_fmt
->
wBitsPerSample
,
passed_fmt
->
cbSize
);
if
(
passed_fmt
->
wBitsPerSample
<
8
||
passed_fmt
->
wBitsPerSample
%
8
!=
0
||
passed_fmt
->
nChannels
==
0
||
passed_fmt
->
nSamplesPerSec
==
0
||
passed_fmt
->
nAvgBytesPerSec
==
0
||
passed_fmt
->
nBlockAlign
!=
passed_fmt
->
nChannels
*
passed_fmt
->
wBitsPerSample
/
8
)
return
DSERR_INVALIDPARAM
;
/* **** */
RtlAcquireResourceExclusive
(
&
(
device
->
buffer_list_lock
),
TRUE
);
EnterCriticalSection
(
&
(
device
->
mixlock
));
...
...
dlls/dsound/tests/dsound.c
View file @
287a6e84
...
...
@@ -1221,6 +1221,144 @@ EXIT:
return
rc
;
}
static
HRESULT
test_invalid_fmts
(
LPGUID
lpGuid
)
{
HRESULT
rc
;
LPDIRECTSOUND
dso
=
NULL
;
LPDIRECTSOUNDBUFFER
primary
=
NULL
;
DSBUFFERDESC
bufdesc
;
/* Create the DirectSound object */
rc
=
pDirectSoundCreate
(
lpGuid
,
&
dso
,
NULL
);
ok
(
rc
==
DS_OK
||
rc
==
DSERR_NODRIVER
||
rc
==
DSERR_ALLOCATED
,
"DirectSoundCreate() failed: %08x
\n
"
,
rc
);
if
(
rc
!=
DS_OK
)
return
rc
;
/* We must call SetCooperativeLevel before creating primary buffer */
/* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
rc
=
IDirectSound_SetCooperativeLevel
(
dso
,
get_hwnd
(),
DSSCL_PRIORITY
);
ok
(
rc
==
DS_OK
,
"IDirectSound_SetCooperativeLevel() failed: %08x
\n
"
,
rc
);
if
(
rc
!=
DS_OK
){
IDirectSound_Release
(
dso
);
return
rc
;
}
ZeroMemory
(
&
bufdesc
,
sizeof
(
bufdesc
));
bufdesc
.
dwSize
=
sizeof
(
bufdesc
);
bufdesc
.
dwFlags
=
DSBCAPS_PRIMARYBUFFER
;
rc
=
IDirectSound_CreateSoundBuffer
(
dso
,
&
bufdesc
,
&
primary
,
NULL
);
ok
(
rc
==
DS_OK
&&
primary
!=
NULL
,
"IDirectSound_CreateSoundBuffer() failed "
"to create a primary buffer %08x
\n
"
,
rc
);
if
(
rc
==
DS_OK
&&
primary
!=
NULL
)
{
WAVEFORMATEX
wfx
;
wfx
.
wFormatTag
=
WAVE_FORMAT_PCM
;
wfx
.
nChannels
=
0
;
wfx
.
nSamplesPerSec
=
44100
;
wfx
.
wBitsPerSample
=
16
;
wfx
.
nBlockAlign
=
wfx
.
nChannels
*
wfx
.
wBitsPerSample
/
8
;
wfx
.
nAvgBytesPerSec
=
wfx
.
nSamplesPerSec
*
wfx
.
nBlockAlign
;
rc
=
IDirectSoundBuffer_SetFormat
(
primary
,
&
wfx
);
ok
(
rc
==
E_INVALIDARG
,
"SetFormat: %08x
\n
"
,
rc
);
wfx
.
nChannels
=
2
;
wfx
.
nSamplesPerSec
=
44100
;
wfx
.
wBitsPerSample
=
0
;
wfx
.
nBlockAlign
=
wfx
.
nChannels
*
wfx
.
wBitsPerSample
/
8
;
wfx
.
nAvgBytesPerSec
=
wfx
.
nSamplesPerSec
*
wfx
.
nBlockAlign
;
rc
=
IDirectSoundBuffer_SetFormat
(
primary
,
&
wfx
);
ok
(
rc
==
E_INVALIDARG
,
"SetFormat: %08x
\n
"
,
rc
);
wfx
.
nChannels
=
2
;
wfx
.
nSamplesPerSec
=
44100
;
wfx
.
wBitsPerSample
=
2
;
wfx
.
nBlockAlign
=
wfx
.
nChannels
*
wfx
.
wBitsPerSample
/
8
;
wfx
.
nAvgBytesPerSec
=
wfx
.
nSamplesPerSec
*
wfx
.
nBlockAlign
;
rc
=
IDirectSoundBuffer_SetFormat
(
primary
,
&
wfx
);
ok
(
rc
==
E_INVALIDARG
,
"SetFormat: %08x
\n
"
,
rc
);
wfx
.
nChannels
=
2
;
wfx
.
nSamplesPerSec
=
44100
;
wfx
.
wBitsPerSample
=
12
;
wfx
.
nBlockAlign
=
wfx
.
nChannels
*
wfx
.
wBitsPerSample
/
8
;
wfx
.
nAvgBytesPerSec
=
wfx
.
nSamplesPerSec
*
wfx
.
nBlockAlign
;
rc
=
IDirectSoundBuffer_SetFormat
(
primary
,
&
wfx
);
ok
(
rc
==
E_INVALIDARG
,
"SetFormat: %08x
\n
"
,
rc
);
wfx
.
nChannels
=
2
;
wfx
.
nSamplesPerSec
=
0
;
wfx
.
wBitsPerSample
=
16
;
wfx
.
nBlockAlign
=
wfx
.
nChannels
*
wfx
.
wBitsPerSample
/
8
;
wfx
.
nAvgBytesPerSec
=
wfx
.
nSamplesPerSec
*
wfx
.
nBlockAlign
;
rc
=
IDirectSoundBuffer_SetFormat
(
primary
,
&
wfx
);
ok
(
rc
==
E_INVALIDARG
,
"SetFormat: %08x
\n
"
,
rc
);
wfx
.
nChannels
=
2
;
wfx
.
nSamplesPerSec
=
44100
;
wfx
.
wBitsPerSample
=
16
;
wfx
.
nBlockAlign
=
0
;
wfx
.
nAvgBytesPerSec
=
wfx
.
nSamplesPerSec
*
wfx
.
nBlockAlign
;
rc
=
IDirectSoundBuffer_SetFormat
(
primary
,
&
wfx
);
ok
(
rc
==
E_INVALIDARG
,
"SetFormat: %08x
\n
"
,
rc
);
wfx
.
nChannels
=
2
;
wfx
.
nSamplesPerSec
=
44100
;
wfx
.
wBitsPerSample
=
16
;
wfx
.
nBlockAlign
=
wfx
.
nChannels
*
wfx
.
wBitsPerSample
/
8
;
wfx
.
nAvgBytesPerSec
=
0
;
rc
=
IDirectSoundBuffer_SetFormat
(
primary
,
&
wfx
);
ok
(
rc
==
E_INVALIDARG
,
"SetFormat: %08x
\n
"
,
rc
);
wfx
.
nChannels
=
2
;
wfx
.
nSamplesPerSec
=
44100
;
wfx
.
wBitsPerSample
=
16
;
wfx
.
nBlockAlign
=
(
wfx
.
nChannels
*
wfx
.
wBitsPerSample
/
8
)
-
1
;
wfx
.
nAvgBytesPerSec
=
wfx
.
nSamplesPerSec
*
wfx
.
nBlockAlign
;
rc
=
IDirectSoundBuffer_SetFormat
(
primary
,
&
wfx
);
ok
(
rc
==
E_INVALIDARG
,
"SetFormat: %08x
\n
"
,
rc
);
wfx
.
nChannels
=
2
;
wfx
.
nSamplesPerSec
=
44100
;
wfx
.
wBitsPerSample
=
16
;
wfx
.
nBlockAlign
=
(
wfx
.
nChannels
*
wfx
.
wBitsPerSample
/
8
)
+
1
;
wfx
.
nAvgBytesPerSec
=
wfx
.
nSamplesPerSec
*
wfx
.
nBlockAlign
;
rc
=
IDirectSoundBuffer_SetFormat
(
primary
,
&
wfx
);
ok
(
rc
==
E_INVALIDARG
,
"SetFormat: %08x
\n
"
,
rc
);
wfx
.
nChannels
=
2
;
wfx
.
nSamplesPerSec
=
44100
;
wfx
.
wBitsPerSample
=
16
;
wfx
.
nBlockAlign
=
wfx
.
nChannels
*
wfx
.
wBitsPerSample
/
8
;
wfx
.
nAvgBytesPerSec
=
wfx
.
nSamplesPerSec
*
wfx
.
nBlockAlign
+
1
;
rc
=
IDirectSoundBuffer_SetFormat
(
primary
,
&
wfx
);
ok
(
rc
==
S_OK
,
"SetFormat: %08x
\n
"
,
rc
);
wfx
.
nChannels
=
2
;
wfx
.
nSamplesPerSec
=
44100
;
wfx
.
wBitsPerSample
=
16
;
wfx
.
nBlockAlign
=
wfx
.
nChannels
*
wfx
.
wBitsPerSample
/
8
;
wfx
.
nAvgBytesPerSec
=
wfx
.
nSamplesPerSec
*
wfx
.
nBlockAlign
-
1
;
rc
=
IDirectSoundBuffer_SetFormat
(
primary
,
&
wfx
);
ok
(
rc
==
S_OK
,
"SetFormat: %08x
\n
"
,
rc
);
wfx
.
nChannels
=
2
;
wfx
.
nSamplesPerSec
=
44100
;
wfx
.
wBitsPerSample
=
16
;
wfx
.
nBlockAlign
=
wfx
.
nChannels
*
wfx
.
wBitsPerSample
/
8
;
wfx
.
nAvgBytesPerSec
=
wfx
.
nSamplesPerSec
*
wfx
.
nBlockAlign
+
1
;
rc
=
IDirectSoundBuffer_SetFormat
(
primary
,
&
wfx
);
ok
(
rc
==
S_OK
,
"SetFormat: %08x
\n
"
,
rc
);
IDirectSoundBuffer_Release
(
primary
);
}
IDirectSound_Release
(
dso
);
return
S_OK
;
}
static
unsigned
int
number
;
static
BOOL
WINAPI
dsenum_callback
(
LPGUID
lpGuid
,
LPCSTR
lpcstrDescription
,
...
...
@@ -1250,6 +1388,7 @@ static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
test_secondary
(
lpGuid
);
test_frequency
(
lpGuid
);
test_duplicate
(
lpGuid
);
test_invalid_fmts
(
lpGuid
);
}
return
1
;
...
...
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