Skip to content

Commit 3d94d50

Browse files
fix(GSTPlayer): prevent multiple speed requests within a frame (#8344)
behavior seems related to changes between GST 1.12 and 1.20. this implements a simple guard that gets reset at the beginning of update() Co-authored-by: alexandre burton <[email protected]>
1 parent 7a86f09 commit 3d94d50

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

libs/openFrameworks/video/ofGstUtils.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,12 @@ void ofGstUtils::setLoopState(ofLoopType state){
507507
void ofGstUtils::setSpeed(float _speed){
508508
if(_speed == speed) return;
509509

510+
if (updated_in_frame) {
511+
ofLogVerbose("ofGstUtils") << "setSpeed(): prevented multiple changes within a frame";
512+
return;
513+
}
514+
updated_in_frame = true;
515+
510516
GstFormat format = GST_FORMAT_TIME;
511517
GstSeekFlags flags = (GstSeekFlags) (GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_FLUSH);
512518

@@ -910,6 +916,7 @@ ofTexture * ofGstVideoUtils::getTexture(){
910916

911917
void ofGstVideoUtils::update(){
912918
if (isLoaded()){
919+
updated_in_frame = false;
913920
if(!isFrameByFrame()){
914921
std::unique_lock<std::mutex> lock(mutex);
915922
bHavePixelsChanged = bBackPixelsChanged;

libs/openFrameworks/video/ofGstUtils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ class ofGstUtils{
7373

7474
void setSinkListener(ofGstAppSink * appsink);
7575

76+
bool updated_in_frame { false };
77+
7678
// callbacks to get called from gstreamer
7779
#if GST_VERSION_MAJOR==0
7880
virtual GstFlowReturn preroll_cb(std::shared_ptr<GstBuffer> buffer);
@@ -112,6 +114,7 @@ class ofGstUtils{
112114
std::mutex eosMutex;
113115
guint busWatchID;
114116

117+
115118
class ofGstMainLoopThread: public ofThread{
116119
public:
117120
ofGstMainLoopThread()

0 commit comments

Comments
 (0)