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
efde78db
Commit
efde78db
authored
Feb 15, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/Thread: skip drain calls if there is no data to be played
Keep track of whether there is data being played, and don't call AudioOutput::Drain() after Cancel() has been called already.
parent
f1b8bcd6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
Control.hxx
src/output/Control.hxx
+8
-0
Thread.cxx
src/output/Thread.cxx
+13
-1
No files found.
src/output/Control.hxx
View file @
efde78db
...
@@ -182,6 +182,14 @@ class AudioOutputControl {
...
@@ -182,6 +182,14 @@ class AudioOutputControl {
bool
open
=
false
;
bool
open
=
false
;
/**
/**
* Is the device currently playing, i.e. is its buffer
* (likely) non-empty? If not, then it will never be drained.
*
* This field is only valid while the output is open.
*/
bool
playing
;
/**
* Is the device paused? i.e. the output thread is in the
* Is the device paused? i.e. the output thread is in the
* ao_pause() loop.
* ao_pause() loop.
*/
*/
...
...
src/output/Thread.cxx
View file @
efde78db
...
@@ -53,7 +53,7 @@ AudioOutputControl::InternalOpen2(const AudioFormat in_audio_format)
...
@@ -53,7 +53,7 @@ AudioOutputControl::InternalOpen2(const AudioFormat in_audio_format)
if
(
open
&&
cf
!=
output
->
filter_audio_format
)
if
(
open
&&
cf
!=
output
->
filter_audio_format
)
/* if the filter's output format changes, the output
/* if the filter's output format changes, the output
must be reopened as well */
must be reopened as well */
InternalCloseOutput
(
true
);
InternalCloseOutput
(
playing
);
output
->
filter_audio_format
=
cf
;
output
->
filter_audio_format
=
cf
;
...
@@ -64,6 +64,7 @@ AudioOutputControl::InternalOpen2(const AudioFormat in_audio_format)
...
@@ -64,6 +64,7 @@ AudioOutputControl::InternalOpen2(const AudioFormat in_audio_format)
}
}
open
=
true
;
open
=
true
;
playing
=
false
;
}
else
if
(
in_audio_format
!=
output
->
out_audio_format
)
{
}
else
if
(
in_audio_format
!=
output
->
out_audio_format
)
{
/* reconfigure the final ConvertFilter for its new
/* reconfigure the final ConvertFilter for its new
input AudioFormat */
input AudioFormat */
...
@@ -285,6 +286,9 @@ AudioOutputControl::PlayChunk(std::unique_lock<Mutex> &lock) noexcept
...
@@ -285,6 +286,9 @@ AudioOutputControl::PlayChunk(std::unique_lock<Mutex> &lock) noexcept
assert
(
nbytes
%
output
->
out_audio_format
.
GetFrameSize
()
==
0
);
assert
(
nbytes
%
output
->
out_audio_format
.
GetFrameSize
()
==
0
);
source
.
ConsumeData
(
nbytes
);
source
.
ConsumeData
(
nbytes
);
/* there's data to be drained from now on */
playing
=
true
;
}
}
return
true
;
return
true
;
...
@@ -371,6 +375,9 @@ AudioOutputControl::InternalPause(std::unique_lock<Mutex> &lock) noexcept
...
@@ -371,6 +375,9 @@ AudioOutputControl::InternalPause(std::unique_lock<Mutex> &lock) noexcept
}
}
skip_delay
=
true
;
skip_delay
=
true
;
/* ignore drain commands until we got something new to play */
playing
=
false
;
}
}
static
void
static
void
...
@@ -390,6 +397,10 @@ PlayFull(FilteredAudioOutput &output, ConstBuffer<void> _buffer)
...
@@ -390,6 +397,10 @@ PlayFull(FilteredAudioOutput &output, ConstBuffer<void> _buffer)
inline
void
inline
void
AudioOutputControl
::
InternalDrain
()
noexcept
AudioOutputControl
::
InternalDrain
()
noexcept
{
{
/* after this method finishes, there's nothing left to be
drained */
playing
=
false
;
try
{
try
{
/* flush the filter and play its remaining output */
/* flush the filter and play its remaining output */
...
@@ -518,6 +529,7 @@ AudioOutputControl::Task() noexcept
...
@@ -518,6 +529,7 @@ AudioOutputControl::Task() noexcept
source
.
Cancel
();
source
.
Cancel
();
if
(
open
)
{
if
(
open
)
{
playing
=
false
;
const
ScopeUnlock
unlock
(
mutex
);
const
ScopeUnlock
unlock
(
mutex
);
output
->
Cancel
();
output
->
Cancel
();
}
}
...
...
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