Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for the PositionWatcher thread to stop #1109

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
36 changes: 36 additions & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Specify the build system requirements.
[build-system]
requires = ["sip >=5.3, <7", "PyQt-builder >=1.9, <2"]
build-backend = "sipbuild.api"

# Specify the PEP 566 metadata for the project.
[tool.sip.metadata]
name = "PyQtAV"
version = "1.12.0"
summary = "Python bindings for the QtAV"
home-page = ""
author = ""
author-email = ""
license = "LGPL"

# Specify a PyQt-based project.
[tool.sip]
project-factory = "pyqtbuild:PyQtProject"

# Configure the project.
[tool.sip.project]
tag-prefix = "QtAV"
sip-include-dirs = [PYQT_BINDINGS_DIR]

# Define and configure each set of bindings.
[tool.sip.bindings.QtAV]
qmake-QT = ["widgets"]
include-dirs = [INCLUDE_DIRS]
libraries = [QTAV_LIB]
library-dirs = [LIB_DIRS]

[tool.sip.bindings.QtAVWidgets]
qmake-QT = ["widgets", "opengl", "openglwidgets"]
include-dirs = [INCLUDE_DIRS]
libraries = [QTAV_LIB, QTAV_WIDGETS_LIB]
library-dirs = [LIB_DIRS]
1 change: 0 additions & 1 deletion python/sip/QtAV/VideoFormat.sip
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ public:
static QImage::Format imageFormatFromPixelFormat(PixelFormat format);
static PixelFormat pixelFormatFromFFmpeg(int ff); //AVPixelFormat
static int pixelFormatToFFmpeg(PixelFormat fmt);
static QVector<int> pixelFormatsFFmpeg();

VideoFormat(PixelFormat format = Format_Invalid);
VideoFormat(int formatFF /Constrained/);
Expand Down
64 changes: 0 additions & 64 deletions python/sip/QtAVWidgets/GLWidgetRenderer2.sip

This file was deleted.

2 changes: 1 addition & 1 deletion python/sip/QtAVWidgets/GraphicsItemRenderer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public:

public:
GraphicsItemRenderer(QGraphicsItem* parent /TransferThis/ = 0);
virtual VideoRendererId id();
VideoRendererId id();

bool isSupported(VideoFormat::PixelFormat pixfmt);

Expand Down
4 changes: 2 additions & 2 deletions python/sip/QtAVWidgets/OpenGLWidgetRenderer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public:
QSize videoFrameSize();

public:
explicit OpenGLWidgetRenderer(QWidget* parent /TransferThis/ = 0, Qt::WindowFlags f = 0);
virtual VideoRendererId id();
explicit OpenGLWidgetRenderer(QWidget* parent /TransferThis/ = 0, Qt::WindowFlags f = Qt::WindowFlags());
VideoRendererId id() const;
virtual QWidget* widget();

signals:
Expand Down
2 changes: 1 addition & 1 deletion python/sip/QtAVWidgets/QtAVWidgetsmod.sip
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
%Import QtGui/QtGuimod.sip
%Import QtWidgets/QtWidgetsmod.sip
%Import QtOpenGL/QtOpenGLmod.sip
%Import QtOpenGLWidgets/QtOpenGLWidgetsmod.sip
%Import QtAV/QtAVmod.sip

%Timeline {QtAVWidgets_1_11_0 QtAVWidgets_1_12_0}
Expand Down Expand Up @@ -35,7 +36,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
%Include global.sip

%If (FULL_QTWIDGETS_API)
%Include GLWidgetRenderer2.sip
%Include GraphicsItemRenderer.sip
// NOTE: We don't expose QOpenGLWidget because it is present in Qt >= 5.4.0
%Include OpenGLWidgetRenderer.sip
Expand Down
4 changes: 2 additions & 2 deletions python/sip/QtAVWidgets/WidgetRenderer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public:
QSize videoFrameSize();

public:
WidgetRenderer(QWidget* parent /TransferThis/ = 0, Qt::WindowFlags f = 0);
virtual VideoRendererId id();
WidgetRenderer(QWidget* parent /TransferThis/ = 0, Qt::WindowFlags f = Qt::WindowFlags());
VideoRendererId id();
virtual QWidget* widget();

signals:
Expand Down
1 change: 1 addition & 0 deletions src/AVError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
******************************************************************************/
#include "QtAV/AVError.h"
#include "QtAV/private/AVCompat.h"
#include <QtCore/QObject>
#ifndef QT_NO_DEBUG_STREAM
#include <QtCore/qdebug.h>
#endif
Expand Down
9 changes: 4 additions & 5 deletions src/codec/video/VideoDecoderDXVA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
//#include "QtAV/private/mkid.h"
#include "utils/Logger.h"
#include "directx/SurfaceInteropD3D9.h"
#include <QtCore/QSysInfo>
#define DX_LOG_COMPONENT "DXVA2"
#include "utils/DirectXHelper.h"

Expand Down Expand Up @@ -98,7 +97,7 @@ class VideoDecoderDXVAPrivate Q_DECL_FINAL: public VideoDecoderD3DPrivate
VideoDecoderD3DPrivate()
{
// d3d9+gl interop may not work on optimus moble platforms, 0-copy is enabled only for egl interop
if (d3d9::InteropResource::isSupported(d3d9::InteropEGL) && QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA)
if (d3d9::InteropResource::isSupported(d3d9::InteropEGL))
copy_mode = VideoDecoderFFmpegHW::ZeroCopy;

hd3d9_dll = 0;
Expand Down Expand Up @@ -269,9 +268,9 @@ bool VideoDecoderDXVAPrivate::createDevice()
return false;
}
vendor = QString::fromLatin1(DXHelper::vendorName(d3dai.VendorId));
description = QString().sprintf("DXVA2 (%.*s, vendor %lu(%s), device %lu, revision %lu)",
sizeof(d3dai.Description), d3dai.Description,
d3dai.VendorId, qPrintable(vendor), d3dai.DeviceId, d3dai.Revision);
description = QString().asprintf("DXVA2 (%.*s, vendor %lu(%s), device %lu, revision %lu)",
sizeof(d3dai.Description), d3dai.Description,
d3dai.VendorId, qPrintable(vendor), d3dai.DeviceId, d3dai.Revision);

//if (copy_uswc)
// copy_uswc = vendor.toLower() == "intel";
Expand Down
2 changes: 1 addition & 1 deletion src/cuda/cuda_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class cuda_api::context {

QLibrary cuda_dll;
QLibrary cuvid_dll;
typedef struct {
typedef struct cuda_api {
typedef CUresult CUDAAPI tcuGetErrorName(CUresult error, const char **pStr);
tcuGetErrorName* cuGetErrorName;
typedef CUresult CUDAAPI tcuGetErrorString(CUresult error, const char **pStr);
Expand Down
2 changes: 1 addition & 1 deletion src/filter/X11FilterContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void X11FilterContext::drawPlainText(const QPointF &pos, const QString &text)
this->plain = true;

QFontMetrics fm(font);
text_q = QImage(fm.width(text), fm.height(), QImage::Format_ARGB32);
text_q = QImage(fm.horizontalAdvance(text), fm.height(), QImage::Format_ARGB32);
text_q.fill(0);
painter->begin(&text_q);
painter->translate(0, 0);
Expand Down
2 changes: 1 addition & 1 deletion src/libQtAV.pro
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ MODULE_INCNAME = QtAV # for mac framework. also used in install_sdk.pro
TARGET = QtAV
QT += core gui
#CONFIG *= ltcg
greaterThan(QT_MAJOR_VERSION, 5): QT += opengl
greaterThan(QT_MAJOR_VERSION, 5): QT += opengl openglwidgets
greaterThan(QT_MAJOR_VERSION, 4) {
contains(QT_CONFIG, opengl) {
CONFIG *= config_opengl
Expand Down
3 changes: 2 additions & 1 deletion src/opengl/gl_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ void* GetProcAddress_Qt(const char *name)
void* p = (void*)QOpenGLContext::currentContext()->getProcAddress(QByteArray((const char*)name));
if (!p) {
#if defined(Q_OS_WIN) && defined(QT_OPENGL_DYNAMIC)
HMODULE handle = (HMODULE)QOpenGLContext::openGLModuleHandle();
using namespace QNativeInterface;
HMODULE handle = QWGLContext::openGLModuleHandle();
if (handle)
p = (void*)GetProcAddress(handle, name);
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/output/OutputSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#ifndef QTAV_OUTPUTSET_H
#define QTAV_OUTPUTSET_H

#include <climits>

#include <QtCore/QObject>
#include <QtCore/QMutex>
#include <QtCore/QWaitCondition>
Expand Down
6 changes: 6 additions & 0 deletions src/output/audio/AudioOutputDSound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ bool AudioOutputDSound::close()
available = false;
destroy();
CloseHandle(notify_event); // FIXME: is it ok if thread is still waiting?

// Wait for the PositionWatcher thread to stop.
while (watcher.isRunning()) {
watcher.wait(500);
}

return true;
}

Expand Down
3 changes: 1 addition & 2 deletions src/output/video/QPainterRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ void QPainterRenderer::drawBackground()
d.painter->fillRect(QRect(QPoint(), rendererSize()), backgroundColor());
d.painter->restore();
#else
const QVector<QRect> bg(bgRegion.rects());
foreach (const QRect& r, bg) {
foreach (const QRect& r, bgRegion) {
d.painter->fillRect(r, backgroundColor());
}
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/utils/BlockingQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#ifndef QTAV_BLOCKINGQUEUE_H
#define QTAV_BLOCKINGQUEUE_H

#include <climits>

#include <QtCore/QReadWriteLock>
#include <QtCore/QScopedPointer>
#include <QtCore/QWaitCondition>
Expand Down
2 changes: 1 addition & 1 deletion tools/templates/vo.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Q_AV_EXPORT %CLASS% : public QWidget, public VideoRenderer
Q_OBJECT
DPTR_DECLARE_PRIVATE(%CLASS%)
public:
%CLASS%(QWidget* parent = 0, Qt::WindowFlags f = 0);
%CLASS%(QWidget* parent = 0, Qt::WindowFlags f = Qt::WindowFlags());
virtual ~%CLASS%();

/* WA_PaintOnScreen: To render outside of Qt's paint system, e.g. If you require
Expand Down
2 changes: 1 addition & 1 deletion widgets/Direct2DRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Direct2DRenderer : public QWidget, public VideoRenderer
Q_OBJECT
DPTR_DECLARE_PRIVATE(Direct2DRenderer)
public:
Direct2DRenderer(QWidget* parent = 0, Qt::WindowFlags f = 0);
Direct2DRenderer(QWidget* parent = 0, Qt::WindowFlags f = Qt::WindowFlags());
VideoRendererId id() const Q_DECL_OVERRIDE;
bool isSupported(VideoFormat::PixelFormat pixfmt) const Q_DECL_OVERRIDE;

Expand Down
5 changes: 2 additions & 3 deletions widgets/GDIRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class GDIRenderer : public QWidget, public VideoRenderer
Q_OBJECT
DPTR_DECLARE_PRIVATE(GDIRenderer)
public:
GDIRenderer(QWidget* parent = 0, Qt::WindowFlags f = 0); //offscreen?
GDIRenderer(QWidget* parent = 0, Qt::WindowFlags f = Qt::WindowFlags()); //offscreen?
VideoRendererId id() const Q_DECL_OVERRIDE;
bool isSupported(VideoFormat::PixelFormat pixfmt) const Q_DECL_OVERRIDE;
/* WA_PaintOnScreen: To render outside of Qt's paint system, e.g. If you require
Expand Down Expand Up @@ -238,8 +238,7 @@ void GDIRenderer::drawBackground()
//HDC hdc = d.device_context;
Graphics g(d.device_context);
SolidBrush brush(Color(bc.alpha(), bc.red(), bc.green(), bc.blue())); //argb
const QVector<QRect> bg(bgRegion.rects());
foreach (const QRect& r, bg) {
foreach (const QRect& r, bgRegion) {
g.FillRectangle(&brush, r.x(), r.y(), r.width(), r.height());
}
}
Expand Down
2 changes: 1 addition & 1 deletion widgets/QtAVWidgets/GLWidgetRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Q_AVWIDGETS_EXPORT GLWidgetRenderer : public QGLWidget, public VideoRender
Q_OBJECT
DPTR_DECLARE_PRIVATE(GLWidgetRenderer)
public:
GLWidgetRenderer(QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = 0);
GLWidgetRenderer(QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = Qt::WindowFlags());
virtual VideoRendererId id() const;
virtual bool isSupported(VideoFormat::PixelFormat pixfmt) const;
virtual QWidget* widget() { return this; }
Expand Down
2 changes: 1 addition & 1 deletion widgets/QtAVWidgets/GLWidgetRenderer2.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Q_AVWIDGETS_EXPORT GLWidgetRenderer2 : public QGLWidget, public OpenGLRend
Q_PROPERTY(QSize videoFrameSize READ videoFrameSize NOTIFY videoFrameSizeChanged)
Q_ENUMS(Quality)
public:
GLWidgetRenderer2(QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = 0);
GLWidgetRenderer2(QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = Qt::WindowFlags());
virtual VideoRendererId id() const Q_DECL_OVERRIDE;
virtual QWidget* widget() Q_DECL_OVERRIDE { return this; }
Q_SIGNALS:
Expand Down
2 changes: 1 addition & 1 deletion widgets/QtAVWidgets/OpenGLWidgetRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include <QtAVWidgets/global.h>
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
#include <QOpenGLWidget>
#include <QtOpenGLWidgets/QOpenGLWidget>
#else
#include <QtAVWidgets/QOpenGLWidget.h>
#endif //QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
Expand Down
2 changes: 1 addition & 1 deletion widgets/QtAVWidgets/QOpenGLWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Q_AVWIDGETS_EXPORT QOpenGLWidget : public QWidget
Q_OBJECT
Q_DISABLE_COPY(QOpenGLWidget)
public:
explicit QOpenGLWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
explicit QOpenGLWidget(QWidget* parent = 0, Qt::WindowFlags f = Qt::WindowFlags());
virtual ~QOpenGLWidget();
void setFormat(const QSurfaceFormat &format);
QSurfaceFormat format() const;
Expand Down
5 changes: 2 additions & 3 deletions widgets/X11Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class X11Renderer: public QWidget, public VideoRenderer
Q_OBJECT
DPTR_DECLARE_PRIVATE(X11Renderer)
public:
X11Renderer(QWidget* parent = 0, Qt::WindowFlags f = 0);
X11Renderer(QWidget* parent = 0, Qt::WindowFlags f = Qt::WindowFlags());
VideoRendererId id() const Q_DECL_OVERRIDE;
bool isSupported(VideoFormat::PixelFormat pixfmt) const Q_DECL_OVERRIDE;

Expand Down Expand Up @@ -441,8 +441,7 @@ void X11Renderer::drawBackground()
// TODO: fill once each resize? mpv
// TODO: set color
//XSetBackground(d.display, d.gc, BlackPixel(d.display, DefaultScreen(d.display)));
const QVector<QRect> bg(bgRegion.rects());
foreach (const QRect& r, bg) {
foreach (const QRect& r, bgRegion) {
XFillRectangle(d.display, winId(), d.gc, r.x(), r.y(), r.width(), r.height());
}
XFlush(d.display); // apply the color
Expand Down
5 changes: 2 additions & 3 deletions widgets/XVRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class XVRenderer: public QWidget, public VideoRenderer
Q_OBJECT
DPTR_DECLARE_PRIVATE(XVRenderer)
public:
XVRenderer(QWidget* parent = 0, Qt::WindowFlags f = 0);
XVRenderer(QWidget* parent = 0, Qt::WindowFlags f = Qt::WindowFlags());
virtual VideoRendererId id() const Q_DECL_OVERRIDE;
virtual bool isSupported(VideoFormat::PixelFormat pixfmt) const Q_DECL_OVERRIDE;

Expand Down Expand Up @@ -492,8 +492,7 @@ void XVRenderer::drawBackground()
return;
DPTR_D(XVRenderer);
// TODO: set color
const QVector<QRect> bg(bgRegion.rects());
foreach (const QRect& r, bg) {
foreach (const QRect& r, bgRegion) {
XFillRectangle(d.display, winId(), d.gc, r.x(), r.y(), r.width(), r.height());
}
XFlush(d.display);
Expand Down