Skip to content

Commit

Permalink
x11: fix crash if receive an invalid frame(stop playback)
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Sep 23, 2015
1 parent 0d87426 commit 41d469c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
10 changes: 7 additions & 3 deletions src/output/video/XVRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,14 @@ void CopyFromYv12_2(quint8 *dst[], size_t dst_pitch[],
bool XVRenderer::receiveFrame(const VideoFrame& frame)
{
DPTR_D(XVRenderer);
if (frame.isValid()) {
if (!d.ensureImage(frame.width(), frame.height(), frame.format().pixelFormat()))
return false;
if (!frame.isValid()) {
d.update_background = true;
d.video_frame = VideoFrame(); // fill background
update();
return true;
}
if (!d.ensureImage(frame.width(), frame.height(), frame.format().pixelFormat()))
return false;
if (frame.constBits(0))
d.video_frame = frame;
else // FIXME: not work
Expand Down
20 changes: 12 additions & 8 deletions widgets/X11Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
******************************************************************************/
//TODO: ROI
//TODO: ROI, rotation. slow scale because of alignment? no xsync for shm
/*
* X11 headers define 'Bool' type which is used in qmetatype.h. we must include X11 files at last, i.e. X11Renderer_p.h. otherwise compile error
*/
Expand Down Expand Up @@ -322,13 +322,17 @@ extern void CopyPlane(quint8 *dst, size_t dst_pitch, const quint8 *src, size_t s
bool X11Renderer::receiveFrame(const VideoFrame& frame)
{
DPTR_D(X11Renderer);
if (frame.isValid()) {
if (!d.ensureImage(videoRect().width(), videoRect().height())) // we can also call it in onResizeRenderer, onSetOutAspectXXX
return false;
if (preferredPixelFormat() != d.pixfmt) {
qDebug() << "x11 preferred pixel format: " << d.pixfmt;
setPreferredPixelFormat(d.pixfmt);
}
if (!frame.isValid()) {
d.update_background = true;
d.video_frame = VideoFrame(); // fill background
update();
return true;
}
if (!d.ensureImage(videoRect().width(), videoRect().height())) // we can also call it in onResizeRenderer, onSetOutAspectXXX
return false;
if (preferredPixelFormat() != d.pixfmt) {
qDebug() << "x11 preferred pixel format: " << d.pixfmt;
setPreferredPixelFormat(d.pixfmt);
}
bool bad_pitch = false;
if (frame.constBits(0)) {
Expand Down

0 comments on commit 41d469c

Please sign in to comment.