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
f8f95e2d
Commit
f8f95e2d
authored
Nov 06, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OutputControl: reduce the number of OutputThread wakeups
Wake up the OutputThread only if it hasn't already been woken up and if it isn't already in the playback loop.
parent
77c63511
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
2 deletions
+30
-2
OutputControl.cxx
src/OutputControl.cxx
+4
-1
OutputInit.cxx
src/OutputInit.cxx
+2
-0
OutputInternal.hxx
src/OutputInternal.hxx
+15
-0
OutputThread.cxx
src/OutputThread.cxx
+9
-1
No files found.
src/OutputControl.cxx
View file @
f8f95e2d
...
...
@@ -248,8 +248,11 @@ audio_output_play(struct audio_output *ao)
assert
(
ao
->
allow_play
);
if
(
audio_output_is_open
(
ao
))
if
(
audio_output_is_open
(
ao
)
&&
!
ao
->
in_playback_loop
&&
!
ao
->
woken_for_play
)
{
ao
->
woken_for_play
=
true
;
ao
->
cond
.
signal
();
}
}
void
audio_output_pause
(
struct
audio_output
*
ao
)
...
...
src/OutputInit.cxx
View file @
f8f95e2d
...
...
@@ -171,6 +171,8 @@ ao_base_init(struct audio_output *ao,
ao
->
open
=
false
;
ao
->
pause
=
false
;
ao
->
allow_play
=
true
;
ao
->
in_playback_loop
=
false
;
ao
->
woken_for_play
=
false
;
ao
->
fail_timer
=
nullptr
;
/* set up the filter chain */
...
...
src/OutputInternal.hxx
View file @
f8f95e2d
...
...
@@ -128,6 +128,21 @@ struct audio_output {
bool
allow_play
;
/**
* True while the OutputThread is inside ao_play(). This
* means the PlayerThread does not need to wake up the
* OutputThread when new chunks are added to the MusicPipe,
* because the OutputThread is already watching that.
*/
bool
in_playback_loop
;
/**
* Has the OutputThread been woken up to play more chunks?
* This is set by audio_output_play() and reset by ao_play()
* to reduce the number of duplicate wakeups.
*/
bool
woken_for_play
;
/**
* If not nullptr, the device has failed, and this timer is used
* to estimate how long it should stay disabled (unless
* explicitly reopened with "play").
...
...
src/OutputThread.cxx
View file @
f8f95e2d
...
...
@@ -510,6 +510,9 @@ ao_play(struct audio_output *ao)
ao
->
chunk_finished
=
false
;
assert
(
!
ao
->
in_playback_loop
);
ao
->
in_playback_loop
=
true
;
while
(
chunk
!=
nullptr
&&
ao
->
command
==
AO_COMMAND_NONE
)
{
assert
(
!
ao
->
chunk_finished
);
...
...
@@ -525,6 +528,9 @@ ao_play(struct audio_output *ao)
chunk
=
chunk
->
next
;
}
assert
(
ao
->
in_playback_loop
);
ao
->
in_playback_loop
=
false
;
ao
->
chunk_finished
=
true
;
ao
->
mutex
.
unlock
();
...
...
@@ -656,8 +662,10 @@ audio_output_task(void *arg)
chunks in the pipe */
continue
;
if
(
ao
->
command
==
AO_COMMAND_NONE
)
if
(
ao
->
command
==
AO_COMMAND_NONE
)
{
ao
->
woken_for_play
=
false
;
ao
->
cond
.
wait
(
ao
->
mutex
);
}
}
}
...
...
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