Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
edf76b1d
Commit
edf76b1d
authored
Jul 23, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wasapi: enumerate rendering devices (at start-up only)
parent
b6d22a96
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
1 deletion
+71
-1
modules/audio_output/wasapi.c
modules/audio_output/wasapi.c
+71
-1
No files found.
modules/audio_output/wasapi.c
View file @
edf76b1d
...
@@ -219,6 +219,74 @@ static int DeviceChanged(vlc_object_t *obj, const char *varname,
...
@@ -219,6 +219,74 @@ static int DeviceChanged(vlc_object_t *obj, const char *varname,
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
static
void
GetDevices
(
vlc_object_t
*
obj
,
IMMDeviceEnumerator
*
it
)
{
HRESULT
hr
;
vlc_value_t
val
,
text
;
text
.
psz_string
=
_
(
"Audio Device"
);
var_Change
(
obj
,
"audio-device"
,
VLC_VAR_SETTEXT
,
&
text
,
NULL
);
IMMDeviceCollection
*
devs
;
hr
=
IMMDeviceEnumerator_EnumAudioEndpoints
(
it
,
eRender
,
DEVICE_STATE_ACTIVE
,
&
devs
);
if
(
FAILED
(
hr
))
{
msg_Warn
(
obj
,
"cannot enumerate audio endpoints (error 0x%lx)"
,
hr
);
return
;
}
UINT
n
;
hr
=
IMMDeviceCollection_GetCount
(
devs
,
&
n
);
if
(
FAILED
(
hr
))
n
=
0
;
while
(
n
>
0
)
{
IMMDevice
*
dev
;
hr
=
IMMDeviceCollection_Item
(
devs
,
--
n
,
&
dev
);
if
(
FAILED
(
hr
))
continue
;
/* Unique device ID */
LPWSTR
devid
;
hr
=
IMMDevice_GetId
(
dev
,
&
devid
);
if
(
FAILED
(
hr
))
{
IMMDevice_Release
(
dev
);
continue
;
}
val
.
psz_string
=
FromWide
(
devid
);
CoTaskMemFree
(
devid
);
text
.
psz_string
=
val
.
psz_string
;
/* User-readable device name */
IPropertyStore
*
props
;
hr
=
IMMDevice_OpenPropertyStore
(
dev
,
STGM_READ
,
&
props
);
if
(
SUCCEEDED
(
hr
))
{
PROPVARIANT
v
;
PropVariantInit
(
&
v
);
#ifdef FIXED
hr
=
IPropertyStore_GetValue
(
props
,
PKEY_Device_FriendlyName
,
&
v
);
if
(
SUCCEEDED
(
hr
))
text
.
psz_string
=
FromWide
(
v
.
pwszVal
);
#endif
PropVariantClear
(
&
v
);
IPropertyStore_Release
(
props
);
}
IMMDevice_Release
(
dev
);
var_Change
(
obj
,
"audio-device"
,
VLC_VAR_ADDCHOICE
,
&
val
,
&
text
);
if
(
likely
(
text
.
psz_string
!=
val
.
psz_string
))
free
(
text
.
psz_string
);
free
(
val
.
psz_string
);
}
IMMDeviceCollection_Release
(
devs
);
}
static
void
vlc_ToWave
(
WAVEFORMATEXTENSIBLE
*
restrict
wf
,
static
void
vlc_ToWave
(
WAVEFORMATEXTENSIBLE
*
restrict
wf
,
audio_sample_format_t
*
restrict
audio
)
audio_sample_format_t
*
restrict
audio
)
{
{
...
@@ -400,7 +468,7 @@ static int Open(vlc_object_t *obj)
...
@@ -400,7 +468,7 @@ static int Open(vlc_object_t *obj)
}
}
/* Get audio device according to policy */
/* Get audio device according to policy */
var_Create
(
aout
,
"audio-device"
,
VLC_VAR_STRING
);
var_Create
(
aout
,
"audio-device"
,
VLC_VAR_STRING
|
VLC_VAR_HASCHOICE
);
IMMDeviceEnumerator
*
devs
;
IMMDeviceEnumerator
*
devs
;
hr
=
CoCreateInstance
(
&
CLSID_MMDeviceEnumerator
,
NULL
,
CLSCTX_ALL
,
hr
=
CoCreateInstance
(
&
CLSID_MMDeviceEnumerator
,
NULL
,
CLSCTX_ALL
,
...
@@ -431,6 +499,8 @@ static int Open(vlc_object_t *obj)
...
@@ -431,6 +499,8 @@ static int Open(vlc_object_t *obj)
hr
=
IMMDeviceEnumerator_GetDefaultAudioEndpoint
(
devs
,
eRender
,
hr
=
IMMDeviceEnumerator_GetDefaultAudioEndpoint
(
devs
,
eRender
,
eConsole
,
&
dev
);
eConsole
,
&
dev
);
}
}
GetDevices
(
VLC_OBJECT
(
aout
),
devs
);
IMMDeviceEnumerator_Release
(
devs
);
IMMDeviceEnumerator_Release
(
devs
);
if
(
FAILED
(
hr
))
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