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
5e93c050
Commit
5e93c050
authored
Nov 11, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
queue/Playlist: seek methods return bool/Error instead of PlaylistResult
parent
0f4f04ea
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
77 additions
and
47 deletions
+77
-47
Partition.hxx
src/Partition.hxx
+9
-7
PlayerCommands.cxx
src/command/PlayerCommands.cxx
+12
-9
Playlist.hxx
src/queue/Playlist.hxx
+13
-9
PlaylistControl.cxx
src/queue/PlaylistControl.cxx
+41
-21
PlaylistState.cxx
src/queue/PlaylistState.cxx
+2
-1
No files found.
src/Partition.hxx
View file @
5e93c050
...
@@ -142,17 +142,19 @@ struct Partition final : private PlayerListener, private MixerListener {
...
@@ -142,17 +142,19 @@ struct Partition final : private PlayerListener, private MixerListener {
return
playlist
.
PlayPrevious
(
pc
);
return
playlist
.
PlayPrevious
(
pc
);
}
}
PlaylistResult
SeekSongPosition
(
unsigned
song_position
,
bool
SeekSongPosition
(
unsigned
song_position
,
SongTime
seek_time
)
{
SongTime
seek_time
,
Error
&
error
)
{
return
playlist
.
SeekSongPosition
(
pc
,
song_position
,
seek_time
);
return
playlist
.
SeekSongPosition
(
pc
,
song_position
,
seek_time
,
error
);
}
}
PlaylistResult
SeekSongId
(
unsigned
song_id
,
SongTime
seek_time
)
{
bool
SeekSongId
(
unsigned
song_id
,
SongTime
seek_time
,
Error
&
error
)
{
return
playlist
.
SeekSongId
(
pc
,
song_id
,
seek_time
);
return
playlist
.
SeekSongId
(
pc
,
song_id
,
seek_time
,
error
);
}
}
PlaylistResult
SeekCurrent
(
SignedSongTime
seek_time
,
bool
relative
)
{
bool
SeekCurrent
(
SignedSongTime
seek_time
,
bool
relative
,
return
playlist
.
SeekCurrent
(
pc
,
seek_time
,
relative
);
Error
&
error
)
{
return
playlist
.
SeekCurrent
(
pc
,
seek_time
,
relative
,
error
);
}
}
void
SetRepeat
(
bool
new_value
)
{
void
SetRepeat
(
bool
new_value
)
{
...
...
src/command/PlayerCommands.cxx
View file @
5e93c050
...
@@ -296,9 +296,10 @@ handle_seek(Client &client, Request args, Response &r)
...
@@ -296,9 +296,10 @@ handle_seek(Client &client, Request args, Response &r)
if
(
!
args
.
Parse
(
0
,
song
,
r
)
||
!
args
.
Parse
(
1
,
seek_time
,
r
))
if
(
!
args
.
Parse
(
0
,
song
,
r
)
||
!
args
.
Parse
(
1
,
seek_time
,
r
))
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
PlaylistResult
result
=
Error
error
;
client
.
partition
.
SeekSongPosition
(
song
,
seek_time
);
return
client
.
partition
.
SeekSongPosition
(
song
,
seek_time
,
error
)
return
print_playlist_result
(
r
,
result
);
?
CommandResult
::
OK
:
print_error
(
r
,
error
);
}
}
CommandResult
CommandResult
...
@@ -311,9 +312,10 @@ handle_seekid(Client &client, Request args, Response &r)
...
@@ -311,9 +312,10 @@ handle_seekid(Client &client, Request args, Response &r)
if
(
!
args
.
Parse
(
1
,
seek_time
,
r
))
if
(
!
args
.
Parse
(
1
,
seek_time
,
r
))
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
PlaylistResult
result
=
Error
error
;
client
.
partition
.
SeekSongId
(
id
,
seek_time
);
return
client
.
partition
.
SeekSongId
(
id
,
seek_time
,
error
)
return
print_playlist_result
(
r
,
result
);
?
CommandResult
::
OK
:
print_error
(
r
,
error
);
}
}
CommandResult
CommandResult
...
@@ -325,9 +327,10 @@ handle_seekcur(Client &client, Request args, Response &r)
...
@@ -325,9 +327,10 @@ handle_seekcur(Client &client, Request args, Response &r)
if
(
!
ParseCommandArg
(
r
,
seek_time
,
p
))
if
(
!
ParseCommandArg
(
r
,
seek_time
,
p
))
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
PlaylistResult
result
=
Error
error
;
client
.
partition
.
SeekCurrent
(
seek_time
,
relative
);
return
client
.
partition
.
SeekCurrent
(
seek_time
,
relative
,
error
)
return
print_playlist_result
(
r
,
result
);
?
CommandResult
::
OK
:
print_error
(
r
,
error
);
}
}
CommandResult
CommandResult
...
...
src/queue/Playlist.hxx
View file @
5e93c050
...
@@ -280,16 +280,19 @@ public:
...
@@ -280,16 +280,19 @@ public:
void
PlayPrevious
(
PlayerControl
&
pc
);
void
PlayPrevious
(
PlayerControl
&
pc
);
PlaylistResult
SeekSongOrder
(
PlayerControl
&
pc
,
bool
SeekSongOrder
(
PlayerControl
&
pc
,
unsigned
song_order
,
unsigned
song_order
,
SongTime
seek_time
);
SongTime
seek_time
,
Error
&
error
);
PlaylistResult
SeekSongPosition
(
PlayerControl
&
pc
,
bool
SeekSongPosition
(
PlayerControl
&
pc
,
unsigned
song_position
,
unsigned
sonag_position
,
SongTime
seek_time
);
SongTime
seek_time
,
Error
&
error
);
PlaylistResult
SeekSongId
(
PlayerControl
&
pc
,
bool
SeekSongId
(
PlayerControl
&
pc
,
unsigned
song_id
,
SongTime
seek_time
);
unsigned
song_id
,
SongTime
seek_time
,
Error
&
error
);
/**
/**
* Seek within the current song. Fails if MPD is not currently
* Seek within the current song. Fails if MPD is not currently
...
@@ -299,8 +302,9 @@ public:
...
@@ -299,8 +302,9 @@ public:
* @param relative if true, then the specified time is relative to the
* @param relative if true, then the specified time is relative to the
* current position
* current position
*/
*/
PlaylistResult
SeekCurrent
(
PlayerControl
&
pc
,
bool
SeekCurrent
(
PlayerControl
&
pc
,
SignedSongTime
seek_time
,
bool
relative
);
SignedSongTime
seek_time
,
bool
relative
,
Error
&
error
);
bool
GetRepeat
()
const
{
bool
GetRepeat
()
const
{
return
queue
.
repeat
;
return
queue
.
repeat
;
...
...
src/queue/PlaylistControl.cxx
View file @
5e93c050
...
@@ -189,8 +189,9 @@ playlist::PlayPrevious(PlayerControl &pc)
...
@@ -189,8 +189,9 @@ playlist::PlayPrevious(PlayerControl &pc)
PlayOrder
(
pc
,
order
);
PlayOrder
(
pc
,
order
);
}
}
PlaylistResult
bool
playlist
::
SeekSongOrder
(
PlayerControl
&
pc
,
unsigned
i
,
SongTime
seek_time
)
playlist
::
SeekSongOrder
(
PlayerControl
&
pc
,
unsigned
i
,
SongTime
seek_time
,
Error
&
error
)
{
{
assert
(
queue
.
IsValidOrder
(
i
));
assert
(
queue
.
IsValidOrder
(
i
));
...
@@ -213,52 +214,71 @@ playlist::SeekSongOrder(PlayerControl &pc, unsigned i, SongTime seek_time)
...
@@ -213,52 +214,71 @@ playlist::SeekSongOrder(PlayerControl &pc, unsigned i, SongTime seek_time)
if
(
!
pc
.
LockSeek
(
new
DetachedSong
(
queue
.
GetOrder
(
i
)),
seek_time
))
{
if
(
!
pc
.
LockSeek
(
new
DetachedSong
(
queue
.
GetOrder
(
i
)),
seek_time
))
{
UpdateQueuedSong
(
pc
,
queued_song
);
UpdateQueuedSong
(
pc
,
queued_song
);
return
PlaylistResult
::
NOT_PLAYING
;
// TODO: fix error code
error
.
Set
(
playlist_domain
,
int
(
PlaylistResult
::
NOT_PLAYING
),
"Decoder failed to seek"
);
return
false
;
}
}
queued
=
-
1
;
queued
=
-
1
;
UpdateQueuedSong
(
pc
,
nullptr
);
UpdateQueuedSong
(
pc
,
nullptr
);
return
PlaylistResult
::
SUCCESS
;
return
true
;
}
}
PlaylistResult
bool
playlist
::
SeekSongPosition
(
PlayerControl
&
pc
,
unsigned
song
,
playlist
::
SeekSongPosition
(
PlayerControl
&
pc
,
unsigned
song
,
SongTime
seek_time
)
SongTime
seek_time
,
Error
&
error
)
{
{
if
(
!
queue
.
IsValidPosition
(
song
))
if
(
!
queue
.
IsValidPosition
(
song
))
{
return
PlaylistResult
::
BAD_RANGE
;
error
.
Set
(
playlist_domain
,
int
(
PlaylistResult
::
BAD_RANGE
),
"Bad range"
);
return
false
;
}
unsigned
i
=
queue
.
random
unsigned
i
=
queue
.
random
?
queue
.
PositionToOrder
(
song
)
?
queue
.
PositionToOrder
(
song
)
:
song
;
:
song
;
return
SeekSongOrder
(
pc
,
i
,
seek_time
);
return
SeekSongOrder
(
pc
,
i
,
seek_time
,
error
);
}
}
PlaylistResult
bool
playlist
::
SeekSongId
(
PlayerControl
&
pc
,
unsigned
id
,
SongTime
seek_time
)
playlist
::
SeekSongId
(
PlayerControl
&
pc
,
unsigned
id
,
SongTime
seek_time
,
Error
&
error
)
{
{
int
song
=
queue
.
IdToPosition
(
id
);
int
song
=
queue
.
IdToPosition
(
id
);
if
(
song
<
0
)
if
(
song
<
0
)
{
return
PlaylistResult
::
NO_SUCH_SONG
;
error
.
Set
(
playlist_domain
,
int
(
PlaylistResult
::
NO_SUCH_SONG
),
"No such song"
);
return
false
;
}
return
SeekSongPosition
(
pc
,
song
,
seek_time
);
return
SeekSongPosition
(
pc
,
song
,
seek_time
,
error
);
}
}
PlaylistResult
bool
playlist
::
SeekCurrent
(
PlayerControl
&
pc
,
playlist
::
SeekCurrent
(
PlayerControl
&
pc
,
SignedSongTime
seek_time
,
bool
relative
)
SignedSongTime
seek_time
,
bool
relative
,
Error
&
error
)
{
{
if
(
!
playing
)
if
(
!
playing
)
{
return
PlaylistResult
::
NOT_PLAYING
;
error
.
Set
(
playlist_domain
,
int
(
PlaylistResult
::
NOT_PLAYING
),
"Not playing"
);
return
false
;
}
if
(
relative
)
{
if
(
relative
)
{
const
auto
status
=
pc
.
LockGetStatus
();
const
auto
status
=
pc
.
LockGetStatus
();
if
(
status
.
state
!=
PlayerState
::
PLAY
&&
if
(
status
.
state
!=
PlayerState
::
PLAY
&&
status
.
state
!=
PlayerState
::
PAUSE
)
status
.
state
!=
PlayerState
::
PAUSE
)
{
return
PlaylistResult
::
NOT_PLAYING
;
error
.
Set
(
playlist_domain
,
int
(
PlaylistResult
::
NOT_PLAYING
),
"Not playing"
);
return
false
;
}
seek_time
+=
status
.
elapsed_time
;
seek_time
+=
status
.
elapsed_time
;
if
(
seek_time
.
IsNegative
())
if
(
seek_time
.
IsNegative
())
...
@@ -268,5 +288,5 @@ playlist::SeekCurrent(PlayerControl &pc,
...
@@ -268,5 +288,5 @@ playlist::SeekCurrent(PlayerControl &pc,
if
(
seek_time
.
IsNegative
())
if
(
seek_time
.
IsNegative
())
seek_time
=
SignedSongTime
::
zero
();
seek_time
=
SignedSongTime
::
zero
();
return
SeekSongOrder
(
pc
,
current
,
SongTime
(
seek_time
));
return
SeekSongOrder
(
pc
,
current
,
SongTime
(
seek_time
)
,
error
);
}
}
src/queue/PlaylistState.cxx
View file @
5e93c050
...
@@ -198,7 +198,8 @@ playlist_state_restore(const char *line, TextFile &file,
...
@@ -198,7 +198,8 @@ playlist_state_restore(const char *line, TextFile &file,
else
if
(
seek_time
.
count
()
==
0
)
else
if
(
seek_time
.
count
()
==
0
)
playlist
.
PlayPosition
(
pc
,
current
);
playlist
.
PlayPosition
(
pc
,
current
);
else
else
playlist
.
SeekSongPosition
(
pc
,
current
,
seek_time
);
playlist
.
SeekSongPosition
(
pc
,
current
,
seek_time
,
IgnoreError
());
if
(
state
==
PlayerState
::
PAUSE
)
if
(
state
==
PlayerState
::
PAUSE
)
pc
.
LockPause
();
pc
.
LockPause
();
...
...
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