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
22899686
Commit
22899686
authored
Aug 29, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PlayerControl: use SignedSongTime for the song duration
parent
ca252804
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
14 deletions
+16
-14
PlayerControl.hxx
src/PlayerControl.hxx
+2
-2
PlayerThread.cxx
src/PlayerThread.cxx
+11
-11
PlayerCommands.cxx
src/command/PlayerCommands.cxx
+3
-1
No files found.
src/PlayerControl.hxx
View file @
22899686
...
...
@@ -89,7 +89,7 @@ struct player_status {
PlayerState
state
;
uint16_t
bit_rate
;
AudioFormat
audio_format
;
float
total_time
;
SignedSongTime
total_time
;
float
elapsed_time
;
};
...
...
@@ -151,7 +151,7 @@ struct PlayerControl {
uint16_t
bit_rate
;
AudioFormat
audio_format
;
float
total_time
;
SignedSongTime
total_time
;
float
elapsed_time
;
/**
...
...
src/PlayerThread.cxx
View file @
22899686
...
...
@@ -349,7 +349,7 @@ Player::WaitForDecoder()
decoder_starting
=
true
;
/* update PlayerControl's song information */
pc
.
total_time
=
pc
.
next_song
->
GetDuration
()
.
ToDoubleS
()
;
pc
.
total_time
=
pc
.
next_song
->
GetDuration
();
pc
.
bit_rate
=
0
;
pc
.
audio_format
.
Clear
();
...
...
@@ -368,21 +368,21 @@ Player::WaitForDecoder()
* Returns the real duration of the song, comprising the duration
* indicated by the decoder plugin.
*/
static
doubl
e
real_song_duration
(
const
DetachedSong
&
song
,
doubl
e
decoder_duration
)
static
SignedSongTim
e
real_song_duration
(
const
DetachedSong
&
song
,
SignedSongTim
e
decoder_duration
)
{
if
(
decoder_duration
<=
0.0
)
if
(
decoder_duration
.
IsNegative
()
)
/* the decoder plugin didn't provide information; fall
back to Song::GetDuration() */
return
song
.
GetDuration
()
.
ToDoubleS
()
;
return
song
.
GetDuration
();
const
SongTime
start_time
=
song
.
GetStartTime
();
const
SongTime
end_time
=
song
.
GetEndTime
();
if
(
end_time
.
IsPositive
()
&&
end_time
.
ToDoubleS
()
<
decoder_duration
)
return
(
end_time
-
start_time
).
ToDoubleS
(
);
if
(
end_time
.
IsPositive
()
&&
end_time
<
SongTime
(
decoder_duration
)
)
return
SignedSongTime
(
end_time
-
start_time
);
return
decoder_duration
-
start_time
.
ToDoubleS
(
);
return
SignedSongTime
(
SongTime
(
decoder_duration
)
-
start_time
);
}
bool
...
...
@@ -450,7 +450,7 @@ Player::CheckDecoderStartup()
return
true
;
pc
.
Lock
();
pc
.
total_time
=
real_song_duration
(
*
dc
.
song
,
dc
.
total_time
.
ToDoubleS
()
);
pc
.
total_time
=
real_song_duration
(
*
dc
.
song
,
dc
.
total_time
);
pc
.
audio_format
=
dc
.
in_audio_format
;
pc
.
Unlock
();
...
...
@@ -562,8 +562,8 @@ Player::SeekDecoder()
/* send the SEEK command */
SongTime
where
=
pc
.
seek_time
;
if
(
pc
.
total_time
>
0
)
{
const
SongTime
total_time
=
SongTime
::
FromS
(
pc
.
total_time
);
if
(
!
pc
.
total_time
.
IsNegative
()
)
{
const
SongTime
total_time
(
pc
.
total_time
);
if
(
where
>
total_time
)
where
=
total_time
;
}
...
...
src/command/PlayerCommands.cxx
View file @
22899686
...
...
@@ -176,7 +176,9 @@ handle_status(Client &client,
"elapsed: %1.3f
\n
"
COMMAND_STATUS_BITRATE
": %u
\n
"
,
(
int
)(
player_status
.
elapsed_time
+
0.5
),
(
int
)(
player_status
.
total_time
+
0.5
),
player_status
.
total_time
.
IsNegative
()
?
0u
:
unsigned
(
player_status
.
total_time
.
RoundS
()),
player_status
.
elapsed_time
,
player_status
.
bit_rate
);
...
...
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