Fixed esoteric bugs in VideoPreviewWidget and VideoFrameExtractor and added some features #922
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
This pull request is to avoid some occasional hangs/bugs with VideoPreviewWidget (and VideoFrameExtractor).
VideoPreviewWidget/VideoFrameExtractor would sometimes hang because there was a race condition in the task.take() call in addTask(). In order to fix this I needed to add an optional timeout in BlockingQueue -- if task.take() times out, it's ok -- it means another thread took the task.
VideoPreviewWidget failed to scale frames properly when videoFormat == m_out->videoFormat. As a result, preview frames looked wrong.
VideoPreviewWidget had some class methods declared for keepAspectRatio but they weren't implemented. Fixed.
Additionally, I cleaned up the code in VideoFrameExtractor and fixed it to be error-free. I got rid of the ASYNC_EVENT and ASYNC_SIGNAL mechanisms (which were disabled anyway at compile-time) because they were inferior/redundant with ASYNC_TASK.
I also fixed the warning about "moveToThread on object with a parent". The VideoFrameExtractor doesn't need to live in d.thread -- I see no advantage to this and it can only cause problems, so I got rid of the call.
This is heavily tested and I am fairly certain no new bugs were introduced.
Wherever I changed a shared API (such as BlockingQueue) -- I made sure that the 'defaults' to the methods behave exactly 100% the same as the old methods. I just added optional parameters for timeouts. If not using the optional parameters, methods have exactly the same behavior (including ability to put() onto an already-full queue!).
Thanks so much and let me know if there are any issues or comments on this PR.