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
5d90ada5
Commit
5d90ada5
authored
Jun 29, 2023
by
Davide Beatrici
Committed by
Alexandre Julliard
Jun 30, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winealsa: Refactor get_device_name_from_guid() to allocate memory dynamically.
parent
32775c87
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
9 deletions
+31
-9
mmdevdrv.c
dlls/winealsa.drv/mmdevdrv.c
+31
-9
No files found.
dlls/winealsa.drv/mmdevdrv.c
View file @
5d90ada5
...
...
@@ -251,7 +251,7 @@ end:
return
params
.
result
;
}
static
BOOL
get_
alsa_name_by_guid
(
GUID
*
guid
,
char
*
name
,
DWORD
name_siz
e
,
EDataFlow
*
flow
)
static
BOOL
get_
device_name_from_guid
(
GUID
*
guid
,
char
**
nam
e
,
EDataFlow
*
flow
)
{
HKEY
devices_key
;
UINT
i
=
0
;
...
...
@@ -282,6 +282,8 @@ static BOOL get_alsa_name_by_guid(GUID *guid, char *name, DWORD name_size, EData
if
(
RegQueryValueExW
(
key
,
guidW
,
0
,
&
type
,
(
BYTE
*
)
&
reg_guid
,
&
size
)
==
ERROR_SUCCESS
){
if
(
IsEqualGUID
(
&
reg_guid
,
guid
)){
INT
size
;
RegCloseKey
(
key
);
RegCloseKey
(
devices_key
);
...
...
@@ -296,7 +298,16 @@ static BOOL get_alsa_name_by_guid(GUID *guid, char *name, DWORD name_size, EData
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
;
}
...
...
@@ -315,23 +326,30 @@ static BOOL get_alsa_name_by_guid(GUID *guid, char *name, DWORD name_size, EData
HRESULT
WINAPI
AUDDRV_GetAudioEndpoint
(
GUID
*
guid
,
IMMDevice
*
dev
,
IAudioClient
**
out
)
{
ACImpl
*
This
;
char
alsa_name
[
256
]
;
char
*
alsa_name
;
EDataFlow
dataflow
;
HRESULT
hr
;
int
len
;
TRACE
(
"%s %p %p
\n
"
,
debugstr_guid
(
guid
),
dev
,
out
);
if
(
!
get_
alsa_name_by_guid
(
guid
,
alsa_name
,
sizeof
(
alsa_name
)
,
&
dataflow
))
if
(
!
get_
device_name_from_guid
(
guid
,
&
alsa_name
,
&
dataflow
))
return
AUDCLNT_E_DEVICE_INVALIDATED
;
if
(
dataflow
!=
eRender
&&
dataflow
!=
eCapture
)
if
(
dataflow
!=
eRender
&&
dataflow
!=
eCapture
){
free
(
alsa_name
);
return
E_UNEXPECTED
;
}
len
=
strlen
(
alsa_name
);
This
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
offsetof
(
ACImpl
,
device_name
[
len
+
1
]));
if
(
!
This
)
if
(
!
This
){
free
(
alsa_name
);
return
E_OUTOFMEMORY
;
}
memcpy
(
This
->
device_name
,
alsa_name
,
len
+
1
);
free
(
alsa_name
);
This
->
IAudioClient3_iface
.
lpVtbl
=
&
AudioClient3_Vtbl
;
This
->
IAudioRenderClient_iface
.
lpVtbl
=
&
AudioRenderClient_Vtbl
;
...
...
@@ -347,7 +365,6 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient
}
This
->
dataflow
=
dataflow
;
memcpy
(
This
->
device_name
,
alsa_name
,
len
+
1
);
This
->
parent
=
dev
;
IMMDevice_AddRef
(
This
->
parent
);
...
...
@@ -458,13 +475,13 @@ HRESULT WINAPI AUDDRV_GetAudioSessionWrapper(const GUID *guid, IMMDevice *device
HRESULT
WINAPI
AUDDRV_GetPropValue
(
GUID
*
guid
,
const
PROPERTYKEY
*
prop
,
PROPVARIANT
*
out
)
{
struct
get_prop_value_params
params
;
char
name
[
256
]
;
char
*
name
;
EDataFlow
flow
;
unsigned
int
size
=
0
;
TRACE
(
"%s, (%s,%lu), %p
\n
"
,
wine_dbgstr_guid
(
guid
),
wine_dbgstr_guid
(
&
prop
->
fmtid
),
prop
->
pid
,
out
);
if
(
!
get_
alsa_name_by_guid
(
guid
,
name
,
sizeof
(
name
)
,
&
flow
))
if
(
!
get_
device_name_from_guid
(
guid
,
&
name
,
&
flow
))
{
WARN
(
"Unknown interface %s
\n
"
,
debugstr_guid
(
guid
));
return
E_NOINTERFACE
;
...
...
@@ -487,10 +504,15 @@ HRESULT WINAPI AUDDRV_GetPropValue(GUID *guid, const PROPERTYKEY *prop, PROPVARI
CoTaskMemFree
(
params
.
buffer
);
params
.
buffer
=
CoTaskMemAlloc
(
*
params
.
buffer_size
);
if
(
!
params
.
buffer
)
{
free
(
name
);
return
E_OUTOFMEMORY
;
}
}
if
(
FAILED
(
params
.
result
))
CoTaskMemFree
(
params
.
buffer
);
free
(
name
);
return
params
.
result
;
}
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