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
9e2e8821
Commit
9e2e8821
authored
Feb 28, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PlaylistPrint: throw PlaylistError on error
parent
99ded560
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
19 deletions
+15
-19
PlaylistPrint.cxx
src/PlaylistPrint.cxx
+6
-7
PlaylistPrint.hxx
src/PlaylistPrint.hxx
+5
-3
QueueCommands.cxx
src/command/QueueCommands.cxx
+4
-9
No files found.
src/PlaylistPrint.cxx
View file @
9e2e8821
...
...
@@ -46,7 +46,7 @@ playlist_print_uris(Response &r, Partition &partition,
queue_print_uris
(
r
,
partition
,
queue
,
0
,
queue
.
GetLength
());
}
bool
void
playlist_print_info
(
Response
&
r
,
Partition
&
partition
,
const
playlist
&
playlist
,
unsigned
start
,
unsigned
end
)
...
...
@@ -59,13 +59,12 @@ playlist_print_info(Response &r, Partition &partition,
if
(
start
>
end
)
/* an invalid "start" offset is fatal */
return
false
;
throw
PlaylistError
::
BadRange
()
;
queue_print_info
(
r
,
partition
,
queue
,
start
,
end
);
return
true
;
}
bool
void
playlist_print_id
(
Response
&
r
,
Partition
&
partition
,
const
playlist
&
playlist
,
unsigned
id
)
{
...
...
@@ -74,10 +73,10 @@ playlist_print_id(Response &r, Partition &partition, const playlist &playlist,
position
=
playlist
.
queue
.
IdToPosition
(
id
);
if
(
position
<
0
)
/* no such song */
return
false
;
throw
PlaylistError
::
NoSuchSong
()
;
return
playlist_print_info
(
r
,
partition
,
playlist
,
position
,
position
+
1
);
playlist_print_info
(
r
,
partition
,
playlist
,
position
,
position
+
1
);
}
bool
...
...
src/PlaylistPrint.hxx
View file @
9e2e8821
...
...
@@ -41,8 +41,10 @@ playlist_print_uris(Response &r, Partition &partition,
* information about the songs. The "end" offset is decreased
* automatically if it is too large; passing UINT_MAX is allowed.
* This function however fails when the start offset is invalid.
*
* Throws #PlaylistError if the range is invalid.
*/
bool
void
playlist_print_info
(
Response
&
r
,
Partition
&
partition
,
const
playlist
&
playlist
,
unsigned
start
,
unsigned
end
);
...
...
@@ -50,9 +52,9 @@ playlist_print_info(Response &r, Partition &partition,
/**
* Sends the song with the specified id to the client.
*
*
@return true on suite, false if there is no such song
*
Throws #PlaylistError if the range is invalid.
*/
bool
void
playlist_print_id
(
Response
&
r
,
Partition
&
partition
,
const
playlist
&
playlist
,
unsigned
id
);
...
...
src/command/QueueCommands.cxx
View file @
9e2e8821
...
...
@@ -251,11 +251,8 @@ handle_playlistinfo(Client &client, Request args, Response &r)
{
RangeArg
range
=
args
.
ParseOptional
(
0
,
RangeArg
::
All
());
if
(
!
playlist_print_info
(
r
,
client
.
partition
,
client
.
playlist
,
range
.
start
,
range
.
end
))
return
print_playlist_result
(
r
,
PlaylistResult
::
BAD_RANGE
);
playlist_print_info
(
r
,
client
.
partition
,
client
.
playlist
,
range
.
start
,
range
.
end
);
return
CommandResult
::
OK
;
}
...
...
@@ -264,10 +261,8 @@ handle_playlistid(Client &client, Request args, Response &r)
{
if
(
!
args
.
IsEmpty
())
{
unsigned
id
=
args
.
ParseUnsigned
(
0
);
bool
ret
=
playlist_print_id
(
r
,
client
.
partition
,
client
.
playlist
,
id
);
if
(
!
ret
)
return
print_playlist_result
(
r
,
PlaylistResult
::
NO_SUCH_SONG
);
playlist_print_id
(
r
,
client
.
partition
,
client
.
playlist
,
id
);
}
else
{
playlist_print_info
(
r
,
client
.
partition
,
client
.
playlist
,
0
,
std
::
numeric_limits
<
unsigned
>::
max
());
...
...
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