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
1f0770ca
Commit
1f0770ca
authored
Dec 21, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
player/Thread: move code to SeekDecoder(SongTime)
parent
505d0bfa
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
20 deletions
+38
-20
Thread.cxx
src/player/Thread.cxx
+38
-20
No files found.
src/player/Thread.cxx
View file @
1f0770ca
...
...
@@ -267,6 +267,16 @@ private:
}
/**
* Invoke DecoderControl::Seek() and update our state or
* handle errors.
*
* Caller must lock the mutex.
*
* @return false if the decoder has failed
*/
bool
SeekDecoder
(
SongTime
seek_time
)
noexcept
;
/**
* This is the handler for the #PlayerCommand::SEEK command.
*
* The player lock is not held.
...
...
@@ -580,6 +590,33 @@ Player::SendSilence() noexcept
return
true
;
}
bool
Player
::
SeekDecoder
(
SongTime
seek_time
)
noexcept
{
assert
(
song
);
assert
(
!
decoder_starting
);
if
(
!
pc
.
total_time
.
IsNegative
())
{
const
SongTime
total_time
(
pc
.
total_time
);
if
(
seek_time
>
total_time
)
seek_time
=
total_time
;
}
try
{
const
PlayerControl
::
ScopeOccupied
occupied
(
pc
);
dc
.
Seek
(
song
->
GetStartTime
()
+
seek_time
);
}
catch
(...)
{
/* decoder failure */
pc
.
SetError
(
PlayerError
::
DECODER
,
std
::
current_exception
());
pc
.
CommandFinished
();
return
false
;
}
elapsed_time
=
seek_time
;
return
true
;
}
inline
bool
Player
::
SeekDecoder
()
noexcept
{
...
...
@@ -615,7 +652,6 @@ Player::SeekDecoder() noexcept
const
std
::
lock_guard
<
Mutex
>
lock
(
pc
.
mutex
);
const
SongTime
start_time
=
pc
.
next_song
->
GetStartTime
();
pc
.
next_song
.
reset
();
queued
=
false
;
...
...
@@ -628,28 +664,10 @@ Player::SeekDecoder() noexcept
/* send the SEEK command */
SongTime
where
=
pc
.
seek_time
;
if
(
!
pc
.
total_time
.
IsNegative
())
{
const
SongTime
total_time
(
pc
.
total_time
);
if
(
where
>
total_time
)
where
=
total_time
;
}
try
{
const
PlayerControl
::
ScopeOccupied
occupied
(
pc
);
dc
.
Seek
(
where
+
start_time
);
}
catch
(...)
{
/* decoder failure */
pc
.
SetError
(
PlayerError
::
DECODER
,
std
::
current_exception
());
pc
.
CommandFinished
();
if
(
!
SeekDecoder
(
pc
.
seek_time
))
return
false
;
}
elapsed_time
=
where
;
}
pc
.
LockCommandFinished
();
assert
(
xfade_state
==
CrossFadeState
::
UNKNOWN
);
...
...
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