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
8e338fbb
Commit
8e338fbb
authored
Dec 03, 2023
by
Brendan Shanks
Committed by
Alexandre Julliard
Dec 07, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winecoreaudio: Use UID as device string.
parent
38e06bfb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
9 deletions
+46
-9
coreaudio.c
dlls/winecoreaudio.drv/coreaudio.c
+43
-6
mmdevdrv.c
dlls/winecoreaudio.drv/mmdevdrv.c
+3
-3
No files found.
dlls/winecoreaudio.drv/coreaudio.c
View file @
8e338fbb
...
...
@@ -84,8 +84,6 @@ typedef OSSpinLock os_unfair_lock;
WINE_DEFAULT_DEBUG_CHANNEL
(
coreaudio
);
#define MAX_DEV_NAME_LEN 10
/* Max 32 bit digits */
struct
coreaudio_stream
{
os_unfair_lock
lock
;
...
...
@@ -242,6 +240,7 @@ static NTSTATUS unix_get_endpoint_ids(void *args)
struct
endpoint_info
{
CFStringRef
name
;
CFStringRef
uid
;
AudioDeviceID
id
;
}
*
info
;
OSStatus
sc
;
...
...
@@ -293,13 +292,13 @@ static NTSTATUS unix_get_endpoint_ids(void *args)
return
STATUS_SUCCESS
;
}
addr
.
mSelector
=
kAudioObjectPropertyName
;
addr
.
mScope
=
get_scope
(
params
->
flow
);
addr
.
mElement
=
0
;
for
(
i
=
0
;
i
<
num_devices
;
i
++
){
if
(
!
device_has_channels
(
devices
[
i
],
params
->
flow
))
continue
;
addr
.
mSelector
=
kAudioObjectPropertyName
;
size
=
sizeof
(
CFStringRef
);
sc
=
AudioObjectGetPropertyData
(
devices
[
i
],
&
addr
,
0
,
NULL
,
&
size
,
&
info
[
params
->
num
].
name
);
if
(
sc
!=
noErr
){
...
...
@@ -307,6 +306,16 @@ static NTSTATUS unix_get_endpoint_ids(void *args)
(
unsigned
int
)
devices
[
i
],
(
int
)
sc
);
continue
;
}
addr
.
mSelector
=
kAudioDevicePropertyDeviceUID
;
size
=
sizeof
(
CFStringRef
);
sc
=
AudioObjectGetPropertyData
(
devices
[
i
],
&
addr
,
0
,
NULL
,
&
size
,
&
info
[
params
->
num
].
uid
);
if
(
sc
!=
noErr
){
WARN
(
"Unable to get UID property for device %u: %x
\n
"
,
(
unsigned
int
)
devices
[
i
],
(
int
)
sc
);
continue
;
}
info
[
params
->
num
++
].
id
=
devices
[
i
];
}
free
(
devices
);
...
...
@@ -316,7 +325,7 @@ static NTSTATUS unix_get_endpoint_ids(void *args)
for
(
i
=
0
;
i
<
params
->
num
;
i
++
){
const
SIZE_T
name_len
=
CFStringGetLength
(
info
[
i
].
name
)
+
1
;
const
SIZE_T
device_len
=
MAX_DEV_NAME_LEN
+
1
;
const
SIZE_T
device_len
=
CFStringGetLength
(
info
[
i
].
uid
)
+
1
;
needed
+=
name_len
*
sizeof
(
WCHAR
)
+
((
device_len
+
1
)
&
~
1
);
if
(
needed
<=
params
->
size
){
...
...
@@ -325,12 +334,16 @@ static NTSTATUS unix_get_endpoint_ids(void *args)
CFStringGetCharacters
(
info
[
i
].
name
,
CFRangeMake
(
0
,
name_len
-
1
),
ptr
);
ptr
[
name_len
-
1
]
=
0
;
offset
+=
name_len
*
sizeof
(
WCHAR
);
endpoint
->
device
=
offset
;
sprintf
((
char
*
)
params
->
endpoints
+
offset
,
"%u"
,
(
unsigned
int
)
info
[
i
].
id
);
CFStringGetCString
(
info
[
i
].
uid
,
(
char
*
)
params
->
endpoints
+
offset
,
params
->
size
-
offset
,
kCFStringEncodingUTF8
);
((
char
*
)
params
->
endpoints
)[
offset
+
device_len
-
1
]
=
'\0'
;
offset
+=
(
device_len
+
1
)
&
~
1
;
endpoint
++
;
}
CFRelease
(
info
[
i
].
name
);
CFRelease
(
info
[
i
].
uid
);
if
(
info
[
i
].
id
==
default_id
)
params
->
default_idx
=
i
;
}
free
(
info
);
...
...
@@ -669,7 +682,31 @@ static HRESULT ca_setup_audiounit(EDataFlow dataflow, AudioComponentInstance uni
static
AudioDeviceID
dev_id_from_device
(
const
char
*
device
)
{
return
strtoul
(
device
,
NULL
,
10
);
AudioDeviceID
id
;
CFStringRef
uid
;
UInt32
size
;
OSStatus
sc
;
const
AudioObjectPropertyAddress
addr
=
{
.
mScope
=
kAudioObjectPropertyScopeGlobal
,
.
mElement
=
kAudioObjectPropertyElementMain
,
.
mSelector
=
kAudioHardwarePropertyTranslateUIDToDevice
,
};
uid
=
CFStringCreateWithCStringNoCopy
(
NULL
,
device
,
kCFStringEncodingUTF8
,
kCFAllocatorNull
);
size
=
sizeof
(
id
);
sc
=
AudioObjectGetPropertyData
(
kAudioObjectSystemObject
,
&
addr
,
sizeof
(
uid
),
&
uid
,
&
size
,
&
id
);
CFRelease
(
uid
);
if
(
sc
!=
noErr
){
WARN
(
"Failed to get device ID for UID %s: %x
\n
"
,
device
,
(
int
)
sc
);
return
kAudioObjectUnknown
;
}
if
(
id
==
kAudioObjectUnknown
)
WARN
(
"Failed to get device ID for UID %s
\n
"
,
device
);
return
id
;
}
static
NTSTATUS
unix_create_stream
(
void
*
args
)
...
...
dlls/winecoreaudio.drv/mmdevdrv.c
View file @
8e338fbb
...
...
@@ -124,7 +124,7 @@ void WINAPI get_device_guid(EDataFlow flow, const char *dev, GUID *guid)
key_name
[
0
]
=
'0'
;
key_name
[
1
]
=
','
;
MultiByteToWideChar
(
CP_U
NIXCP
,
0
,
dev
,
-
1
,
key_name
+
2
,
ARRAY_SIZE
(
key_name
)
-
2
);
MultiByteToWideChar
(
CP_U
TF8
,
0
,
dev
,
-
1
,
key_name
+
2
,
ARRAY_SIZE
(
key_name
)
-
2
);
if
(
RegOpenKeyExW
(
HKEY_CURRENT_USER
,
drv_key_devicesW
,
0
,
KEY_WRITE
|
KEY_READ
,
&
key
)
==
ERROR_SUCCESS
){
if
(
RegOpenKeyExW
(
key
,
key_name
,
0
,
KEY_READ
,
&
dev_key
)
==
ERROR_SUCCESS
){
...
...
@@ -195,13 +195,13 @@ BOOL WINAPI get_device_name_from_guid(const GUID *guid, char **name, EDataFlow *
return
FALSE
;
}
if
(
!
(
size
=
WideCharToMultiByte
(
CP_U
NIXCP
,
0
,
key_name
+
2
,
-
1
,
NULL
,
0
,
NULL
,
NULL
)))
if
(
!
(
size
=
WideCharToMultiByte
(
CP_U
TF8
,
0
,
key_name
+
2
,
-
1
,
NULL
,
0
,
NULL
,
NULL
)))
return
FALSE
;
if
(
!
(
*
name
=
malloc
(
size
)))
return
FALSE
;
if
(
!
WideCharToMultiByte
(
CP_U
NIXCP
,
0
,
key_name
+
2
,
-
1
,
*
name
,
size
,
NULL
,
NULL
)){
if
(
!
WideCharToMultiByte
(
CP_U
TF8
,
0
,
key_name
+
2
,
-
1
,
*
name
,
size
,
NULL
,
NULL
)){
free
(
*
name
);
return
FALSE
;
}
...
...
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