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
4c315db1
Commit
4c315db1
authored
Jun 05, 2005
by
Robert Reif
Committed by
Alexandre Julliard
Jun 05, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests to check DirectSoundCapture creation.
Fix dsound/capture.c to pass tests.
parent
d73dad66
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
178 additions
and
22 deletions
+178
-22
capture.c
dlls/dsound/capture.c
+19
-22
capture.c
dlls/dsound/tests/capture.c
+159
-0
No files found.
dlls/dsound/capture.c
View file @
4c315db1
...
...
@@ -91,7 +91,6 @@ HRESULT WINAPI IDirectSoundCaptureImpl_Create(
}
HRESULT
WINAPI
DSOUND_CaptureCreate
(
LPDIRECTSOUNDCAPTURE
*
ppDSC
,
IUnknown
*
pUnkOuter
)
{
...
...
@@ -254,7 +253,7 @@ static HRESULT DirectSoundCaptureDevice_Create(
{
DirectSoundCaptureDevice
*
device
;
TRACE
(
"(%p)
\n
"
,
ppDevice
);
/* Allocate memory */
device
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
DirectSoundCaptureDevice
));
...
...
@@ -457,7 +456,7 @@ IDirectSoundCaptureImpl_QueryInterface(
REFIID
riid
,
LPVOID
*
ppobj
)
{
DirectSoundCaptureDevice
*
This
=
((
IDirectSoundCaptureImpl
*
)
iface
)
->
devi
ce
;
IDirectSoundCaptureImpl
*
This
=
(
IDirectSoundCaptureImpl
*
)
ifa
ce
;
TRACE
(
"(%p,%s,%p)
\n
"
,
This
,
debugstr_guid
(
riid
),
ppobj
);
if
(
ppobj
==
NULL
)
{
...
...
@@ -467,16 +466,18 @@ IDirectSoundCaptureImpl_QueryInterface(
*
ppobj
=
NULL
;
if
(
This
->
driver
)
{
HRESULT
hres
;
hres
=
IDsCaptureDriver_QueryInterface
(
This
->
driver
,
riid
,
ppobj
);
if
(
hres
!=
DS_OK
)
WARN
(
"IDsCaptureDriver_QueryInterface failed
\n
"
);
return
hres
;
if
(
IsEqualIID
(
riid
,
&
IID_IUnknown
))
{
IDirectSoundCapture_AddRef
((
LPDIRECTSOUNDCAPTURE
)
This
);
*
ppobj
=
This
;
return
DS_OK
;
}
else
if
(
IsEqualIID
(
riid
,
&
IID_IDirectSoundCapture
))
{
IDirectSoundCapture_AddRef
((
LPDIRECTSOUNDCAPTURE
)
This
);
*
ppobj
=
This
;
return
DS_OK
;
}
WARN
(
"unsupported riid: %s
\n
"
,
debugstr_guid
(
riid
));
return
E_
FAIL
;
return
E_
NOINTERFACE
;
}
static
ULONG
WINAPI
...
...
@@ -492,7 +493,6 @@ static ULONG DirectSoundCaptureDevice_Release(
DirectSoundCaptureDevice
*
device
)
{
ULONG
ref
;
TRACE
(
"(%p) ref was %lu
\n
"
,
device
,
device
->
ref
);
device
->
ref
--
;
...
...
@@ -506,7 +506,7 @@ static ULONG DirectSoundCaptureDevice_Release(
if
(
device
->
driver
)
{
IDsCaptureDriver_Close
(
device
->
driver
);
IDsCaptureDriver_Release
(
device
->
driver
);
}
}
HeapFree
(
GetProcessHeap
(),
0
,
device
->
pwfx
);
device
->
lock
.
DebugInfo
->
Spare
[
1
]
=
0
;
...
...
@@ -590,6 +590,11 @@ IDirectSoundCaptureImpl_GetCaps(
IDirectSoundCaptureImpl
*
This
=
(
IDirectSoundCaptureImpl
*
)
iface
;
TRACE
(
"(%p,%p)
\n
"
,
This
,
lpDSCCaps
);
if
(
This
->
device
==
NULL
)
{
WARN
(
"not initialized
\n
"
);
return
DSERR_UNINITIALIZED
;
}
if
(
lpDSCCaps
==
NULL
)
{
WARN
(
"invalid parameter: lpDSCCaps== NULL
\n
"
);
return
DSERR_INVALIDPARAM
;
...
...
@@ -601,11 +606,6 @@ IDirectSoundCaptureImpl_GetCaps(
return
DSERR_INVALIDPARAM
;
}
if
(
!
(
This
->
device
)
)
{
WARN
(
"not initialized
\n
"
);
return
DSERR_UNINITIALIZED
;
}
lpDSCCaps
->
dwFlags
=
This
->
device
->
drvcaps
.
dwFlags
;
lpDSCCaps
->
dwFormats
=
This
->
device
->
drvcaps
.
dwFormats
;
lpDSCCaps
->
dwChannels
=
This
->
device
->
drvcaps
.
dwChannels
;
...
...
@@ -677,7 +677,7 @@ IDirectSoundCaptureImpl_Initialize(
WARN
(
"DirectSoundCaptureDevice_Create failed
\n
"
);
return
err
;
}
This
->
device
=
device
;
device
->
guid
=
devGUID
;
...
...
@@ -1771,10 +1771,7 @@ DSCCF_CreateInstance(
*
ppobj
=
NULL
;
if
(
IsEqualGUID
(
&
IID_IDirectSoundCapture
,
riid
)
)
return
DSOUND_CaptureCreate
((
LPDIRECTSOUNDCAPTURE
*
)
ppobj
,
pOuter
);
if
(
IsEqualGUID
(
&
IID_IDirectSoundCapture8
,
riid
)
)
return
DSOUND_CaptureCreate8
((
LPDIRECTSOUNDCAPTURE8
*
)
ppobj
,
pOuter
);
return
DSOUND_CaptureCreate8
((
LPDIRECTSOUNDCAPTURE
*
)
ppobj
,
pOuter
);
WARN
(
"(%p,%p,%s,%p) Interface not found!
\n
"
,
This
,
pOuter
,
debugstr_guid
(
riid
),
ppobj
);
return
E_NOINTERFACE
;
...
...
dlls/dsound/tests/capture.c
View file @
4c315db1
...
...
@@ -29,6 +29,7 @@
#include "dsound.h"
#include "mmreg.h"
#include "dxerr8.h"
#include "dsconf.h"
#include "dsound_test.h"
...
...
@@ -101,6 +102,163 @@ static char * format_string(WAVEFORMATEX* wfx)
return
str
;
}
static
void
IDirectSoundCapture_test
(
LPDIRECTSOUNDCAPTURE
dsco
,
BOOL
initialized
,
LPCGUID
lpGuid
)
{
HRESULT
rc
;
DSCCAPS
dsccaps
;
int
ref
;
IUnknown
*
unknown
;
IDirectSoundCapture
*
dsc
;
/* Try to Query for objects */
rc
=
IDirectSoundCapture_QueryInterface
(
dsco
,
&
IID_IUnknown
,
(
LPVOID
*
)
&
unknown
);
ok
(
rc
==
DS_OK
,
"IDirectSoundCapture_QueryInterface(IID_IUnknown) "
"failed: %s
\n
"
,
DXGetErrorString8
(
rc
));
if
(
rc
==
DS_OK
)
IDirectSoundCapture_Release
(
unknown
);
rc
=
IDirectSoundCapture_QueryInterface
(
dsco
,
&
IID_IDirectSoundCapture
,
(
LPVOID
*
)
&
dsc
);
ok
(
rc
==
DS_OK
,
"IDirectSoundCapture_QueryInterface(IID_IDirectSoundCapture) "
"failed: %s
\n
"
,
DXGetErrorString8
(
rc
));
if
(
rc
==
DS_OK
)
IDirectSoundCapture_Release
(
dsc
);
if
(
initialized
==
FALSE
)
{
/* try unitialized object */
rc
=
IDirectSoundCapture_GetCaps
(
dsco
,
0
);
ok
(
rc
==
DSERR_UNINITIALIZED
,
"IDirectSoundCapture_GetCaps(NULL) "
"should have returned DSERR_UNINITIALIZED, returned: %s
\n
"
,
DXGetErrorString8
(
rc
));
rc
=
IDirectSoundCapture_GetCaps
(
dsco
,
&
dsccaps
);
ok
(
rc
==
DSERR_UNINITIALIZED
,
"IDirectSoundCapture_GetCaps() "
"should have returned DSERR_UNINITIALIZED, returned: %s
\n
"
,
DXGetErrorString8
(
rc
));
rc
=
IDirectSoundCapture_Initialize
(
dsco
,
lpGuid
);
ok
(
rc
==
DS_OK
||
rc
==
DSERR_NODRIVER
||
rc
==
DSERR_ALLOCATED
||
rc
==
E_FAIL
,
"IDirectSoundCapture_Initialize() failed: %s
\n
"
,
DXGetErrorString8
(
rc
));
if
(
rc
==
DSERR_NODRIVER
)
{
trace
(
" No Driver
\n
"
);
goto
EXIT
;
}
else
if
(
rc
==
E_FAIL
)
{
trace
(
" No Device
\n
"
);
goto
EXIT
;
}
else
if
(
rc
==
DSERR_ALLOCATED
)
{
trace
(
" Already In Use
\n
"
);
goto
EXIT
;
}
}
rc
=
IDirectSoundCapture_Initialize
(
dsco
,
lpGuid
);
ok
(
rc
==
DSERR_ALREADYINITIALIZED
,
"IDirectSoundCapture_Initialize() "
"should have returned DSERR_ALREADYINITIALIZED: %s
\n
"
,
DXGetErrorString8
(
rc
));
/* DSOUND: Error: Invalid caps buffer */
rc
=
IDirectSoundCapture_GetCaps
(
dsco
,
0
);
ok
(
rc
==
DSERR_INVALIDPARAM
,
"IDirectSoundCapture_GetCaps(NULL) "
"should have returned DSERR_INVALIDPARAM, returned: %s
\n
"
,
DXGetErrorString8
(
rc
));
ZeroMemory
(
&
dsccaps
,
sizeof
(
dsccaps
));
/* DSOUND: Error: Invalid caps buffer */
rc
=
IDirectSound_GetCaps
(
dsco
,
&
dsccaps
);
ok
(
rc
==
DSERR_INVALIDPARAM
,
"IDirectSound_GetCaps() "
"should have returned DSERR_INVALIDPARAM, returned: %s
\n
"
,
DXGetErrorString8
(
rc
));
dsccaps
.
dwSize
=
sizeof
(
dsccaps
);
/* DSOUND: Running on a certified driver */
rc
=
IDirectSoundCapture_GetCaps
(
dsco
,
&
dsccaps
);
ok
(
rc
==
DS_OK
,
"IDirectSoundCapture_GetCaps() failed: %s
\n
"
,
DXGetErrorString8
(
rc
));
EXIT:
ref
=
IDirectSoundCapture_Release
(
dsco
);
ok
(
ref
==
0
,
"IDirectSoundCapture_Release() has %d references, "
"should have 0
\n
"
,
ref
);
}
static
void
IDirectSoundCapture_tests
()
{
HRESULT
rc
;
LPDIRECTSOUNDCAPTURE
dsco
=
NULL
;
trace
(
"Testing IDirectSoundCapture
\n
"
);
/* try the COM class factory method of creation with no device specified */
rc
=
CoCreateInstance
(
&
CLSID_DirectSoundCapture
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_IDirectSoundCapture
,
(
void
**
)
&
dsco
);
ok
(
rc
==
S_OK
,
"CoCreateInstance(CLSID_DirectSoundCapture) failed: %s
\n
"
,
DXGetErrorString8
(
rc
));
if
(
dsco
)
IDirectSoundCapture_test
(
dsco
,
FALSE
,
NULL
);
/* try the COM class factory method of creation with default capture
* device specified */
rc
=
CoCreateInstance
(
&
CLSID_DirectSoundCapture
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_IDirectSoundCapture
,
(
void
**
)
&
dsco
);
ok
(
rc
==
S_OK
,
"CoCreateInstance(CLSID_DirectSoundCapture) failed: %s
\n
"
,
DXGetErrorString8
(
rc
));
if
(
dsco
)
IDirectSoundCapture_test
(
dsco
,
FALSE
,
&
DSDEVID_DefaultCapture
);
/* try the COM class factory method of creation with default voice
* capture device specified */
rc
=
CoCreateInstance
(
&
CLSID_DirectSoundCapture
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_IDirectSoundCapture
,
(
void
**
)
&
dsco
);
ok
(
rc
==
S_OK
,
"CoCreateInstance(CLSID_DirectSoundCapture) failed: %s
\n
"
,
DXGetErrorString8
(
rc
));
if
(
dsco
)
IDirectSoundCapture_test
(
dsco
,
FALSE
,
&
DSDEVID_DefaultVoiceCapture
);
/* try the COM class factory method of creation with a bad
* IID specified */
rc
=
CoCreateInstance
(
&
CLSID_DirectSoundCapture
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
CLSID_DirectSoundPrivate
,
(
void
**
)
&
dsco
);
ok
(
rc
==
E_NOINTERFACE
,
"CoCreateInstance(CLSID_DirectSoundCapture,CLSID_DirectSoundPrivate) "
"should have failed: %s
\n
"
,
DXGetErrorString8
(
rc
));
/* try with no device specified */
rc
=
DirectSoundCaptureCreate
(
NULL
,
&
dsco
,
NULL
);
ok
(
rc
==
DS_OK
||
rc
==
DSERR_NODRIVER
||
rc
==
DSERR_ALLOCATED
||
rc
==
E_FAIL
,
"DirectSoundCaptureCreate(NULL) failed: %s
\n
"
,
DXGetErrorString8
(
rc
));
if
(
rc
==
S_OK
&&
dsco
)
IDirectSoundCapture_test
(
dsco
,
TRUE
,
NULL
);
/* try with default capture device specified */
rc
=
DirectSoundCaptureCreate
(
&
DSDEVID_DefaultCapture
,
&
dsco
,
NULL
);
ok
(
rc
==
DS_OK
||
rc
==
DSERR_NODRIVER
||
rc
==
DSERR_ALLOCATED
||
rc
==
E_FAIL
,
"DirectSoundCaptureCreate(DSDEVID_DefaultCapture) failed: %s
\n
"
,
DXGetErrorString8
(
rc
));
if
(
rc
==
DS_OK
&&
dsco
)
IDirectSoundCapture_test
(
dsco
,
TRUE
,
NULL
);
/* try with default voice capture device specified */
rc
=
DirectSoundCaptureCreate
(
&
DSDEVID_DefaultVoiceCapture
,
&
dsco
,
NULL
);
ok
(
rc
==
DS_OK
||
rc
==
DSERR_NODRIVER
||
rc
==
DSERR_ALLOCATED
||
rc
==
E_FAIL
,
"DirectSoundCaptureCreate(DSDEVID_DefaultVoiceCapture) failed: %s
\n
"
,
DXGetErrorString8
(
rc
));
if
(
rc
==
DS_OK
&&
dsco
)
IDirectSoundCapture_test
(
dsco
,
TRUE
,
NULL
);
/* try with a bad device specified */
rc
=
DirectSoundCaptureCreate
(
&
DSDEVID_DefaultVoicePlayback
,
&
dsco
,
NULL
);
ok
(
rc
==
DSERR_NODRIVER
,
"DirectSoundCaptureCreate(DSDEVID_DefaultVoicePlatback) "
"should have failed: %s
\n
"
,
DXGetErrorString8
(
rc
));
if
(
rc
==
DS_OK
&&
dsco
)
IDirectSoundCapture_Release
(
dsco
);
}
typedef
struct
{
char
*
wave
;
DWORD
wave_len
;
...
...
@@ -552,6 +710,7 @@ START_TEST(capture)
return
;
}
IDirectSoundCapture_tests
();
capture_tests
();
CoUninitialize
();
...
...
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