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
473a5462
Commit
473a5462
authored
May 27, 2023
by
Shaun Ren
Committed by
Alexandre Julliard
Jun 09, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sapi: Implement ISpMMSysAudio::Get/SetFormat.
parent
b24c1abf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
124 additions
and
4 deletions
+124
-4
mmaudio.c
dlls/sapi/mmaudio.c
+64
-4
mmaudio.c
dlls/sapi/tests/mmaudio.c
+60
-0
No files found.
dlls/sapi/mmaudio.c
View file @
473a5462
...
...
@@ -53,6 +53,7 @@ struct mmaudio
enum
flow_type
flow
;
ISpObjectToken
*
token
;
UINT
device_id
;
WAVEFORMATEX
*
wfx
;
CRITICAL_SECTION
cs
;
};
...
...
@@ -363,6 +364,7 @@ static ULONG WINAPI mmsysaudio_Release(ISpMMSysAudio *iface)
if
(
!
ref
)
{
if
(
This
->
token
)
ISpObjectToken_Release
(
This
->
token
);
heap_free
(
This
->
wfx
);
DeleteCriticalSection
(
&
This
->
cs
);
heap_free
(
This
);
...
...
@@ -455,9 +457,26 @@ static HRESULT WINAPI mmsysaudio_Clone(ISpMMSysAudio *iface, IStream **stream)
static
HRESULT
WINAPI
mmsysaudio_GetFormat
(
ISpMMSysAudio
*
iface
,
GUID
*
format
,
WAVEFORMATEX
**
wfx
)
{
FIXME
(
"(%p, %p, %p): stub.
\n
"
,
iface
,
format
,
wfx
);
struct
mmaudio
*
This
=
impl_from_ISpMMSysAudio
(
iface
);
return
E_NOTIMPL
;
TRACE
(
"(%p, %p, %p).
\n
"
,
iface
,
format
,
wfx
);
if
(
!
format
||
!
wfx
)
return
E_POINTER
;
EnterCriticalSection
(
&
This
->
cs
);
if
(
!
(
*
wfx
=
CoTaskMemAlloc
(
sizeof
(
WAVEFORMATEX
)
+
This
->
wfx
->
cbSize
)))
{
LeaveCriticalSection
(
&
This
->
cs
);
return
E_OUTOFMEMORY
;
}
*
format
=
SPDFID_WaveFormatEx
;
memcpy
(
*
wfx
,
This
->
wfx
,
sizeof
(
WAVEFORMATEX
)
+
This
->
wfx
->
cbSize
);
LeaveCriticalSection
(
&
This
->
cs
);
return
S_OK
;
}
static
HRESULT
WINAPI
mmsysaudio_SetState
(
ISpMMSysAudio
*
iface
,
SPAUDIOSTATE
state
,
ULONGLONG
reserved
)
...
...
@@ -469,9 +488,37 @@ static HRESULT WINAPI mmsysaudio_SetState(ISpMMSysAudio *iface, SPAUDIOSTATE sta
static
HRESULT
WINAPI
mmsysaudio_SetFormat
(
ISpMMSysAudio
*
iface
,
const
GUID
*
guid
,
const
WAVEFORMATEX
*
wfx
)
{
FIXME
(
"(%p, %s, %p): stub.
\n
"
,
iface
,
debugstr_guid
(
guid
),
wfx
);
struct
mmaudio
*
This
=
impl_from_ISpMMSysAudio
(
iface
);
MMRESULT
res
;
WAVEFORMATEX
*
new_wfx
;
return
E_NOTIMPL
;
TRACE
(
"(%p, %s, %p).
\n
"
,
iface
,
debugstr_guid
(
guid
),
wfx
);
if
(
!
guid
||
!
wfx
||
!
IsEqualGUID
(
guid
,
&
SPDFID_WaveFormatEx
))
return
E_INVALIDARG
;
EnterCriticalSection
(
&
This
->
cs
);
/* Determine whether the device supports the requested format. */
res
=
waveOutOpen
(
NULL
,
This
->
device_id
,
wfx
,
0
,
0
,
WAVE_FORMAT_QUERY
);
if
(
res
!=
MMSYSERR_NOERROR
)
{
LeaveCriticalSection
(
&
This
->
cs
);
return
res
==
WAVERR_BADFORMAT
?
SPERR_UNSUPPORTED_FORMAT
:
SPERR_GENERIC_MMSYS_ERROR
;
}
if
(
!
(
new_wfx
=
heap_alloc
(
sizeof
(
*
wfx
)
+
wfx
->
cbSize
)))
{
LeaveCriticalSection
(
&
This
->
cs
);
return
E_OUTOFMEMORY
;
}
memcpy
(
new_wfx
,
wfx
,
sizeof
(
*
wfx
)
+
wfx
->
cbSize
);
heap_free
(
This
->
wfx
);
This
->
wfx
=
new_wfx
;
LeaveCriticalSection
(
&
This
->
cs
);
return
S_OK
;
}
static
HRESULT
WINAPI
mmsysaudio_GetStatus
(
ISpMMSysAudio
*
iface
,
SPAUDIOSTATUS
*
status
)
...
...
@@ -647,6 +694,19 @@ static HRESULT mmaudio_create(IUnknown *outer, REFIID iid, void **obj, enum flow
This
->
token
=
NULL
;
This
->
device_id
=
WAVE_MAPPER
;
if
(
!
(
This
->
wfx
=
heap_alloc
(
sizeof
(
*
This
->
wfx
))))
{
heap_free
(
This
);
return
E_OUTOFMEMORY
;
}
This
->
wfx
->
wFormatTag
=
WAVE_FORMAT_PCM
;
This
->
wfx
->
nChannels
=
1
;
This
->
wfx
->
nSamplesPerSec
=
22050
;
This
->
wfx
->
nAvgBytesPerSec
=
22050
*
2
;
This
->
wfx
->
nBlockAlign
=
2
;
This
->
wfx
->
wBitsPerSample
=
16
;
This
->
wfx
->
cbSize
=
0
;
InitializeCriticalSection
(
&
This
->
cs
);
hr
=
ISpMMSysAudio_QueryInterface
(
&
This
->
ISpMMSysAudio_iface
,
iid
,
obj
);
...
...
dlls/sapi/tests/mmaudio.c
View file @
473a5462
...
...
@@ -22,9 +22,13 @@
#include "sapiddk.h"
#include "sperror.h"
#include "initguid.h"
#include "wine/test.h"
DEFINE_GUID
(
SPDFID_Text
,
0x7ceef9f9
,
0x3d13
,
0x11d2
,
0x9e
,
0xe7
,
0x00
,
0xc0
,
0x4f
,
0x79
,
0x73
,
0x96
);
DEFINE_GUID
(
SPDFID_WaveFormatEx
,
0xc31adbae
,
0x527f
,
0x4ff5
,
0xa2
,
0x30
,
0xf6
,
0x2b
,
0xb6
,
0x1f
,
0xf7
,
0x0c
);
static
void
test_interfaces
(
void
)
{
ISpMMSysAudio
*
mmaudio
;
...
...
@@ -99,10 +103,66 @@ static void test_device_id(void)
ISpMMSysAudio_Release
(
mmaudio
);
}
static
void
test_formats
(
void
)
{
ISpMMSysAudio
*
mmaudio
;
GUID
fmtid
;
WAVEFORMATEX
*
wfx
;
WAVEFORMATEX
wfx2
;
HRESULT
hr
;
hr
=
CoCreateInstance
(
&
CLSID_SpMMAudioOut
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_ISpMMSysAudio
,
(
void
**
)
&
mmaudio
);
ok
(
hr
==
S_OK
,
"failed to create SpMMAudioOut instance: %#lx.
\n
"
,
hr
);
wfx
=
NULL
;
hr
=
ISpMMSysAudio_GetFormat
(
mmaudio
,
&
fmtid
,
&
wfx
);
ok
(
hr
==
S_OK
,
"got %#lx.
\n
"
,
hr
);
ok
(
IsEqualGUID
(
&
fmtid
,
&
SPDFID_WaveFormatEx
),
"got %s.
\n
"
,
wine_dbgstr_guid
(
&
fmtid
));
ok
(
wfx
!=
NULL
,
"wfx == NULL.
\n
"
);
ok
(
wfx
->
wFormatTag
==
WAVE_FORMAT_PCM
,
"got %u.
\n
"
,
wfx
->
wFormatTag
);
ok
(
wfx
->
nChannels
==
1
,
"got %u.
\n
"
,
wfx
->
nChannels
);
ok
(
wfx
->
nSamplesPerSec
==
22050
,
"got %lu.
\n
"
,
wfx
->
nSamplesPerSec
);
ok
(
wfx
->
nAvgBytesPerSec
==
22050
*
2
,
"got %lu.
\n
"
,
wfx
->
nAvgBytesPerSec
);
ok
(
wfx
->
nBlockAlign
==
2
,
"got %u.
\n
"
,
wfx
->
nBlockAlign
);
ok
(
wfx
->
wBitsPerSample
==
16
,
"got %u.
\n
"
,
wfx
->
wBitsPerSample
);
ok
(
wfx
->
cbSize
==
0
,
"got %u.
\n
"
,
wfx
->
cbSize
);
CoTaskMemFree
(
wfx
);
hr
=
ISpMMSysAudio_SetFormat
(
mmaudio
,
NULL
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"got %#lx.
\n
"
,
hr
);
hr
=
ISpMMSysAudio_SetFormat
(
mmaudio
,
&
SPDFID_Text
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"got %#lx.
\n
"
,
hr
);
hr
=
ISpMMSysAudio_SetFormat
(
mmaudio
,
&
SPDFID_WaveFormatEx
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"got %#lx.
\n
"
,
hr
);
if
(
waveOutGetNumDevs
()
==
0
)
{
skip
(
"no wave out devices.
\n
"
);
ISpMMSysAudio_Release
(
mmaudio
);
return
;
}
wfx2
.
wFormatTag
=
WAVE_FORMAT_PCM
;
wfx2
.
nChannels
=
2
;
wfx2
.
nSamplesPerSec
=
16000
;
wfx2
.
nAvgBytesPerSec
=
16000
*
2
*
2
;
wfx2
.
nBlockAlign
=
2
*
2
;
wfx2
.
wBitsPerSample
=
16
;
wfx2
.
cbSize
=
0
;
hr
=
ISpMMSysAudio_SetFormat
(
mmaudio
,
&
SPDFID_WaveFormatEx
,
&
wfx2
);
ok
(
hr
==
S_OK
,
"got %#lx.
\n
"
,
hr
);
ISpMMSysAudio_Release
(
mmaudio
);
}
START_TEST
(
mmaudio
)
{
CoInitialize
(
NULL
);
test_interfaces
();
test_device_id
();
test_formats
();
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