Bugfix: issues with vframe stack when seek and stop with setop at EOF.

This commit is contained in:
brunoherbelin
2020-07-20 18:02:24 +02:00
parent f8a09eaaa0
commit 4f5e2a616c
3 changed files with 29 additions and 6 deletions

View File

@@ -657,8 +657,8 @@ void MediaPlayer::update()
// manage loop mode
if (need_loop_ && !isimage_) {
execute_loop_command();
need_loop_ = false;
execute_loop_command();
}
// all other updates below are only for playing mode
@@ -692,7 +692,7 @@ void MediaPlayer::execute_loop_command()
rate_ *= - 1.f;
execute_seek_command();
}
else {
else { //LOOP_NONE
play(false);
}
}
@@ -742,6 +742,23 @@ void MediaPlayer::execute_seek_command(GstClockTime target)
else
Log::Info("MediaPlayer %s Seek %ld %f", gst_element_get_name(pipeline_), seek_pos, rate_);
#endif
// make sure the intermediate buffered frames are ignored
guint i = vframe_read_index_;
vframe_lock_[i].lock();
if (vframe_write_index_ != vframe_read_index_)
{
vframe_lock_[vframe_write_index_].lock();
// catch-up with vframe stack
vframe_read_index_ = vframe_write_index_;
#ifdef MEDIA_PLAYER_DEBUG
Log::Info("MediaPlayer %s reset vframe %d", gst_element_get_name(pipeline_), vframe_write_index_);
#endif
vframe_lock_[vframe_write_index_].unlock();
}
vframe_lock_[i].unlock();
}
void MediaPlayer::setPlaySpeed(double s)

View File

@@ -902,7 +902,8 @@ void UserInterface::showMediaPlayer(MediaPlayer *mp)
#define LABEL_AUTO_MEDIA_PLAYER "Active source"
MediaController::MediaController() : mp_(nullptr), current_(LABEL_AUTO_MEDIA_PLAYER), follow_active_source_(true), media_playing_mode_(false)
MediaController::MediaController() : mp_(nullptr), current_(LABEL_AUTO_MEDIA_PLAYER),
follow_active_source_(true), media_playing_mode_(false), slider_pressed_(false)
{
}
@@ -1040,6 +1041,10 @@ void MediaController::Render()
mp_->rewind();
ImGui::SameLine(0, spacing);
// ignore actual play status of mediaplayer when slider is pressed
if (!slider_pressed_)
media_playing_mode_ = mp_->isPlaying();
// display buttons Play/Stop depending on current playing mode
if (media_playing_mode_) {
@@ -1090,18 +1095,18 @@ void MediaController::Render()
// custom timeline slider
guint64 current_t = mp_->position();
guint64 seek_t = current_t;
bool slider_pressed = ImGuiToolkit::TimelineSlider( "simpletimeline", &seek_t,
slider_pressed_ = ImGuiToolkit::TimelineSlider( "simpletimeline", &seek_t,
mp_->duration(), mp_->frameDuration());
// if the seek target time is different from the current position time
// (i.e. the difference is less than one frame)
if ( ABS_DIFF (current_t, seek_t) > mp_->frameDuration() ) {
// request seek (ASYNC)
mp_->seekTo(seek_t);
slider_pressed = false;
slider_pressed_ = false;
}
// play/stop command should be following the playing mode (buttons)
// AND force to stop when the slider is pressed
bool media_play = media_playing_mode_ & (!slider_pressed);
bool media_play = media_playing_mode_ & (!slider_pressed_);
// apply play action to media only if status should change
// NB: The seek command performed an ASYNC state change, but

View File

@@ -86,6 +86,7 @@ class MediaController
std::string current_;
bool follow_active_source_;
bool media_playing_mode_;
bool slider_pressed_;
public:
MediaController();