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
ece59710
Commit
ece59710
authored
Dec 14, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/Multiple: move Wait() to struct PlayerControl
Eliminate a dependency from MultipleOutputs on PlayerControl.
parent
7c6b0d5c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
29 deletions
+32
-29
MultipleOutputs.cxx
src/output/MultipleOutputs.cxx
+0
-17
MultipleOutputs.hxx
src/output/MultipleOutputs.hxx
+0
-10
Control.cxx
src/player/Control.cxx
+13
-0
Control.hxx
src/player/Control.hxx
+17
-0
Thread.cxx
src/player/Thread.cxx
+2
-2
No files found.
src/output/MultipleOutputs.cxx
View file @
ece59710
...
...
@@ -19,7 +19,6 @@
#include "config.h"
#include "MultipleOutputs.hxx"
#include "player/Control.hxx"
#include "Internal.hxx"
#include "Domain.hxx"
#include "MusicBuffer.hxx"
...
...
@@ -331,22 +330,6 @@ MultipleOutputs::Check()
return
0
;
}
bool
MultipleOutputs
::
Wait
(
PlayerControl
&
pc
,
unsigned
threshold
)
{
pc
.
Lock
();
if
(
Check
()
<
threshold
)
{
pc
.
Unlock
();
return
true
;
}
pc
.
Wait
();
pc
.
Unlock
();
return
Check
()
<
threshold
;
}
void
MultipleOutputs
::
Pause
()
{
...
...
src/output/MultipleOutputs.hxx
View file @
ece59710
...
...
@@ -160,16 +160,6 @@ public:
unsigned
Check
();
/**
* Checks if the size of the #MusicPipe is below the #threshold. If
* not, it attempts to synchronize with all output threads, and waits
* until another #MusicChunk is finished.
*
* @param threshold the maximum number of chunks in the pipe
* @return true if there are less than #threshold chunks in the pipe
*/
bool
Wait
(
PlayerControl
&
pc
,
unsigned
threshold
);
/**
* Puts all audio outputs into pause mode. Most implementations will
* simply close it then.
*/
...
...
src/player/Control.cxx
View file @
ece59710
...
...
@@ -21,6 +21,7 @@
#include "Control.hxx"
#include "Idle.hxx"
#include "DetachedSong.hxx"
#include "output/MultipleOutputs.hxx"
#include <algorithm>
...
...
@@ -46,6 +47,18 @@ PlayerControl::~PlayerControl()
delete
tagged_song
;
}
bool
PlayerControl
::
WaitOutputConsumed
(
unsigned
threshold
)
{
bool
result
=
outputs
.
Check
()
<
threshold
;
if
(
!
result
&&
command
==
PlayerCommand
::
NONE
)
{
Wait
();
result
=
outputs
.
Check
()
<
threshold
;
}
return
result
;
}
void
PlayerControl
::
Play
(
DetachedSong
*
song
)
{
...
...
src/player/Control.hxx
View file @
ece59710
...
...
@@ -280,6 +280,23 @@ struct PlayerControl {
CommandFinished
();
}
/**
* Checks if the size of the #MusicPipe is below the #threshold. If
* not, it attempts to synchronize with all output threads, and waits
* until another #MusicChunk is finished.
*
* Caller must lock the mutex.
*
* @param threshold the maximum number of chunks in the pipe
* @return true if there are less than #threshold chunks in the pipe
*/
bool
WaitOutputConsumed
(
unsigned
threshold
);
bool
LockWaitOutputConsumed
(
unsigned
threshold
)
{
const
ScopeLock
protect
(
mutex
);
return
WaitOutputConsumed
(
threshold
);
}
private
:
/**
* Wait for the command to be finished by the player thread.
...
...
src/player/Thread.cxx
View file @
ece59710
...
...
@@ -500,7 +500,7 @@ Player::CheckDecoderStartup()
pc
.
Unlock
();
if
(
output_open
&&
!
pc
.
outputs
.
Wait
(
pc
,
1
))
!
pc
.
LockWaitOutputConsumed
(
1
))
/* the output devices havn't finished playing
all chunks yet - wait for that */
return
true
;
...
...
@@ -813,7 +813,7 @@ play_chunk(PlayerControl &pc,
inline
bool
Player
::
PlayNextChunk
()
{
if
(
!
pc
.
outputs
.
Wait
(
pc
,
64
))
if
(
!
pc
.
LockWaitOutputConsumed
(
64
))
/* the output pipe is still large enough, don't send
another chunk */
return
true
;
...
...
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