Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
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
Иван Мажукин
mpd
Commits
3010d182
Commit
3010d182
authored
Jun 08, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/Internal: move "really_enabled" flag to class AudioOutputControl
parent
a72a02f0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
22 deletions
+22
-22
Control.cxx
src/output/Control.cxx
+5
-5
Control.hxx
src/output/Control.hxx
+6
-0
Internal.hxx
src/output/Internal.hxx
+0
-6
Thread.cxx
src/output/Thread.cxx
+11
-11
No files found.
src/output/Control.cxx
View file @
3010d182
...
...
@@ -132,7 +132,7 @@ AudioOutputControl::EnableAsync()
/* don't bother to start the thread now if the
device doesn't even have a enable() method;
just assign the variable and we're done */
output
->
really_enabled
=
true
;
really_enabled
=
true
;
return
;
}
...
...
@@ -147,11 +147,11 @@ AudioOutputControl::DisableAsync() noexcept
{
if
(
!
thread
.
IsDefined
())
{
if
(
output
->
plugin
.
disable
==
nullptr
)
output
->
really_enabled
=
false
;
really_enabled
=
false
;
else
/* if there's no thread yet, the device cannot
be enabled */
assert
(
!
output
->
really_enabled
);
assert
(
!
really_enabled
);
return
;
}
...
...
@@ -162,7 +162,7 @@ AudioOutputControl::DisableAsync() noexcept
void
AudioOutputControl
::
EnableDisableAsync
()
{
if
(
enabled
==
output
->
really_enabled
)
if
(
enabled
==
really_enabled
)
return
;
if
(
enabled
)
...
...
@@ -233,7 +233,7 @@ AudioOutputControl::LockUpdate(const AudioFormat audio_format,
{
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
if
(
enabled
&&
output
->
really_enabled
)
{
if
(
enabled
&&
really_enabled
)
{
if
(
force
||
!
fail_timer
.
IsDefined
()
||
fail_timer
.
Check
(
REOPEN_AFTER
*
1000
))
{
return
Open
(
audio_format
,
mp
);
...
...
src/output/Control.hxx
View file @
3010d182
...
...
@@ -144,6 +144,12 @@ class AudioOutputControl {
bool
enabled
=
true
;
/**
* Is this device actually enabled, i.e. the "enable" method
* has succeeded?
*/
bool
really_enabled
=
false
;
/**
* Is the device paused? i.e. the output thread is in the
* ao_pause() loop.
*/
...
...
src/output/Internal.hxx
View file @
3010d182
...
...
@@ -54,12 +54,6 @@ struct AudioOutput {
Mixer
*
mixer
=
nullptr
;
/**
* Is this device actually enabled, i.e. the "enable" method
* has succeeded?
*/
bool
really_enabled
=
false
;
/**
* Is the device (already) open and functional?
*
* This attribute may only be modified by the output thread.
...
...
src/output/Thread.cxx
View file @
3010d182
...
...
@@ -60,9 +60,6 @@ AudioOutputControl::CommandFinished() noexcept
inline
void
AudioOutput
::
Enable
()
{
if
(
really_enabled
)
return
;
try
{
const
ScopeUnlock
unlock
(
mutex
);
ao_plugin_enable
(
*
this
);
...
...
@@ -70,19 +67,13 @@ AudioOutput::Enable()
std
::
throw_with_nested
(
FormatRuntimeError
(
"Failed to enable output
\"
%s
\"
[%s]"
,
name
,
plugin
.
name
));
}
really_enabled
=
true
;
}
inline
void
AudioOutput
::
Disable
()
noexcept
{
if
(
really_enabled
)
{
really_enabled
=
false
;
const
ScopeUnlock
unlock
(
mutex
);
ao_plugin_disable
(
*
this
);
}
const
ScopeUnlock
unlock
(
mutex
);
ao_plugin_disable
(
*
this
);
}
void
...
...
@@ -200,10 +191,15 @@ AudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format)
inline
bool
AudioOutputControl
::
InternalEnable
()
noexcept
{
if
(
really_enabled
)
/* already enabled */
return
true
;
last_error
=
nullptr
;
try
{
output
->
Enable
();
really_enabled
=
true
;
return
true
;
}
catch
(
const
std
::
runtime_error
&
e
)
{
LogError
(
e
);
...
...
@@ -216,9 +212,13 @@ AudioOutputControl::InternalEnable() noexcept
inline
void
AudioOutputControl
::
InternalDisable
()
noexcept
{
if
(
!
really_enabled
)
return
;
if
(
output
->
open
)
output
->
Close
(
false
);
really_enabled
=
false
;
output
->
Disable
();
}
...
...
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