mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-13 19:29:58 +01:00
Bugfix: issues with vframe stack when seek and stop with setop at EOF.
This commit is contained in:
@@ -657,8 +657,8 @@ void MediaPlayer::update()
|
|||||||
|
|
||||||
// manage loop mode
|
// manage loop mode
|
||||||
if (need_loop_ && !isimage_) {
|
if (need_loop_ && !isimage_) {
|
||||||
execute_loop_command();
|
|
||||||
need_loop_ = false;
|
need_loop_ = false;
|
||||||
|
execute_loop_command();
|
||||||
}
|
}
|
||||||
|
|
||||||
// all other updates below are only for playing mode
|
// all other updates below are only for playing mode
|
||||||
@@ -692,7 +692,7 @@ void MediaPlayer::execute_loop_command()
|
|||||||
rate_ *= - 1.f;
|
rate_ *= - 1.f;
|
||||||
execute_seek_command();
|
execute_seek_command();
|
||||||
}
|
}
|
||||||
else {
|
else { //LOOP_NONE
|
||||||
play(false);
|
play(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -742,6 +742,23 @@ void MediaPlayer::execute_seek_command(GstClockTime target)
|
|||||||
else
|
else
|
||||||
Log::Info("MediaPlayer %s Seek %ld %f", gst_element_get_name(pipeline_), seek_pos, rate_);
|
Log::Info("MediaPlayer %s Seek %ld %f", gst_element_get_name(pipeline_), seek_pos, rate_);
|
||||||
#endif
|
#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)
|
void MediaPlayer::setPlaySpeed(double s)
|
||||||
|
|||||||
@@ -902,7 +902,8 @@ void UserInterface::showMediaPlayer(MediaPlayer *mp)
|
|||||||
|
|
||||||
#define LABEL_AUTO_MEDIA_PLAYER "Active source"
|
#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();
|
mp_->rewind();
|
||||||
ImGui::SameLine(0, spacing);
|
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
|
// display buttons Play/Stop depending on current playing mode
|
||||||
if (media_playing_mode_) {
|
if (media_playing_mode_) {
|
||||||
|
|
||||||
@@ -1090,18 +1095,18 @@ void MediaController::Render()
|
|||||||
// custom timeline slider
|
// custom timeline slider
|
||||||
guint64 current_t = mp_->position();
|
guint64 current_t = mp_->position();
|
||||||
guint64 seek_t = current_t;
|
guint64 seek_t = current_t;
|
||||||
bool slider_pressed = ImGuiToolkit::TimelineSlider( "simpletimeline", &seek_t,
|
slider_pressed_ = ImGuiToolkit::TimelineSlider( "simpletimeline", &seek_t,
|
||||||
mp_->duration(), mp_->frameDuration());
|
mp_->duration(), mp_->frameDuration());
|
||||||
// if the seek target time is different from the current position time
|
// if the seek target time is different from the current position time
|
||||||
// (i.e. the difference is less than one frame)
|
// (i.e. the difference is less than one frame)
|
||||||
if ( ABS_DIFF (current_t, seek_t) > mp_->frameDuration() ) {
|
if ( ABS_DIFF (current_t, seek_t) > mp_->frameDuration() ) {
|
||||||
// request seek (ASYNC)
|
// request seek (ASYNC)
|
||||||
mp_->seekTo(seek_t);
|
mp_->seekTo(seek_t);
|
||||||
slider_pressed = false;
|
slider_pressed_ = false;
|
||||||
}
|
}
|
||||||
// play/stop command should be following the playing mode (buttons)
|
// play/stop command should be following the playing mode (buttons)
|
||||||
// AND force to stop when the slider is pressed
|
// 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
|
// apply play action to media only if status should change
|
||||||
// NB: The seek command performed an ASYNC state change, but
|
// NB: The seek command performed an ASYNC state change, but
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ class MediaController
|
|||||||
std::string current_;
|
std::string current_;
|
||||||
bool follow_active_source_;
|
bool follow_active_source_;
|
||||||
bool media_playing_mode_;
|
bool media_playing_mode_;
|
||||||
|
bool slider_pressed_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MediaController();
|
MediaController();
|
||||||
|
|||||||
Reference in New Issue
Block a user