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
f461e849
Commit
f461e849
authored
Apr 09, 2012
by
Andrew Eikum
Committed by
Alexandre Julliard
Apr 09, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winealsa.drv: Enumerate ALSA devices in a single pass.
parent
78fc648d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
33 deletions
+41
-33
mmdevdrv.c
dlls/winealsa.drv/mmdevdrv.c
+41
-33
No files found.
dlls/winealsa.drv/mmdevdrv.c
View file @
f461e849
...
...
@@ -329,6 +329,8 @@ static BOOL alsa_try_open(const char *devnode, snd_pcm_stream_t stream)
snd_pcm_t
*
handle
;
int
err
;
TRACE
(
"devnode: %s, stream: %d
\n
"
,
devnode
,
stream
);
if
((
err
=
snd_pcm_open
(
&
handle
,
devnode
,
stream
,
SND_PCM_NONBLOCK
))
<
0
){
WARN
(
"The device
\"
%s
\"
failed to open: %d (%s).
\n
"
,
devnode
,
err
,
snd_strerror
(
err
));
...
...
@@ -386,11 +388,13 @@ static WCHAR *construct_device_id(EDataFlow flow, const WCHAR *chunk1, const cha
}
else
ret
[
copied
]
=
0
;
TRACE
(
"Enumerated device: %s
\n
"
,
wine_dbgstr_w
(
ret
));
return
ret
;
}
static
HRESULT
alsa_get_card_devices
(
EDataFlow
flow
,
snd_pcm_stream_t
stream
,
WCHAR
**
ids
,
GUID
*
guids
,
UINT
*
num
,
snd_ctl_t
*
ctl
,
int
card
,
WCHAR
**
*
ids
,
GUID
*
*
guids
,
UINT
*
num
,
snd_ctl_t
*
ctl
,
int
card
,
const
WCHAR
*
cardnameW
)
{
int
err
,
device
;
...
...
@@ -425,7 +429,14 @@ static HRESULT alsa_get_card_devices(EDataFlow flow, snd_pcm_stream_t stream,
if
(
!
alsa_try_open
(
devnode
,
stream
))
continue
;
if
(
ids
&&
guids
){
if
(
*
num
){
*
ids
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
*
ids
,
sizeof
(
WCHAR
*
)
*
(
*
num
+
1
));
*
guids
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
*
guids
,
sizeof
(
GUID
)
*
(
*
num
+
1
));
}
else
{
*
ids
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
WCHAR
*
));
*
guids
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
GUID
));
}
devname
=
snd_pcm_info_get_name
(
info
);
if
(
!
devname
){
WARN
(
"Unable to get device name for card %d, device %d
\n
"
,
card
,
...
...
@@ -433,9 +444,8 @@ static HRESULT alsa_get_card_devices(EDataFlow flow, snd_pcm_stream_t stream,
continue
;
}
ids
[
*
num
]
=
construct_device_id
(
flow
,
cardnameW
,
devname
);
get_device_guid
(
flow
,
devnode
,
&
guids
[
*
num
]);
}
(
*
ids
)[
*
num
]
=
construct_device_id
(
flow
,
cardnameW
,
devname
);
get_device_guid
(
flow
,
devnode
,
&
(
*
guids
)[
*
num
]);
++
(
*
num
);
}
...
...
@@ -449,8 +459,8 @@ static HRESULT alsa_get_card_devices(EDataFlow flow, snd_pcm_stream_t stream,
return
S_OK
;
}
static
void
get_reg_devices
(
EDataFlow
flow
,
snd_pcm_stream_t
stream
,
WCHAR
**
ids
,
GUID
*
guids
,
UINT
*
num
)
static
void
get_reg_devices
(
EDataFlow
flow
,
snd_pcm_stream_t
stream
,
WCHAR
**
*
ids
,
GUID
*
*
guids
,
UINT
*
num
)
{
static
const
WCHAR
ALSAOutputDevices
[]
=
{
'A'
,
'L'
,
'S'
,
'A'
,
'O'
,
'u'
,
't'
,
'p'
,
'u'
,
't'
,
'D'
,
'e'
,
'v'
,
'i'
,
'c'
,
'e'
,
's'
,
0
};
static
const
WCHAR
ALSAInputDevices
[]
=
{
'A'
,
'L'
,
'S'
,
'A'
,
'I'
,
'n'
,
'p'
,
'u'
,
't'
,
'D'
,
'e'
,
'v'
,
'i'
,
'c'
,
'e'
,
's'
,
0
};
...
...
@@ -477,10 +487,15 @@ static void get_reg_devices(EDataFlow flow, snd_pcm_stream_t stream, WCHAR **ids
WideCharToMultiByte
(
CP_UNIXCP
,
0
,
p
,
-
1
,
devname
,
sizeof
(
devname
),
NULL
,
NULL
);
if
(
alsa_try_open
(
devname
,
stream
)){
if
(
ids
&&
guids
){
ids
[
*
num
]
=
construct_device_id
(
flow
,
p
,
NULL
);
get_device_guid
(
flow
,
devname
,
&
guids
[
*
num
]);
if
(
*
num
){
*
ids
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
*
ids
,
sizeof
(
WCHAR
*
)
*
(
*
num
+
1
));
*
guids
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
*
guids
,
sizeof
(
GUID
)
*
(
*
num
+
1
));
}
else
{
*
ids
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
WCHAR
*
));
*
guids
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
GUID
));
}
(
*
ids
)[
*
num
]
=
construct_device_id
(
flow
,
p
,
NULL
);
get_device_guid
(
flow
,
devname
,
&
(
*
guids
)[
*
num
]);
++*
num
;
}
...
...
@@ -492,7 +507,7 @@ static void get_reg_devices(EDataFlow flow, snd_pcm_stream_t stream, WCHAR **ids
}
}
static
HRESULT
alsa_enum_devices
(
EDataFlow
flow
,
WCHAR
**
ids
,
GUID
*
guids
,
static
HRESULT
alsa_enum_devices
(
EDataFlow
flow
,
WCHAR
**
*
ids
,
GUID
*
*
guids
,
UINT
*
num
)
{
snd_pcm_stream_t
stream
=
(
flow
==
eRender
?
SND_PCM_STREAM_PLAYBACK
:
...
...
@@ -503,10 +518,10 @@ static HRESULT alsa_enum_devices(EDataFlow flow, WCHAR **ids, GUID *guids,
*
num
=
0
;
if
(
alsa_try_open
(
defname
,
stream
)){
if
(
ids
&&
guids
){
*
ids
=
construct_device_id
(
flow
,
defaultW
,
NULL
);
get_device_guid
(
flow
,
defname
,
guids
);
}
*
ids
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
WCHAR
*
));
(
*
ids
)[
0
]
=
construct_device_id
(
flow
,
defaultW
,
NULL
);
*
guids
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
GUID
)
);
get_device_guid
(
flow
,
defname
,
&
(
*
guids
)[
0
]);
++*
num
;
}
...
...
@@ -568,37 +583,30 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, GUID **guids,
TRACE
(
"%d %p %p %p %p
\n
"
,
flow
,
ids
,
guids
,
num
,
def_index
);
hr
=
alsa_enum_devices
(
flow
,
NULL
,
NULL
,
num
);
if
(
FAILED
(
hr
))
return
hr
;
if
(
*
num
==
0
)
{
*
ids
=
NULL
;
*
guids
=
NULL
;
return
S_OK
;
}
*
ids
=
HeapAlloc
(
GetProcessHeap
(),
0
,
*
num
*
sizeof
(
WCHAR
*
));
*
guids
=
HeapAlloc
(
GetProcessHeap
(),
0
,
*
num
*
sizeof
(
GUID
));
if
(
!*
ids
||
!*
guids
){
hr
=
alsa_enum_devices
(
flow
,
ids
,
guids
,
num
);
if
(
FAILED
(
hr
)){
UINT
i
;
for
(
i
=
0
;
i
<
*
num
;
++
i
)
HeapFree
(
GetProcessHeap
(),
0
,
(
*
ids
)[
i
]);
HeapFree
(
GetProcessHeap
(),
0
,
*
ids
);
HeapFree
(
GetProcessHeap
(),
0
,
*
guids
);
return
E_OUTOFMEMORY
;
}
*
def_index
=
0
;
TRACE
(
"Enumerated %u devices
\n
"
,
*
num
)
;
hr
=
alsa_enum_devices
(
flow
,
*
ids
,
*
guids
,
num
);
if
(
FAILED
(
hr
)){
int
i
;
for
(
i
=
0
;
i
<
*
num
;
++
i
)
HeapFree
(
GetProcessHeap
(),
0
,
(
*
ids
)[
i
]);
if
(
*
num
==
0
){
HeapFree
(
GetProcessHeap
(),
0
,
*
ids
);
*
ids
=
NULL
;
HeapFree
(
GetProcessHeap
(),
0
,
*
guids
);
return
E_OUTOFMEMORY
;
*
guids
=
NULL
;
}
*
def_index
=
0
;
return
S_OK
;
}
...
...
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