Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
4f42f236
Commit
4f42f236
authored
Dec 04, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mmdevice: simplify volume & mute handling
Apparently, there is no need for COM to do that.
parent
6c8ed420
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
41 deletions
+34
-41
modules/audio_output/mmdevice.c
modules/audio_output/mmdevice.c
+34
-41
No files found.
modules/audio_output/mmdevice.c
View file @
4f42f236
...
...
@@ -87,8 +87,6 @@ struct aout_sys_t
bool
killed
;
/**< Flag to terminate the thread */
bool
running
;
/**< Whether the thread is running */
int8_t
mute
;
/**< Requested mute state or negative value */
float
volume
;
/**< Requested volume or negative value */
};
static
int
vlc_FromHR
(
audio_output_t
*
aout
,
HRESULT
hr
)
...
...
@@ -138,24 +136,50 @@ static void Flush(audio_output_t *aout, bool wait)
static
int
VolumeSet
(
audio_output_t
*
aout
,
float
vol
)
{
aout_sys_t
*
sys
=
aout
->
sys
;
ISimpleAudioVolume
*
volume
;
HRESULT
hr
;
EnterCriticalSection
(
&
sys
->
lock
);
sys
->
volume
=
vol
;
LeaveCriticalSection
(
&
sys
->
lock
);
hr
=
IAudioSessionManager_GetSimpleAudioVolume
(
sys
->
manager
,
&
GUID_VLC_AUD_OUT
,
FALSE
,
&
volume
);
if
(
FAILED
(
hr
))
{
msg_Err
(
aout
,
"cannot get simple volume (error 0x%lx)"
,
hr
);
return
-
1
;
}
WakeConditionVariable
(
&
sys
->
request_wait
);
hr
=
ISimpleAudioVolume_SetMasterVolume
(
volume
,
vol
,
NULL
);
ISimpleAudioVolume_Release
(
volume
);
if
(
FAILED
(
hr
))
{
msg_Err
(
aout
,
"cannot set volume (error 0x%lx)"
,
hr
);
return
-
1
;
}
return
0
;
}
static
int
MuteSet
(
audio_output_t
*
aout
,
bool
mute
)
{
aout_sys_t
*
sys
=
aout
->
sys
;
ISimpleAudioVolume
*
volume
;
HRESULT
hr
;
EnterCriticalSection
(
&
sys
->
lock
);
sys
->
mute
=
mute
;
LeaveCriticalSection
(
&
sys
->
lock
);
hr
=
IAudioSessionManager_GetSimpleAudioVolume
(
sys
->
manager
,
&
GUID_VLC_AUD_OUT
,
FALSE
,
&
volume
);
if
(
FAILED
(
hr
))
{
msg_Err
(
aout
,
"cannot get simple volume (error 0x%lx)"
,
hr
);
return
-
1
;
}
WakeConditionVariable
(
&
sys
->
request_wait
);
hr
=
ISimpleAudioVolume_SetMute
(
volume
,
mute
?
TRUE
:
FALSE
,
NULL
);
ISimpleAudioVolume_Release
(
volume
);
if
(
FAILED
(
hr
))
{
msg_Err
(
aout
,
"cannot set mute (error 0x%lx)"
,
hr
);
return
-
1
;
}
return
0
;
}
...
...
@@ -411,7 +435,6 @@ static void MMThread(void *data)
audio_output_t
*
aout
=
data
;
aout_sys_t
*
sys
=
aout
->
sys
;
IAudioSessionControl
*
control
;
ISimpleAudioVolume
*
volume
;
HRESULT
hr
;
Enter
();
...
...
@@ -432,42 +455,14 @@ static void MMThread(void *data)
&
sys
->
session_events
);
}
hr
=
IAudioSessionManager_GetSimpleAudioVolume
(
sys
->
manager
,
&
GUID_VLC_AUD_OUT
,
FALSE
,
&
volume
);
if
(
FAILED
(
hr
))
msg_Err
(
aout
,
"cannot get simple volume (error 0x%lx)"
,
hr
);
EnterCriticalSection
(
&
sys
->
lock
);
sys
->
running
=
true
;
WakeConditionVariable
(
&
sys
->
reply_wait
);
while
(
!
sys
->
killed
)
{
/* Update volume */
if
(
sys
->
volume
>=
0
.
f
)
{
hr
=
ISimpleAudioVolume_SetMasterVolume
(
volume
,
sys
->
volume
,
NULL
);
if
(
FAILED
(
hr
))
msg_Err
(
aout
,
"cannot set volume (error 0x%lx)"
,
hr
);
sys
->
volume
=
-
1
.
f
;
}
/* Update mute state */
if
(
sys
->
mute
>=
0
)
{
hr
=
ISimpleAudioVolume_SetMute
(
volume
,
sys
->
mute
,
NULL
);
if
(
FAILED
(
hr
))
msg_Err
(
aout
,
"cannot set mute (error 0x%lx)"
,
hr
);
sys
->
mute
=
-
1
;
}
SleepConditionVariableCS
(
&
sys
->
request_wait
,
&
sys
->
lock
,
INFINITE
);
}
LeaveCriticalSection
(
&
sys
->
lock
);
if
(
volume
!=
NULL
)
ISimpleAudioVolume_Release
(
volume
);
if
(
control
!=
NULL
)
{
IAudioSessionControl_UnregisterAudioSessionNotification
(
control
,
...
...
@@ -532,8 +527,6 @@ static int Open(vlc_object_t *obj)
InitializeConditionVariable
(
&
sys
->
reply_wait
);
sys
->
killed
=
false
;
sys
->
running
=
false
;
sys
->
volume
=
-
1
.
f
;
sys
->
mute
=
-
1
;
hr
=
CoCreateInstance
(
&
CLSID_MMDeviceEnumerator
,
NULL
,
CLSCTX_ALL
,
&
IID_IMMDeviceEnumerator
,
&
pv
);
...
...
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