diff options
Diffstat (limited to 'src')
9 files changed, 128 insertions, 98 deletions
diff --git a/src/multimedia/audio/qsamplecache_p.cpp b/src/multimedia/audio/qsamplecache_p.cpp index 487346832..c76f51899 100644 --- a/src/multimedia/audio/qsamplecache_p.cpp +++ b/src/multimedia/audio/qsamplecache_p.cpp @@ -140,8 +140,11 @@ void QSampleCache::loadingRelease() QMutexLocker locker(&m_loadingMutex); m_loadingRefCount--; if (m_loadingRefCount == 0) { - if (m_loadingThread.isRunning()) + if (m_loadingThread.isRunning()) { + m_networkAccessManager->deleteLater(); + m_networkAccessManager = nullptr; m_loadingThread.exit(); + } } } diff --git a/src/plugins/avfoundation/camera/avfcamerasession.mm b/src/plugins/avfoundation/camera/avfcamerasession.mm index 0b7c0e9d8..8e3436d39 100644 --- a/src/plugins/avfoundation/camera/avfcamerasession.mm +++ b/src/plugins/avfoundation/camera/avfcamerasession.mm @@ -234,7 +234,7 @@ void AVFCameraSession::updateCameraDevices() break; case AVCaptureDevicePositionFront: info.position = QCamera::FrontFace; - info.orientation = 270; + info.orientation = 90; break; default: info.position = QCamera::UnspecifiedPosition; diff --git a/src/plugins/common/evr/evrd3dpresentengine.cpp b/src/plugins/common/evr/evrd3dpresentengine.cpp index 32d0acf91..54403faba 100644 --- a/src/plugins/common/evr/evrd3dpresentengine.cpp +++ b/src/plugins/common/evr/evrd3dpresentengine.cpp @@ -47,6 +47,7 @@ #include <QDebug> #include <qthread.h> #include <private/qmediaopenglhelper_p.h> +#include <QOffscreenSurface> #ifdef MAYBE_ANGLE # include <qguiapplication.h> @@ -128,11 +129,65 @@ class OpenGLResources : public QObject { public: OpenGLResources() - : egl(new EGLWrapper) - , eglDisplay(0) - , eglSurface(0) - , glTexture(0) - {} + : m_egl(new EGLWrapper) + , m_eglDisplay(nullptr) + , m_eglSurface(nullptr) + , m_glTexture(0) + , m_glContext(QOpenGLContext::currentContext()) + { + Q_ASSERT(m_glContext); + } + + unsigned int glTexture() const + { + return m_glTexture; + } + + bool createTexture(const QVideoSurfaceFormat &format, IDirect3DDevice9Ex *device, + IDirect3DTexture9 **texture) + { + if (!m_glContext) + return false; + + m_glContext->functions()->glGenTextures(1, &m_glTexture); + QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); + m_eglDisplay = static_cast<EGLDisplay*>( + nativeInterface->nativeResourceForContext("eglDisplay", m_glContext)); + EGLConfig *eglConfig = static_cast<EGLConfig*>( + nativeInterface->nativeResourceForContext("eglConfig", m_glContext)); + + const bool hasAlpha = m_glContext->format().hasAlpha(); + + EGLint attribs[] = { + EGL_WIDTH, format.frameWidth(), + EGL_HEIGHT, format.frameHeight(), + EGL_TEXTURE_FORMAT, (hasAlpha ? EGL_TEXTURE_RGBA : EGL_TEXTURE_RGB), + EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, + EGL_NONE + }; + + m_eglSurface = m_egl->createPbufferSurface(m_eglDisplay, eglConfig, attribs); + + HANDLE share_handle = 0; + PFNEGLQUERYSURFACEPOINTERANGLEPROC eglQuerySurfacePointerANGLE = + reinterpret_cast<PFNEGLQUERYSURFACEPOINTERANGLEPROC>( + m_egl->getProcAddress("eglQuerySurfacePointerANGLE")); + Q_ASSERT(eglQuerySurfacePointerANGLE); + eglQuerySurfacePointerANGLE( + m_eglDisplay, + m_eglSurface, + EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, &share_handle); + + device->CreateTexture(format.frameWidth(), format.frameHeight(), 1, + D3DUSAGE_RENDERTARGET, + (hasAlpha ? D3DFMT_A8R8G8B8 : D3DFMT_X8R8G8B8), + D3DPOOL_DEFAULT, texture, &share_handle); + + m_glContext->functions()->glBindTexture(GL_TEXTURE_2D, m_glTexture); + m_egl->bindTexImage(m_eglDisplay, m_eglSurface, EGL_BACK_BUFFER); + + return texture != NULL; + } void release() { @@ -142,24 +197,32 @@ public: deleteLater(); } - EGLWrapper *egl; - EGLDisplay *eglDisplay; - EGLSurface eglSurface; - unsigned int glTexture; - private: + EGLWrapper *m_egl; + EGLDisplay *m_eglDisplay; + EGLSurface m_eglSurface; + unsigned int m_glTexture; + QOpenGLContext *m_glContext; + ~OpenGLResources() { - Q_ASSERT(QOpenGLContext::currentContext() != NULL); + QScopedPointer<QOffscreenSurface> surface; + if (m_glContext != QOpenGLContext::currentContext()) { + surface.reset(new QOffscreenSurface); + surface->create(); + m_glContext->makeCurrent(surface.data()); + } - if (eglSurface && egl) { - egl->releaseTexImage(eglDisplay, eglSurface, EGL_BACK_BUFFER); - egl->destroySurface(eglDisplay, eglSurface); + if (m_eglSurface && m_egl) { + m_egl->releaseTexImage(m_eglDisplay, m_eglSurface, EGL_BACK_BUFFER); + m_egl->destroySurface(m_eglDisplay, m_eglSurface); } - if (glTexture) - QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &glTexture); + if (m_glTexture) + m_glContext->functions()->glDeleteTextures(1, &m_glTexture); - delete egl; + delete m_egl; + if (surface) + m_glContext->doneCurrent(); } }; @@ -257,9 +320,9 @@ QVariant IMFSampleVideoBuffer::handle() const if (handleType() != GLTextureHandle) return handle; - if (m_engine->m_glResources && (m_textureUpdated || m_engine->updateTexture(m_surface))) { + if (m_textureUpdated || m_engine->updateTexture(m_surface)) { m_textureUpdated = true; - handle = QVariant::fromValue<unsigned int>(m_engine->m_glResources->glTexture); + handle = QVariant::fromValue<unsigned int>(m_engine->m_glResources->glTexture()); } #endif @@ -557,61 +620,11 @@ QVideoFrame D3DPresentEngine::makeVideoFrame(IMFSample *sample) bool D3DPresentEngine::createRenderTexture() { - if (m_texture) - return true; - - Q_ASSERT(QOpenGLContext::currentContext() != NULL); - - if (!m_glResources) - m_glResources = new OpenGLResources; - - QOpenGLContext *currentContext = QOpenGLContext::currentContext(); - if (!currentContext) - return false; - - QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); - m_glResources->eglDisplay = static_cast<EGLDisplay*>( - nativeInterface->nativeResourceForContext("eglDisplay", currentContext)); - EGLConfig *eglConfig = static_cast<EGLConfig*>( - nativeInterface->nativeResourceForContext("eglConfig", currentContext)); - - currentContext->functions()->glGenTextures(1, &m_glResources->glTexture); - - bool hasAlpha = currentContext->format().hasAlpha(); - - EGLint attribs[] = { - EGL_WIDTH, m_surfaceFormat.frameWidth(), - EGL_HEIGHT, m_surfaceFormat.frameHeight(), - EGL_TEXTURE_FORMAT, hasAlpha ? EGL_TEXTURE_RGBA : EGL_TEXTURE_RGB, - EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, - EGL_NONE - }; - - EGLSurface pbuffer = m_glResources->egl->createPbufferSurface(m_glResources->eglDisplay, eglConfig, attribs); - - HANDLE share_handle = 0; - PFNEGLQUERYSURFACEPOINTERANGLEPROC eglQuerySurfacePointerANGLE = - reinterpret_cast<PFNEGLQUERYSURFACEPOINTERANGLEPROC>(m_glResources->egl->getProcAddress("eglQuerySurfacePointerANGLE")); - Q_ASSERT(eglQuerySurfacePointerANGLE); - eglQuerySurfacePointerANGLE( - m_glResources->eglDisplay, - pbuffer, - EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, &share_handle); - - - m_device->CreateTexture(m_surfaceFormat.frameWidth(), m_surfaceFormat.frameHeight(), 1, - D3DUSAGE_RENDERTARGET, - hasAlpha ? D3DFMT_A8R8G8B8 : D3DFMT_X8R8G8B8, - D3DPOOL_DEFAULT, - &m_texture, - &share_handle); - - m_glResources->eglSurface = pbuffer; - - QOpenGLContext::currentContext()->functions()->glBindTexture(GL_TEXTURE_2D, m_glResources->glTexture); - m_glResources->egl->bindTexImage(m_glResources->eglDisplay, m_glResources->eglSurface, EGL_BACK_BUFFER); + if (m_glResources) + m_glResources->release(); - return m_texture != NULL; + m_glResources = new OpenGLResources; + return m_glResources->createTexture(m_surfaceFormat, m_device, &m_texture); } bool D3DPresentEngine::updateTexture(IDirect3DSurface9 *src) diff --git a/src/plugins/directshow/player/directshowplayerservice.cpp b/src/plugins/directshow/player/directshowplayerservice.cpp index 8ee5d67a1..2218ca5ed 100644 --- a/src/plugins/directshow/player/directshowplayerservice.cpp +++ b/src/plugins/directshow/player/directshowplayerservice.cpp @@ -318,18 +318,15 @@ void DirectShowPlayerService::load(const QMediaContent &media, QIODevice *stream m_graphStatus = InvalidMedia; m_error = QMediaPlayer::ResourceError; } else { - // {36b73882-c2c8-11cf-8b46-00805f6cef60} - static const GUID iid_IFilterGraph2 = { - 0x36b73882, 0xc2c8, 0x11cf, {0x8b, 0x46, 0x00, 0x80, 0x5f, 0x6c, 0xef, 0x60} }; m_graphStatus = Loading; - m_graph = com_new<IFilterGraph2>(CLSID_FilterGraph, iid_IFilterGraph2); - if (stream) m_pendingTasks = SetStreamSource; else m_pendingTasks = SetUrlSource; + m_pendingTasks |= CreateGraph; + ::SetEvent(m_taskHandle); } @@ -340,6 +337,17 @@ void DirectShowPlayerService::load(const QMediaContent &media, QIODevice *stream updateStatus(); } +void DirectShowPlayerService::doCreateGraph(QMutexLocker *locker) +{ + Q_UNUSED(locker); + + // {36b73882-c2c8-11cf-8b46-00805f6cef60} + static const GUID iid_IFilterGraph2 = { + 0x36b73882, 0xc2c8, 0x11cf, {0x8b, 0x46, 0x00, 0x80, 0x5f, 0x6c, 0xef, 0x60} }; + + m_graph = com_new<IFilterGraph2>(CLSID_FilterGraphNoThread, iid_IFilterGraph2); +} + void DirectShowPlayerService::doSetUrlSource(QMutexLocker *locker) { IBaseFilter *source = 0; @@ -1686,6 +1694,8 @@ void DirectShowPlayerService::run() { QMutexLocker locker(&m_mutex); + CoInitialize(NULL); + for (;;) { while (m_pendingTasks == 0) { DWORD result = 0; @@ -1700,12 +1710,17 @@ void DirectShowPlayerService::run() } locker.relock(); - if (result == WAIT_OBJECT_0 + 1) { + if (m_graph && result == WAIT_OBJECT_0 + 1) { graphEvent(&locker); } } - if (m_pendingTasks & ReleaseGraph) { + if (m_pendingTasks & CreateGraph) { + m_pendingTasks ^= CreateGraph; + m_executingTask = CreateGraph; + + doCreateGraph(&locker); + } else if (m_pendingTasks & ReleaseGraph) { m_pendingTasks ^= ReleaseGraph; m_executingTask = ReleaseGraph; @@ -1798,6 +1813,8 @@ void DirectShowPlayerService::run() } m_executingTask = 0; } + + CoUninitialize(); } QT_END_NAMESPACE diff --git a/src/plugins/directshow/player/directshowplayerservice.h b/src/plugins/directshow/player/directshowplayerservice.h index 01d05449e..cc7b4dd3e 100644 --- a/src/plugins/directshow/player/directshowplayerservice.h +++ b/src/plugins/directshow/player/directshowplayerservice.h @@ -124,6 +124,7 @@ private: void run(); + void doCreateGraph(QMutexLocker *locker); void doSetUrlSource(QMutexLocker *locker); void doSetStreamSource(QMutexLocker *locker); void doRender(QMutexLocker *locker); @@ -169,7 +170,8 @@ private: ReleaseVideoProbe = 0x40000, ReleaseFilters = ReleaseGraph | ReleaseAudioOutput | ReleaseVideoOutput | ReleaseAudioProbe - | ReleaseVideoProbe + | ReleaseVideoProbe, + CreateGraph = 0x80000 }; enum Event diff --git a/src/plugins/gstreamer/camerabin/camerabinsession.cpp b/src/plugins/gstreamer/camerabin/camerabinsession.cpp index 823cfe408..cfac61c01 100644 --- a/src/plugins/gstreamer/camerabin/camerabinsession.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinsession.cpp @@ -732,18 +732,21 @@ void CameraBinSession::setState(QCamera::State newState) if (newState == m_pendingState) return; - m_pendingState = newState; - emit pendingStateChanged(m_pendingState); + emit pendingStateChanged(newState); #if CAMERABIN_DEBUG qDebug() << Q_FUNC_INFO << newState; #endif setStateHelper(newState); + m_pendingState = newState; } void CameraBinSession::setStateHelper(QCamera::State state) { + if (state == m_pendingState) + return; + switch (state) { case QCamera::UnloadedState: unload(); diff --git a/src/plugins/windowsaudio/qwindowsaudiodeviceinfo.cpp b/src/plugins/windowsaudio/qwindowsaudiodeviceinfo.cpp index 83e9ccfc8..c054c0f76 100644 --- a/src/plugins/windowsaudio/qwindowsaudiodeviceinfo.cpp +++ b/src/plugins/windowsaudio/qwindowsaudiodeviceinfo.cpp @@ -238,21 +238,16 @@ void QWindowsAudioDeviceInfo::updateLists() if (!sizez.isEmpty()) return; - bool hasCaps = false; DWORD fmt = 0; if(mode == QAudio::AudioOutput) { WAVEOUTCAPS woc; - if (waveOutGetDevCaps(devId, &woc, sizeof(WAVEOUTCAPS)) == MMSYSERR_NOERROR) { - hasCaps = true; + if (waveOutGetDevCaps(devId, &woc, sizeof(WAVEOUTCAPS)) == MMSYSERR_NOERROR) fmt = woc.dwFormats; - } } else { WAVEINCAPS woc; - if (waveInGetDevCaps(devId, &woc, sizeof(WAVEINCAPS)) == MMSYSERR_NOERROR) { - hasCaps = true; + if (waveInGetDevCaps(devId, &woc, sizeof(WAVEINCAPS)) == MMSYSERR_NOERROR) fmt = woc.dwFormats; - } } sizez.clear(); @@ -260,7 +255,7 @@ void QWindowsAudioDeviceInfo::updateLists() channelz.clear(); typez.clear(); - if (hasCaps) { + if (fmt) { // Check sample size if ((fmt & WAVE_FORMAT_1M08) || (fmt & WAVE_FORMAT_1S08) diff --git a/src/plugins/windowsaudio/qwindowsaudiooutput.cpp b/src/plugins/windowsaudio/qwindowsaudiooutput.cpp index 815b78979..eb4caf128 100644 --- a/src/plugins/windowsaudio/qwindowsaudiooutput.cpp +++ b/src/plugins/windowsaudio/qwindowsaudiooutput.cpp @@ -298,10 +298,7 @@ void QWindowsAudioOutput::close() deviceState = QAudio::StoppedState; errorState = QAudio::NoError; - int delay = (buffer_size-bytesFree())*1000/(settings.sampleRate() - *settings.channelCount()*(settings.sampleSize()/8)); waveOutReset(hWaveOut); - Sleep(delay+10); freeBlocks(waveBlocks); waveOutClose(hWaveOut); diff --git a/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp b/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp index f1b7662b5..0cb6659ca 100644 --- a/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp +++ b/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp @@ -382,9 +382,9 @@ QAbstractVideoSurface *QDeclarativeVideoRendererBackend::videoSurface() const QRectF QDeclarativeVideoRendererBackend::adjustedViewport() const { const QRectF viewport = m_surface->surfaceFormat().viewport(); - const QSize pixelAspectRatio = m_surface->surfaceFormat().pixelAspectRatio(); + const QSizeF pixelAspectRatio = m_surface->surfaceFormat().pixelAspectRatio(); - if (pixelAspectRatio.height() != 0) { + if (pixelAspectRatio.isValid()) { const qreal ratio = pixelAspectRatio.width() / pixelAspectRatio.height(); QRectF result = viewport; result.setX(result.x() * ratio); |