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
127fe6ec
Commit
127fe6ec
authored
Aug 28, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PlaylistEdit: pass std::chrono::duration to SetSongIdRange()
parent
888ab0c8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
20 deletions
+20
-20
QueueCommands.cxx
src/command/QueueCommands.cxx
+11
-11
Playlist.hxx
src/queue/Playlist.hxx
+2
-2
PlaylistEdit.cxx
src/queue/PlaylistEdit.cxx
+7
-7
No files found.
src/command/QueueCommands.cxx
View file @
127fe6ec
...
@@ -125,7 +125,7 @@ handle_addid(Client &client, unsigned argc, char *argv[])
...
@@ -125,7 +125,7 @@ handle_addid(Client &client, unsigned argc, char *argv[])
* integer milliseconds. Omitted values are zero.
* integer milliseconds. Omitted values are zero.
*/
*/
static
bool
static
bool
parse_time_range
(
const
char
*
p
,
unsigned
&
start_ms
,
unsigned
&
end_ms
)
parse_time_range
(
const
char
*
p
,
SongTime
&
start_r
,
SongTime
&
end_r
)
{
{
char
*
endptr
;
char
*
endptr
;
...
@@ -133,9 +133,9 @@ parse_time_range(const char *p, unsigned &start_ms, unsigned &end_ms)
...
@@ -133,9 +133,9 @@ parse_time_range(const char *p, unsigned &start_ms, unsigned &end_ms)
if
(
*
endptr
!=
':'
||
start
<
0
)
if
(
*
endptr
!=
':'
||
start
<
0
)
return
false
;
return
false
;
start_
ms
=
endptr
>
p
start_
r
=
endptr
>
p
?
unsigned
(
start
*
1000u
)
?
SongTime
::
FromS
(
start
)
:
0u
;
:
SongTime
::
zero
()
;
p
=
endptr
+
1
;
p
=
endptr
+
1
;
...
@@ -143,11 +143,11 @@ parse_time_range(const char *p, unsigned &start_ms, unsigned &end_ms)
...
@@ -143,11 +143,11 @@ parse_time_range(const char *p, unsigned &start_ms, unsigned &end_ms)
if
(
*
endptr
!=
0
||
end
<
0
)
if
(
*
endptr
!=
0
||
end
<
0
)
return
false
;
return
false
;
end_
ms
=
endptr
>
p
end_
r
=
endptr
>
p
?
unsigned
(
end
*
1000u
)
?
SongTime
::
FromS
(
end
)
:
0u
;
:
SongTime
::
zero
()
;
return
end_
ms
==
0
||
end_ms
>
start_ms
;
return
end_
r
.
IsZero
()
||
end_r
>
start_r
;
}
}
CommandResult
CommandResult
...
@@ -157,15 +157,15 @@ handle_rangeid(Client &client, gcc_unused unsigned argc, char *argv[])
...
@@ -157,15 +157,15 @@ handle_rangeid(Client &client, gcc_unused unsigned argc, char *argv[])
if
(
!
check_unsigned
(
client
,
&
id
,
argv
[
1
]))
if
(
!
check_unsigned
(
client
,
&
id
,
argv
[
1
]))
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
unsigned
start_ms
,
end_ms
;
SongTime
start
,
end
;
if
(
!
parse_time_range
(
argv
[
2
],
start
_ms
,
end_ms
))
{
if
(
!
parse_time_range
(
argv
[
2
],
start
,
end
))
{
command_error
(
client
,
ACK_ERROR_ARG
,
"Bad range"
);
command_error
(
client
,
ACK_ERROR_ARG
,
"Bad range"
);
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
}
}
Error
error
;
Error
error
;
if
(
!
client
.
partition
.
playlist
.
SetSongIdRange
(
client
.
partition
.
pc
,
if
(
!
client
.
partition
.
playlist
.
SetSongIdRange
(
client
.
partition
.
pc
,
id
,
start
_ms
,
end_ms
,
id
,
start
,
end
,
error
))
error
))
return
print_error
(
client
,
error
);
return
print_error
(
client
,
error
);
...
...
src/queue/Playlist.hxx
View file @
127fe6ec
...
@@ -228,11 +228,11 @@ public:
...
@@ -228,11 +228,11 @@ public:
unsigned
song_id
,
uint8_t
priority
);
unsigned
song_id
,
uint8_t
priority
);
/**
/**
* Sets the start_
ms and end_ms
attributes on the song
* Sets the start_
time and end_time
attributes on the song
* with the specified id.
* with the specified id.
*/
*/
bool
SetSongIdRange
(
PlayerControl
&
pc
,
unsigned
id
,
bool
SetSongIdRange
(
PlayerControl
&
pc
,
unsigned
id
,
unsigned
start_ms
,
unsigned
end_ms
,
SongTime
start
,
SongTime
end
,
Error
&
error
);
Error
&
error
);
bool
AddSongIdTag
(
unsigned
id
,
TagType
tag_type
,
const
char
*
value
,
bool
AddSongIdTag
(
unsigned
id
,
TagType
tag_type
,
const
char
*
value
,
...
...
src/queue/PlaylistEdit.cxx
View file @
127fe6ec
...
@@ -434,10 +434,10 @@ playlist::Shuffle(PlayerControl &pc, unsigned start, unsigned end)
...
@@ -434,10 +434,10 @@ playlist::Shuffle(PlayerControl &pc, unsigned start, unsigned end)
bool
bool
playlist
::
SetSongIdRange
(
PlayerControl
&
pc
,
unsigned
id
,
playlist
::
SetSongIdRange
(
PlayerControl
&
pc
,
unsigned
id
,
unsigned
start_ms
,
unsigned
end_ms
,
SongTime
start
,
SongTime
end
,
Error
&
error
)
Error
&
error
)
{
{
assert
(
end
_ms
==
0
||
start_ms
<
end_ms
);
assert
(
end
.
IsZero
()
||
start
<
end
);
int
position
=
queue
.
IdToPosition
(
id
);
int
position
=
queue
.
IdToPosition
(
id
);
if
(
position
<
0
)
{
if
(
position
<
0
)
{
...
@@ -467,20 +467,20 @@ playlist::SetSongIdRange(PlayerControl &pc, unsigned id,
...
@@ -467,20 +467,20 @@ playlist::SetSongIdRange(PlayerControl &pc, unsigned id,
/* validate the offsets */
/* validate the offsets */
const
unsigned
duration
=
song
.
GetTag
().
time
;
const
unsigned
duration
=
song
.
GetTag
().
time
;
if
(
start
_ms
/
1000u
>
duration
)
{
if
(
start
.
ToMS
()
/
1000u
>
duration
)
{
error
.
Set
(
playlist_domain
,
error
.
Set
(
playlist_domain
,
int
(
PlaylistResult
::
BAD_RANGE
),
int
(
PlaylistResult
::
BAD_RANGE
),
"Invalid start offset"
);
"Invalid start offset"
);
return
false
;
return
false
;
}
}
if
(
end
_ms
/
1000u
>
duration
)
if
(
end
.
ToMS
()
/
1000u
>
duration
)
end
_ms
=
0
;
end
=
SongTime
::
zero
()
;
}
}
/* edit it */
/* edit it */
song
.
SetStartTime
(
SongTime
::
FromMS
(
start_ms
)
);
song
.
SetStartTime
(
start
);
song
.
SetEndTime
(
SongTime
::
FromMS
(
end_ms
)
);
song
.
SetEndTime
(
end
);
/* announce the change to all interested subsystems */
/* announce the change to all interested subsystems */
UpdateQueuedSong
(
pc
,
nullptr
);
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