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
ec3929f9
Commit
ec3929f9
authored
Jun 29, 2023
by
Davide Beatrici
Committed by
Alexandre Julliard
Jun 30, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winecoreaudio: Refactor get_device_name_from_guid() to allocate memory dynamically.
parent
5d90ada5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
7 deletions
+22
-7
mmdevdrv.c
dlls/winecoreaudio.drv/mmdevdrv.c
+22
-7
No files found.
dlls/winecoreaudio.drv/mmdevdrv.c
View file @
ec3929f9
...
...
@@ -247,7 +247,7 @@ end:
return
params
.
result
;
}
static
BOOL
get_device_name_
by_guid
(
const
GUID
*
guid
,
char
*
name
,
const
SIZE_T
name_siz
e
,
EDataFlow
*
flow
)
static
BOOL
get_device_name_
from_guid
(
const
GUID
*
guid
,
char
**
nam
e
,
EDataFlow
*
flow
)
{
HKEY
devices_key
;
UINT
i
=
0
;
...
...
@@ -292,7 +292,16 @@ static BOOL get_device_name_by_guid(const GUID *guid, char *name, const SIZE_T n
return
FALSE
;
}
WideCharToMultiByte
(
CP_UNIXCP
,
0
,
key_name
+
2
,
-
1
,
name
,
name_size
,
NULL
,
NULL
);
if
(
!
(
size
=
WideCharToMultiByte
(
CP_UNIXCP
,
0
,
key_name
+
2
,
-
1
,
NULL
,
0
,
NULL
,
NULL
)))
return
FALSE
;
if
(
!
(
*
name
=
malloc
(
size
)))
return
FALSE
;
if
(
!
WideCharToMultiByte
(
CP_UNIXCP
,
0
,
key_name
+
2
,
-
1
,
*
name
,
size
,
NULL
,
NULL
)){
free
(
*
name
);
return
FALSE
;
}
return
TRUE
;
}
...
...
@@ -311,23 +320,30 @@ static BOOL get_device_name_by_guid(const GUID *guid, char *name, const SIZE_T n
HRESULT
WINAPI
AUDDRV_GetAudioEndpoint
(
GUID
*
guid
,
IMMDevice
*
dev
,
IAudioClient
**
out
)
{
ACImpl
*
This
;
char
name
[
256
]
;
char
*
name
;
SIZE_T
name_len
;
EDataFlow
dataflow
;
HRESULT
hr
;
TRACE
(
"%s %p %p
\n
"
,
debugstr_guid
(
guid
),
dev
,
out
);
if
(
!
get_device_name_
by_guid
(
guid
,
name
,
sizeof
(
name
)
,
&
dataflow
))
if
(
!
get_device_name_
from_guid
(
guid
,
&
name
,
&
dataflow
))
return
AUDCLNT_E_DEVICE_INVALIDATED
;
if
(
dataflow
!=
eRender
&&
dataflow
!=
eCapture
)
if
(
dataflow
!=
eRender
&&
dataflow
!=
eCapture
){
free
(
name
);
return
E_UNEXPECTED
;
}
name_len
=
strlen
(
name
);
This
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
offsetof
(
ACImpl
,
device_name
[
name_len
+
1
]));
if
(
!
This
)
if
(
!
This
){
free
(
name
);
return
E_OUTOFMEMORY
;
}
memcpy
(
This
->
device_name
,
name
,
name_len
+
1
);
free
(
name
);
This
->
IAudioClient3_iface
.
lpVtbl
=
&
AudioClient3_Vtbl
;
This
->
IAudioRenderClient_iface
.
lpVtbl
=
&
AudioRenderClient_Vtbl
;
...
...
@@ -337,7 +353,6 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient
This
->
IAudioStreamVolume_iface
.
lpVtbl
=
&
AudioStreamVolume_Vtbl
;
This
->
dataflow
=
dataflow
;
memcpy
(
This
->
device_name
,
name
,
name_len
+
1
);
hr
=
CoCreateFreeThreadedMarshaler
((
IUnknown
*
)
&
This
->
IAudioClient3_iface
,
&
This
->
marshal
);
if
(
FAILED
(
hr
))
{
...
...
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