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
d86627a2
Commit
d86627a2
authored
Mar 21, 2024
by
Brendan Shanks
Committed by
Alexandre Julliard
Mar 27, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mmdevapi: Make IMMDeviceCollection immutable after creation.
parent
7a529fc9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
24 deletions
+42
-24
devenum.c
dlls/mmdevapi/devenum.c
+42
-24
No files found.
dlls/mmdevapi/devenum.c
View file @
d86627a2
...
...
@@ -76,8 +76,8 @@ typedef struct MMDevColImpl
{
IMMDeviceCollection
IMMDeviceCollection_iface
;
LONG
ref
;
EDataFlow
flow
;
DWORD
state
;
IMMDevice
**
devices
;
UINT
devices_count
;
}
MMDevColImpl
;
typedef
struct
IPropertyBagImpl
{
...
...
@@ -827,6 +827,8 @@ static const IMMEndpointVtbl MMEndpointVtbl =
static
HRESULT
MMDevCol_Create
(
IMMDeviceCollection
**
ppv
,
EDataFlow
flow
,
DWORD
state
)
{
MMDevColImpl
*
This
;
MMDevice
*
cur
;
UINT
i
=
0
;
This
=
malloc
(
sizeof
(
*
This
));
*
ppv
=
NULL
;
...
...
@@ -834,14 +836,43 @@ static HRESULT MMDevCol_Create(IMMDeviceCollection **ppv, EDataFlow flow, DWORD
return
E_OUTOFMEMORY
;
This
->
IMMDeviceCollection_iface
.
lpVtbl
=
&
MMDevColVtbl
;
This
->
ref
=
1
;
This
->
flow
=
flow
;
This
->
state
=
state
;
This
->
devices
=
NULL
;
This
->
devices_count
=
0
;
*
ppv
=
&
This
->
IMMDeviceCollection_iface
;
LIST_FOR_EACH_ENTRY
(
cur
,
&
device_list
,
MMDevice
,
entry
)
{
if
((
cur
->
flow
==
flow
||
flow
==
eAll
)
&&
(
cur
->
state
&
state
))
This
->
devices_count
++
;
}
if
(
This
->
devices_count
)
{
This
->
devices
=
malloc
(
This
->
devices_count
*
sizeof
(
IMMDevice
*
));
if
(
!
This
->
devices_count
)
return
E_OUTOFMEMORY
;
LIST_FOR_EACH_ENTRY
(
cur
,
&
device_list
,
MMDevice
,
entry
)
{
if
((
cur
->
flow
==
flow
||
flow
==
eAll
)
&&
(
cur
->
state
&
state
))
{
This
->
devices
[
i
]
=
&
cur
->
IMMDevice_iface
;
IMMDevice_AddRef
(
This
->
devices
[
i
]);
i
++
;
}
}
}
return
S_OK
;
}
static
void
MMDevCol_Destroy
(
MMDevColImpl
*
This
)
{
UINT
i
;
for
(
i
=
0
;
i
<
This
->
devices_count
;
i
++
)
IMMDevice_Release
(
This
->
devices
[
i
]);
free
(
This
->
devices
);
free
(
This
);
}
...
...
@@ -884,46 +915,33 @@ static ULONG WINAPI MMDevCol_Release(IMMDeviceCollection *iface)
static
HRESULT
WINAPI
MMDevCol_GetCount
(
IMMDeviceCollection
*
iface
,
UINT
*
numdevs
)
{
MMDevColImpl
*
This
=
impl_from_IMMDeviceCollection
(
iface
);
MMDevice
*
cur
;
TRACE
(
"(%p)->(%p)
\n
"
,
This
,
numdevs
);
if
(
!
numdevs
)
return
E_POINTER
;
*
numdevs
=
0
;
LIST_FOR_EACH_ENTRY
(
cur
,
&
device_list
,
MMDevice
,
entry
)
{
if
((
cur
->
flow
==
This
->
flow
||
This
->
flow
==
eAll
)
&&
(
cur
->
state
&
This
->
state
))
++
(
*
numdevs
);
}
*
numdevs
=
This
->
devices_count
;
return
S_OK
;
}
static
HRESULT
WINAPI
MMDevCol_Item
(
IMMDeviceCollection
*
iface
,
UINT
n
,
IMMDevice
**
dev
)
{
MMDevColImpl
*
This
=
impl_from_IMMDeviceCollection
(
iface
);
MMDevice
*
cur
;
DWORD
i
=
0
;
TRACE
(
"(%p)->(%u, %p)
\n
"
,
This
,
n
,
dev
);
if
(
!
dev
)
return
E_POINTER
;
LIST_FOR_EACH_ENTRY
(
cur
,
&
device_list
,
MMDevice
,
entry
)
{
if
((
cur
->
flow
==
This
->
flow
||
This
->
flow
==
eAll
)
&&
(
cur
->
state
&
This
->
state
)
&&
i
++
==
n
)
if
(
n
>=
This
->
devices_count
)
{
*
dev
=
&
cur
->
IMMDevice_iface
;
IMMDevice_AddRef
(
*
dev
);
return
S_OK
;
}
}
WARN
(
"Could not obtain item %u
\n
"
,
n
);
*
dev
=
NULL
;
return
E_INVALIDARG
;
}
*
dev
=
This
->
devices
[
n
];
IMMDevice_AddRef
(
*
dev
);
return
S_OK
;
}
static
const
IMMDeviceCollectionVtbl
MMDevColVtbl
=
...
...
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