Skip to content

Conversation

Tereius
Copy link

@Tereius Tereius commented Oct 24, 2021

There is a race condition between the ExtractThread running p->releaseResourceInternal() (and unloading the demuxer) and the main thread calling extract() and loading the demuxer inside checkAndOpen() if run in synchronous extraction mode.

// Run in main thread
auto mpExtractor = new QtAV::VideoFrameExtractor();
mpExtractor->setAsync(false);
mpExtractor->setSource("file://whatever.mp4"); // This call will unnecessarily start the ExtractThread which will unload the demuxer in p->releaseResourceInternal()
mpExtractor->setPosition(0);
mpExtractor->extract(); // The frame extraction is only successful if the demuxer is loaded. Racing happens because the ExtractThread simultaneously unloads the demuxer while the main thread loads the demuxer in checkAndOpen()

The solution is not to start the ExtractThread at all if async equals false.

…tract() in synchronous extraction mode (async equals false).

Only start ExtractionThread if it is necessary (async equals true).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant