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
b6d22a96
Commit
b6d22a96
authored
Jul 23, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wasapi: add run-time device selection
parent
7dc7f613
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
8 deletions
+45
-8
modules/audio_output/wasapi.c
modules/audio_output/wasapi.c
+45
-8
No files found.
modules/audio_output/wasapi.c
View file @
b6d22a96
...
...
@@ -208,6 +208,17 @@ static int SimpleMuteSet(audio_output_t *aout, bool mute)
return
FAILED
(
hr
)
?
-
1
:
0
;
}
static
int
DeviceChanged
(
vlc_object_t
*
obj
,
const
char
*
varname
,
vlc_value_t
prev
,
vlc_value_t
cur
,
void
*
data
)
{
aout_ChannelsRestart
(
obj
,
varname
,
prev
,
cur
,
data
);
if
(
!
var_Type
(
obj
,
"wasapi-audio-device"
))
var_Create
(
obj
,
"wasapi-audio-device"
,
VLC_VAR_STRING
);
var_SetString
(
obj
,
"wasapi-audio-device"
,
cur
.
psz_string
);
return
VLC_SUCCESS
;
}
static
void
vlc_ToWave
(
WAVEFORMATEXTENSIBLE
*
restrict
wf
,
audio_sample_format_t
*
restrict
audio
)
{
...
...
@@ -389,6 +400,8 @@ static int Open(vlc_object_t *obj)
}
/* Get audio device according to policy */
var_Create
(
aout
,
"audio-device"
,
VLC_VAR_STRING
);
IMMDeviceEnumerator
*
devs
;
hr
=
CoCreateInstance
(
&
CLSID_MMDeviceEnumerator
,
NULL
,
CLSCTX_ALL
,
&
IID_IMMDeviceEnumerator
,
(
void
**
)
&
devs
);
...
...
@@ -398,9 +411,26 @@ static int Open(vlc_object_t *obj)
goto
error
;
}
IMMDevice
*
dev
;
// Without configuration item, the variable must be created explicitly.
var_Create
(
aout
,
"wasapi-audio-device"
,
VLC_VAR_STRING
);
LPWSTR
devid
=
var_InheritWide
(
aout
,
"wasapi-audio-device"
);
var_Destroy
(
aout
,
"wasapi-audio-device"
);
IMMDevice
*
dev
=
NULL
;
if
(
devid
!=
NULL
)
{
msg_Dbg
(
aout
,
"using selected device %ls"
,
devid
);
hr
=
IMMDeviceEnumerator_GetDevice
(
devs
,
devid
,
&
dev
);
if
(
FAILED
(
hr
))
msg_Warn
(
aout
,
"cannot get audio endpoint (error 0x%lx)"
,
hr
);
free
(
devid
);
}
if
(
dev
==
NULL
)
{
msg_Dbg
(
aout
,
"using default device"
);
hr
=
IMMDeviceEnumerator_GetDefaultAudioEndpoint
(
devs
,
eRender
,
eConsole
,
&
dev
);
}
IMMDeviceEnumerator_Release
(
devs
);
if
(
FAILED
(
hr
))
{
...
...
@@ -408,12 +438,12 @@ static int Open(vlc_object_t *obj)
goto
error
;
}
LPWSTR
str
;
hr
=
IMMDevice_GetId
(
dev
,
&
str
);
hr
=
IMMDevice_GetId
(
dev
,
&
devid
);
if
(
SUCCEEDED
(
hr
))
{
msg_Dbg
(
aout
,
"using device %ls"
,
str
);
CoTaskMemFree
(
str
);
msg_Dbg
(
aout
,
"using device %ls"
,
devid
);
var_SetWide
(
aout
,
"audio-device"
,
devid
);
CoTaskMemFree
(
devid
);
}
hr
=
IMMDevice_Activate
(
dev
,
&
IID_IAudioClient
,
CLSCTX_ALL
,
NULL
,
...
...
@@ -482,6 +512,8 @@ static int Open(vlc_object_t *obj)
if
(
sys
->
render
==
NULL
)
goto
error
;
Leave
();
aout
->
format
=
format
;
aout
->
pf_play
=
Play
;
aout
->
pf_pause
=
Pause
;
...
...
@@ -491,7 +523,8 @@ static int Open(vlc_object_t *obj)
aout
->
volume_set
=
SimpleVolumeSet
;
aout
->
mute_set
=
SimpleMuteSet
;
}
Leave
();
var_AddCallback
(
aout
,
"audio-device"
,
DeviceChanged
,
NULL
);
return
VLC_SUCCESS
;
error:
if
(
sys
->
done
!=
NULL
)
...
...
@@ -501,6 +534,7 @@ error:
if
(
sys
->
client
!=
NULL
)
IAudioClient_Release
(
sys
->
client
);
Leave
();
var_Destroy
(
aout
,
"audio-device"
);
free
(
sys
);
return
VLC_EGENERIC
;
}
...
...
@@ -517,6 +551,9 @@ static void Close (vlc_object_t *obj)
IAudioClient_Release
(
sys
->
client
);
Leave
();
var_DelCallback
(
aout
,
"audio-device"
,
DeviceChanged
,
NULL
);
var_Destroy
(
aout
,
"audio-device"
);
CloseHandle
(
sys
->
done
);
CloseHandle
(
sys
->
ready
);
free
(
sys
);
...
...
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