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
2ec94c04
Commit
2ec94c04
authored
Sep 23, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
player/Control: start thread on demand
Keep MPD's footprint small until playback is requested.
parent
bf372e3e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
14 deletions
+21
-14
Main.cxx
src/Main.cxx
+0
-3
PartitionCommands.cxx
src/command/PartitionCommands.cxx
+0
-2
Control.cxx
src/player/Control.cxx
+21
-2
Control.hxx
src/player/Control.hxx
+0
-7
No files found.
src/Main.cxx
View file @
2ec94c04
...
...
@@ -577,9 +577,6 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config)
ZeroconfInit
(
raw_config
,
instance
->
event_loop
);
for
(
auto
&
partition
:
instance
->
partitions
)
partition
.
pc
.
StartThread
();
#ifdef ENABLE_DATABASE
if
(
create_db
)
{
/* the database failed to load: recreate the
...
...
src/command/PartitionCommands.cxx
View file @
2ec94c04
...
...
@@ -109,8 +109,6 @@ handle_newpartition(Client &client, Request request, Response &response)
ReplayGainConfig
(),
partition
.
pc
);
partition
.
UpdateEffectiveReplayGainMode
();
partition
.
pc
.
StartThread
();
partition
.
pc
.
LockUpdateAudio
();
instance
.
EmitIdle
(
IDLE_PARTITION
);
...
...
src/player/Control.cxx
View file @
2ec94c04
...
...
@@ -60,6 +60,9 @@ PlayerControl::WaitOutputConsumed(unsigned threshold) noexcept
void
PlayerControl
::
Play
(
std
::
unique_ptr
<
DetachedSong
>
song
)
{
if
(
!
thread
.
IsDefined
())
thread
.
Start
();
assert
(
song
!=
nullptr
);
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
...
...
@@ -74,6 +77,8 @@ PlayerControl::Play(std::unique_ptr<DetachedSong> song)
void
PlayerControl
::
LockCancel
()
noexcept
{
assert
(
thread
.
IsDefined
());
LockSynchronousCommand
(
PlayerCommand
::
CANCEL
);
assert
(
next_song
==
nullptr
);
}
...
...
@@ -81,6 +86,9 @@ PlayerControl::LockCancel() noexcept
void
PlayerControl
::
LockStop
()
noexcept
{
if
(
!
thread
.
IsDefined
())
return
;
LockSynchronousCommand
(
PlayerCommand
::
CLOSE_AUDIO
);
assert
(
next_song
==
nullptr
);
...
...
@@ -90,13 +98,17 @@ PlayerControl::LockStop() noexcept
void
PlayerControl
::
LockUpdateAudio
()
noexcept
{
if
(
!
thread
.
IsDefined
())
return
;
LockSynchronousCommand
(
PlayerCommand
::
UPDATE_AUDIO
);
}
void
PlayerControl
::
Kill
()
noexcept
{
assert
(
thread
.
IsDefined
());
if
(
!
thread
.
IsDefined
())
return
;
LockSynchronousCommand
(
PlayerCommand
::
EXIT
);
thread
.
Join
();
...
...
@@ -123,6 +135,9 @@ PlayerControl::LockPause() noexcept
void
PlayerControl
::
LockSetPause
(
bool
pause_flag
)
noexcept
{
if
(
!
thread
.
IsDefined
())
return
;
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
switch
(
state
)
{
...
...
@@ -154,7 +169,7 @@ PlayerControl::LockGetStatus() noexcept
PlayerStatus
status
;
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
if
(
!
occupied
)
if
(
!
occupied
&&
thread
.
IsDefined
()
)
SynchronousCommand
(
PlayerCommand
::
REFRESH
);
status
.
state
=
state
;
...
...
@@ -216,6 +231,7 @@ PlayerControl::LockReadTaggedSong() noexcept
void
PlayerControl
::
LockEnqueueSong
(
std
::
unique_ptr
<
DetachedSong
>
song
)
noexcept
{
assert
(
thread
.
IsDefined
());
assert
(
song
!=
nullptr
);
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
...
...
@@ -270,6 +286,9 @@ PlayerControl::SeekLocked(std::unique_ptr<DetachedSong> song, SongTime t)
void
PlayerControl
::
LockSeek
(
std
::
unique_ptr
<
DetachedSong
>
song
,
SongTime
t
)
{
if
(
!
thread
.
IsDefined
())
thread
.
Start
();
assert
(
song
!=
nullptr
);
{
...
...
src/player/Control.hxx
View file @
2ec94c04
...
...
@@ -239,13 +239,6 @@ public:
const
ReplayGainConfig
&
_replay_gain_config
)
noexcept
;
~
PlayerControl
()
noexcept
;
/**
* Throws on error.
*/
void
StartThread
()
{
thread
.
Start
();
}
void
Kill
()
noexcept
;
/**
...
...
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