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
fb547260
Commit
fb547260
authored
Nov 11, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
player/Control: Play*() returns Error information
parent
2065e329
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
82 additions
and
54 deletions
+82
-54
Partition.hxx
src/Partition.hxx
+8
-8
PlayerCommands.cxx
src/command/PlayerCommands.cxx
+20
-8
Control.cxx
src/player/Control.cxx
+6
-4
Control.hxx
src/player/Control.hxx
+1
-1
Playlist.cxx
src/queue/Playlist.cxx
+9
-4
Playlist.hxx
src/queue/Playlist.hxx
+5
-5
PlaylistControl.cxx
src/queue/PlaylistControl.cxx
+29
-22
PlaylistEdit.cxx
src/queue/PlaylistEdit.cxx
+2
-1
PlaylistState.cxx
src/queue/PlaylistState.cxx
+2
-1
No files found.
src/Partition.hxx
View file @
fb547260
...
@@ -123,20 +123,20 @@ struct Partition final : private PlayerListener, private MixerListener {
...
@@ -123,20 +123,20 @@ struct Partition final : private PlayerListener, private MixerListener {
playlist
.
Stop
(
pc
);
playlist
.
Stop
(
pc
);
}
}
void
PlayPosition
(
int
position
)
{
bool
PlayPosition
(
int
position
,
Error
&
error
)
{
playlist
.
PlayPosition
(
pc
,
position
);
return
playlist
.
PlayPosition
(
pc
,
position
,
error
);
}
}
void
PlayId
(
int
id
)
{
bool
PlayId
(
int
id
,
Error
&
error
)
{
playlist
.
PlayId
(
pc
,
id
);
return
playlist
.
PlayId
(
pc
,
id
,
error
);
}
}
void
PlayNext
(
)
{
bool
PlayNext
(
Error
&
error
)
{
playlist
.
PlayNext
(
pc
);
return
playlist
.
PlayNext
(
pc
,
error
);
}
}
void
PlayPrevious
(
)
{
bool
PlayPrevious
(
Error
&
error
)
{
playlist
.
PlayPrevious
(
pc
);
return
playlist
.
PlayPrevious
(
pc
,
error
);
}
}
bool
SeekSongPosition
(
unsigned
song_position
,
bool
SeekSongPosition
(
unsigned
song_position
,
...
...
src/command/PlayerCommands.cxx
View file @
fb547260
...
@@ -60,16 +60,22 @@ CommandResult
...
@@ -60,16 +60,22 @@ CommandResult
handle_play
(
Client
&
client
,
Request
args
,
gcc_unused
Response
&
r
)
handle_play
(
Client
&
client
,
Request
args
,
gcc_unused
Response
&
r
)
{
{
int
song
=
args
.
ParseOptional
(
0
,
-
1
);
int
song
=
args
.
ParseOptional
(
0
,
-
1
);
client
.
partition
.
PlayPosition
(
song
);
return
CommandResult
::
OK
;
Error
error
;
return
client
.
partition
.
PlayPosition
(
song
,
error
)
?
CommandResult
::
OK
:
print_error
(
r
,
error
);
}
}
CommandResult
CommandResult
handle_playid
(
Client
&
client
,
Request
args
,
gcc_unused
Response
&
r
)
handle_playid
(
Client
&
client
,
Request
args
,
gcc_unused
Response
&
r
)
{
{
int
id
=
args
.
ParseOptional
(
0
,
-
1
);
int
id
=
args
.
ParseOptional
(
0
,
-
1
);
client
.
partition
.
PlayId
(
id
);
return
CommandResult
::
OK
;
Error
error
;
return
client
.
partition
.
PlayId
(
id
,
error
)
?
CommandResult
::
OK
:
print_error
(
r
,
error
);
}
}
CommandResult
CommandResult
...
@@ -212,18 +218,24 @@ handle_next(Client &client, gcc_unused Request args, gcc_unused Response &r)
...
@@ -212,18 +218,24 @@ handle_next(Client &client, gcc_unused Request args, gcc_unused Response &r)
const
bool
single
=
playlist
.
queue
.
single
;
const
bool
single
=
playlist
.
queue
.
single
;
playlist
.
queue
.
single
=
false
;
playlist
.
queue
.
single
=
false
;
client
.
partition
.
PlayNext
();
Error
error
;
bool
success
=
client
.
partition
.
PlayNext
(
error
);
playlist
.
queue
.
single
=
single
;
playlist
.
queue
.
single
=
single
;
return
CommandResult
::
OK
;
return
success
?
CommandResult
::
OK
:
print_error
(
r
,
error
);
}
}
CommandResult
CommandResult
handle_previous
(
Client
&
client
,
gcc_unused
Request
args
,
handle_previous
(
Client
&
client
,
gcc_unused
Request
args
,
gcc_unused
Response
&
r
)
gcc_unused
Response
&
r
)
{
{
client
.
partition
.
PlayPrevious
();
Error
error
;
return
CommandResult
::
OK
;
return
client
.
partition
.
PlayPrevious
(
error
)
?
CommandResult
::
OK
:
print_error
(
r
,
error
);
}
}
CommandResult
CommandResult
...
...
src/player/Control.cxx
View file @
fb547260
...
@@ -49,18 +49,20 @@ PlayerControl::~PlayerControl()
...
@@ -49,18 +49,20 @@ PlayerControl::~PlayerControl()
delete
tagged_song
;
delete
tagged_song
;
}
}
void
bool
PlayerControl
::
Play
(
DetachedSong
*
song
)
PlayerControl
::
Play
(
DetachedSong
*
song
,
Error
&
error_r
)
{
{
assert
(
song
!=
nullptr
);
assert
(
song
!=
nullptr
);
const
ScopeLock
protect
(
mutex
);
const
ScopeLock
protect
(
mutex
);
SeekLocked
(
song
,
SongTime
::
zero
(),
IgnoreError
()
);
bool
success
=
SeekLocked
(
song
,
SongTime
::
zero
(),
error_r
);
if
(
state
==
PlayerState
::
PAUSE
)
if
(
s
uccess
&&
s
tate
==
PlayerState
::
PAUSE
)
/* if the player was paused previously, we need to
/* if the player was paused previously, we need to
unpause it */
unpause it */
PauseLocked
();
PauseLocked
();
return
success
;
}
}
void
void
...
...
src/player/Control.hxx
View file @
fb547260
...
@@ -311,7 +311,7 @@ public:
...
@@ -311,7 +311,7 @@ public:
* @param song the song to be queued; the given instance will
* @param song the song to be queued; the given instance will
* be owned and freed by the player
* be owned and freed by the player
*/
*/
void
Play
(
DetachedSong
*
song
);
bool
Play
(
DetachedSong
*
song
,
Error
&
error
);
/**
/**
* see PlayerCommand::CANCEL
* see PlayerCommand::CANCEL
...
...
src/queue/Playlist.cxx
View file @
fb547260
...
@@ -152,8 +152,8 @@ playlist::UpdateQueuedSong(PlayerControl &pc, const DetachedSong *prev)
...
@@ -152,8 +152,8 @@ playlist::UpdateQueuedSong(PlayerControl &pc, const DetachedSong *prev)
}
}
}
}
void
bool
playlist
::
PlayOrder
(
PlayerControl
&
pc
,
int
order
)
playlist
::
PlayOrder
(
PlayerControl
&
pc
,
int
order
,
Error
&
error
)
{
{
playing
=
true
;
playing
=
true
;
queued
=
-
1
;
queued
=
-
1
;
...
@@ -162,10 +162,14 @@ playlist::PlayOrder(PlayerControl &pc, int order)
...
@@ -162,10 +162,14 @@ playlist::PlayOrder(PlayerControl &pc, int order)
FormatDebug
(
playlist_domain
,
"play %i:
\"
%s
\"
"
,
order
,
song
.
GetURI
());
FormatDebug
(
playlist_domain
,
"play %i:
\"
%s
\"
"
,
order
,
song
.
GetURI
());
pc
.
Play
(
new
DetachedSong
(
song
));
current
=
order
;
current
=
order
;
if
(
!
pc
.
Play
(
new
DetachedSong
(
song
),
error
))
return
false
;
SongStarted
();
SongStarted
();
return
true
;
}
}
void
void
...
@@ -224,7 +228,8 @@ playlist::ResumePlayback(PlayerControl &pc)
...
@@ -224,7 +228,8 @@ playlist::ResumePlayback(PlayerControl &pc)
Stop
(
pc
);
Stop
(
pc
);
else
else
/* continue playback at the next song */
/* continue playback at the next song */
PlayNext
(
pc
);
/* TODO: log error? */
PlayNext
(
pc
,
IgnoreError
());
}
}
void
void
...
...
src/queue/Playlist.hxx
View file @
fb547260
...
@@ -262,15 +262,15 @@ public:
...
@@ -262,15 +262,15 @@ public:
void
Stop
(
PlayerControl
&
pc
);
void
Stop
(
PlayerControl
&
pc
);
void
PlayPosition
(
PlayerControl
&
pc
,
int
position
);
bool
PlayPosition
(
PlayerControl
&
pc
,
int
position
,
Error
&
error
);
void
PlayOrder
(
PlayerControl
&
pc
,
int
orde
r
);
bool
PlayOrder
(
PlayerControl
&
pc
,
int
order
,
Error
&
erro
r
);
void
PlayId
(
PlayerControl
&
pc
,
int
id
);
bool
PlayId
(
PlayerControl
&
pc
,
int
id
,
Error
&
error
);
void
PlayNext
(
PlayerControl
&
pc
);
bool
PlayNext
(
PlayerControl
&
pc
,
Error
&
error
);
void
PlayPrevious
(
PlayerControl
&
pc
);
bool
PlayPrevious
(
PlayerControl
&
pc
,
Error
&
error
);
bool
SeekSongOrder
(
PlayerControl
&
pc
,
bool
SeekSongOrder
(
PlayerControl
&
pc
,
unsigned
song_order
,
unsigned
song_order
,
...
...
src/queue/PlaylistControl.cxx
View file @
fb547260
...
@@ -56,8 +56,8 @@ playlist::Stop(PlayerControl &pc)
...
@@ -56,8 +56,8 @@ playlist::Stop(PlayerControl &pc)
}
}
}
}
void
bool
playlist
::
PlayPosition
(
PlayerControl
&
pc
,
int
song
)
playlist
::
PlayPosition
(
PlayerControl
&
pc
,
int
song
,
Error
&
error
)
{
{
pc
.
LockClearError
();
pc
.
LockClearError
();
...
@@ -66,13 +66,13 @@ playlist::PlayPosition(PlayerControl &pc, int song)
...
@@ -66,13 +66,13 @@ playlist::PlayPosition(PlayerControl &pc, int song)
/* play any song ("current" song, or the first song */
/* play any song ("current" song, or the first song */
if
(
queue
.
IsEmpty
())
if
(
queue
.
IsEmpty
())
return
;
return
true
;
if
(
playing
)
{
if
(
playing
)
{
/* already playing: unpause playback, just in
/* already playing: unpause playback, just in
case it was paused, and return */
case it was paused, and return */
pc
.
LockSetPause
(
false
);
pc
.
LockSetPause
(
false
);
return
;
return
true
;
}
}
/* select a song: "current" song, or the first one */
/* select a song: "current" song, or the first one */
...
@@ -102,29 +102,30 @@ playlist::PlayPosition(PlayerControl &pc, int song)
...
@@ -102,29 +102,30 @@ playlist::PlayPosition(PlayerControl &pc, int song)
stop_on_error
=
false
;
stop_on_error
=
false
;
error_count
=
0
;
error_count
=
0
;
PlayOrder
(
pc
,
i
);
return
PlayOrder
(
pc
,
i
,
error
);
}
}
void
bool
playlist
::
PlayId
(
PlayerControl
&
pc
,
int
id
)
playlist
::
PlayId
(
PlayerControl
&
pc
,
int
id
,
Error
&
error
)
{
{
if
(
id
==
-
1
)
{
if
(
id
==
-
1
)
PlayPosition
(
pc
,
id
);
return
PlayPosition
(
pc
,
id
,
error
);
return
;
}
int
song
=
queue
.
IdToPosition
(
id
);
int
song
=
queue
.
IdToPosition
(
id
);
if
(
song
<
0
)
if
(
song
<
0
)
throw
PlaylistError
::
NoSuchSong
();
throw
PlaylistError
::
NoSuchSong
();
return
PlayPosition
(
pc
,
song
);
return
PlayPosition
(
pc
,
song
,
error
);
}
}
void
bool
playlist
::
PlayNext
(
PlayerControl
&
pc
)
playlist
::
PlayNext
(
PlayerControl
&
pc
,
Error
&
error
)
{
{
if
(
!
playing
)
if
(
!
playing
)
{
return
;
error
.
Set
(
playlist_domain
,
int
(
PlaylistResult
::
NOT_PLAYING
),
"Not playing"
);
return
true
;
}
assert
(
!
queue
.
IsEmpty
());
assert
(
!
queue
.
IsEmpty
());
assert
(
queue
.
IsValidOrder
(
current
));
assert
(
queue
.
IsValidOrder
(
current
));
...
@@ -158,19 +159,25 @@ playlist::PlayNext(PlayerControl &pc)
...
@@ -158,19 +159,25 @@ playlist::PlayNext(PlayerControl &pc)
discard them anyway */
discard them anyway */
}
}
PlayOrder
(
pc
,
next_order
);
if
(
!
PlayOrder
(
pc
,
next_order
,
error
))
return
false
;
}
}
/* Consume mode removes each played songs. */
/* Consume mode removes each played songs. */
if
(
queue
.
consume
)
if
(
queue
.
consume
)
DeleteOrder
(
pc
,
old_current
);
DeleteOrder
(
pc
,
old_current
);
return
true
;
}
}
void
bool
playlist
::
PlayPrevious
(
PlayerControl
&
pc
)
playlist
::
PlayPrevious
(
PlayerControl
&
pc
,
Error
&
error
)
{
{
if
(
!
playing
)
if
(
!
playing
)
{
return
;
error
.
Set
(
playlist_domain
,
int
(
PlaylistResult
::
NOT_PLAYING
),
"Not playing"
);
return
true
;
}
assert
(
!
queue
.
IsEmpty
());
assert
(
!
queue
.
IsEmpty
());
...
@@ -187,7 +194,7 @@ playlist::PlayPrevious(PlayerControl &pc)
...
@@ -187,7 +194,7 @@ playlist::PlayPrevious(PlayerControl &pc)
order
=
current
;
order
=
current
;
}
}
PlayOrder
(
pc
,
orde
r
);
return
PlayOrder
(
pc
,
order
,
erro
r
);
}
}
bool
bool
...
...
src/queue/PlaylistEdit.cxx
View file @
fb547260
...
@@ -239,7 +239,8 @@ playlist::DeleteInternal(PlayerControl &pc,
...
@@ -239,7 +239,8 @@ playlist::DeleteInternal(PlayerControl &pc,
if
(
current
>=
0
&&
!
paused
)
if
(
current
>=
0
&&
!
paused
)
/* play the song after the deleted one */
/* play the song after the deleted one */
PlayOrder
(
pc
,
current
);
/* TODO: log error? */
PlayOrder
(
pc
,
current
,
IgnoreError
());
else
{
else
{
/* stop the player */
/* stop the player */
...
...
src/queue/PlaylistState.cxx
View file @
fb547260
...
@@ -196,7 +196,8 @@ playlist_state_restore(const char *line, TextFile &file,
...
@@ -196,7 +196,8 @@ playlist_state_restore(const char *line, TextFile &file,
if
(
state
==
PlayerState
::
STOP
/* && config_option */
)
if
(
state
==
PlayerState
::
STOP
/* && config_option */
)
playlist
.
current
=
current
;
playlist
.
current
=
current
;
else
if
(
seek_time
.
count
()
==
0
)
else
if
(
seek_time
.
count
()
==
0
)
playlist
.
PlayPosition
(
pc
,
current
);
/* TODO: log error? */
playlist
.
PlayPosition
(
pc
,
current
,
IgnoreError
());
else
else
playlist
.
SeekSongPosition
(
pc
,
current
,
seek_time
,
playlist
.
SeekSongPosition
(
pc
,
current
,
seek_time
,
IgnoreError
());
IgnoreError
());
...
...
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