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
0e0bc797
Commit
0e0bc797
authored
Sep 23, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
player/Control: add LockGetSyncInfo()
parent
8c638c50
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
16 deletions
+16
-16
Control.hxx
src/player/Control.hxx
+11
-4
Playlist.cxx
src/queue/Playlist.cxx
+5
-12
No files found.
src/player/Control.hxx
View file @
0e0bc797
...
...
@@ -434,6 +434,17 @@ public:
return
state
;
}
struct
SyncInfo
{
PlayerState
state
;
bool
has_next_song
;
};
gcc_pure
SyncInfo
LockGetSyncInfo
()
const
noexcept
{
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
return
{
state
,
next_song
!=
nullptr
};
}
private
:
/**
* Set the error. Discards any previous error condition.
...
...
@@ -527,10 +538,6 @@ public:
*/
void
LockEnqueueSong
(
std
::
unique_ptr
<
DetachedSong
>
song
)
noexcept
;
bool
HasNextSong
()
const
noexcept
{
return
next_song
!=
nullptr
;
}
/**
* Makes the player thread seek the specified song to a position.
*
...
...
src/queue/Playlist.cxx
View file @
0e0bc797
...
...
@@ -91,7 +91,7 @@ playlist::SongStarted()
inline
void
playlist
::
QueuedSongStarted
(
PlayerControl
&
pc
)
{
assert
(
!
pc
.
HasNextSong
()
);
assert
(
!
pc
.
LockGetSyncInfo
().
has_next_song
);
assert
(
queued
>=
-
1
);
assert
(
current
>=
0
);
...
...
@@ -195,12 +195,9 @@ playlist::SyncWithPlayer(PlayerControl &pc)
playing anymore; ignore the event */
return
;
pc
.
Lock
();
const
PlayerState
pc_state
=
pc
.
GetState
();
bool
pc_has_next_song
=
pc
.
HasNextSong
();
pc
.
Unlock
();
const
auto
i
=
pc
.
LockGetSyncInfo
();
if
(
pc_
state
==
PlayerState
::
STOP
)
if
(
i
.
state
==
PlayerState
::
STOP
)
/* the player thread has stopped: check if playback
should be restarted with the next song. That can
happen if the playlist isn't filling the queue fast
...
...
@@ -209,16 +206,12 @@ playlist::SyncWithPlayer(PlayerControl &pc)
else
{
/* check if the player thread has already started
playing the queued song */
if
(
!
pc_
has_next_song
&&
queued
!=
-
1
)
if
(
!
i
.
has_next_song
&&
queued
!=
-
1
)
QueuedSongStarted
(
pc
);
pc
.
Lock
();
pc_has_next_song
=
pc
.
HasNextSong
();
pc
.
Unlock
();
/* make sure the queued song is always set (if
possible) */
if
(
!
pc
_
has_next_song
&&
queued
<
0
)
if
(
!
pc
.
LockGetSyncInfo
().
has_next_song
&&
queued
<
0
)
UpdateQueuedSong
(
pc
,
nullptr
);
}
}
...
...
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