diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-10-20 03:01:42 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-10-20 03:01:42 +0200 |
commit | 023c48830386566042497bfac2a01c713bc5423b (patch) | |
tree | b3308e3074e3f8169b9817009623d9ed4996538f /src/plugins | |
parent | b62ade1c474026dc2300ad25be02bba28d32096f (diff) | |
parent | 30cbbd98e7159de08bb71ab4332dbd0bab19eba5 (diff) |
Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: Id4521553c437efa66ad52b2e419b446184a0ec11
Diffstat (limited to 'src/plugins')
7 files changed, 101 insertions, 63 deletions
diff --git a/src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/QtAndroidMediaPlayer.java b/src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/QtAndroidMediaPlayer.java index b1da2f1fa..647cc7fe0 100644 --- a/src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/QtAndroidMediaPlayer.java +++ b/src/plugins/android/jar/src/org/qtproject/qt5/android/multimedia/QtAndroidMediaPlayer.java @@ -378,7 +378,7 @@ public class QtAndroidMediaPlayer FileDescriptor fd = fis.getFD(); mMediaPlayer.setDataSource(fd); } else { - mMediaPlayer.setDataSource(mContext, mUri); + mMediaPlayer.setDataSource(path); } setState(State.Initialized); } catch (final IOException e) { diff --git a/src/plugins/common/evr/evrd3dpresentengine.cpp b/src/plugins/common/evr/evrd3dpresentengine.cpp index 12b907336..ab694b795 100644 --- a/src/plugins/common/evr/evrd3dpresentengine.cpp +++ b/src/plugins/common/evr/evrd3dpresentengine.cpp @@ -143,11 +143,11 @@ public: return m_glTexture; } - bool createTexture(const QVideoSurfaceFormat &format, IDirect3DDevice9Ex *device, + void createTexture(const QVideoSurfaceFormat &format, IDirect3DDevice9Ex *device, IDirect3DTexture9 **texture) { if (!m_glContext) - return false; + return; m_glContext->functions()->glGenTextures(1, &m_glTexture); QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); @@ -185,8 +185,6 @@ public: m_glContext->functions()->glBindTexture(GL_TEXTURE_2D, m_glTexture); m_egl->bindTexImage(m_eglDisplay, m_eglSurface, EGL_BACK_BUFFER); - - return texture != NULL; } void release() @@ -238,7 +236,6 @@ public: , m_sample(sample) , m_surface(0) , m_mapMode(NotMapped) - , m_textureUpdated(false) { if (m_sample) { m_sample->AddRef(); @@ -276,7 +273,7 @@ private: IMFSample *m_sample; IDirect3DSurface9 *m_surface; MapMode m_mapMode; - mutable bool m_textureUpdated; + mutable unsigned int m_textureId = 0; }; uchar *IMFSampleVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine) @@ -314,19 +311,12 @@ void IMFSampleVideoBuffer::unmap() QVariant IMFSampleVideoBuffer::handle() const { - QVariant handle; - #ifdef MAYBE_ANGLE - if (handleType() != GLTextureHandle) - return handle; - - if (m_textureUpdated || m_engine->updateTexture(m_surface)) { - m_textureUpdated = true; - handle = QVariant::fromValue<unsigned int>(m_engine->m_glResources->glTexture()); - } + if (handleType() == GLTextureHandle && !m_textureId) + m_textureId = m_engine->updateTexture(m_surface); #endif - return handle; + return m_textureId; } @@ -618,24 +608,20 @@ QVideoFrame D3DPresentEngine::makeVideoFrame(IMFSample *sample) #ifdef MAYBE_ANGLE -bool D3DPresentEngine::createRenderTexture() +unsigned int D3DPresentEngine::updateTexture(IDirect3DSurface9 *src) { - if (m_glResources) - m_glResources->release(); + if (!m_texture) { + if (m_glResources) + m_glResources->release(); - m_glResources = new OpenGLResources; - return m_glResources->createTexture(m_surfaceFormat, m_device, &m_texture); -} - -bool D3DPresentEngine::updateTexture(IDirect3DSurface9 *src) -{ - if (!m_texture && !createRenderTexture()) - return false; + m_glResources = new OpenGLResources; + m_glResources->createTexture(m_surfaceFormat, m_device, &m_texture); + } IDirect3DSurface9 *dest = NULL; // Copy the sample surface to the shared D3D/EGL surface - HRESULT hr = m_texture->GetSurfaceLevel(0, &dest); + HRESULT hr = m_texture ? m_texture->GetSurfaceLevel(0, &dest) : E_FAIL; if (FAILED(hr)) goto done; @@ -657,7 +643,7 @@ bool D3DPresentEngine::updateTexture(IDirect3DSurface9 *src) done: qt_evr_safe_release(&dest); - return SUCCEEDED(hr); + return (SUCCEEDED(hr) && m_glResources) ? m_glResources->glTexture() : 0; } #endif // MAYBE_ANGLE diff --git a/src/plugins/common/evr/evrd3dpresentengine.h b/src/plugins/common/evr/evrd3dpresentengine.h index df2c9b506..8e2a444f3 100644 --- a/src/plugins/common/evr/evrd3dpresentengine.h +++ b/src/plugins/common/evr/evrd3dpresentengine.h @@ -143,8 +143,7 @@ private: bool m_useTextureRendering; #ifdef MAYBE_ANGLE - bool createRenderTexture(); - bool updateTexture(IDirect3DSurface9 *src); + unsigned int updateTexture(IDirect3DSurface9 *src); OpenGLResources *m_glResources; IDirect3DTexture9 *m_texture; diff --git a/src/plugins/directshow/camera/dscameracontrol.cpp b/src/plugins/directshow/camera/dscameracontrol.cpp index 8dc0d4136..67971d1b5 100644 --- a/src/plugins/directshow/camera/dscameracontrol.cpp +++ b/src/plugins/directshow/camera/dscameracontrol.cpp @@ -51,7 +51,7 @@ DSCameraControl::DSCameraControl(QObject *parent) , m_captureMode(QCamera::CaptureStillImage) { m_session = qobject_cast<DSCameraSession*>(parent); - connect(m_session, &DSCameraSession::statusChanged, + connect(m_session, &DSCameraSession::statusChanged, this, [&](QCamera::Status status) { if (status == QCamera::UnloadedStatus) m_state = QCamera::UnloadedState; diff --git a/src/plugins/qnx/mediaplayer/mmrenderermetadata.cpp b/src/plugins/qnx/mediaplayer/mmrenderermetadata.cpp index 50b45382c..a8b92c267 100644 --- a/src/plugins/qnx/mediaplayer/mmrenderermetadata.cpp +++ b/src/plugins/qnx/mediaplayer/mmrenderermetadata.cpp @@ -42,6 +42,8 @@ #include <QtCore/qfile.h> #include <QtCore/qstringlist.h> +#include <mm/renderer/events.h> +#include <sys/neutrino.h> #include <sys/strm.h> static const char *strm_string_getx(const strm_string_t *sstr, const char *defaultValue) @@ -49,6 +51,13 @@ static const char *strm_string_getx(const strm_string_t *sstr, const char *defau return sstr ? strm_string_get(sstr) : defaultValue; } +#if _NTO_VERSION < 700 +static strm_dict_t *mmr_metadata_split(strm_dict_t const *, const char *, unsigned) +{ + return nullptr; +} +#endif + QT_BEGIN_NAMESPACE MmRendererMetaData::MmRendererMetaData() @@ -72,6 +81,12 @@ static const char * mediaTypeKey = "md_title_mediatype"; static const char * pixelWidthKey = "md_video_pixel_width"; static const char * pixelHeightKey = "md_video_pixel_height"; static const char * seekableKey = "md_title_seekable"; +static const char * trackSampleKey = "sample_rate"; +static const char * trackBitRateKey = "bitrate"; +static const char * trackWidthKey = "width"; +static const char * trackHeightKey = "height"; +static const char * trackPixelWidthKey = "pixel_width"; +static const char * trackPixelHeightKey = "pixel_height"; static const int mediaTypeAudioFlag = 4; static const int mediaTypeVideoFlag = 2; @@ -88,21 +103,9 @@ bool MmRendererMetaData::update(const strm_dict_t *dict) value = strm_dict_find_rstr(dict, durationKey); m_duration = QByteArray(strm_string_getx(value, "0")).toLongLong(); - value = strm_dict_find_rstr(dict, widthKey); - m_width = QByteArray(strm_string_getx(value, "0")).toInt(); - - value = strm_dict_find_rstr(dict, heightKey); - m_height = QByteArray(strm_string_getx(value, "0")).toInt(); - value = strm_dict_find_rstr(dict, mediaTypeKey); m_mediaType = QByteArray(strm_string_getx(value, "-1")).toInt(); - value = strm_dict_find_rstr(dict, pixelWidthKey); - m_pixelWidth = QByteArray(strm_string_getx(value, "1")).toFloat(); - - value = strm_dict_find_rstr(dict, pixelHeightKey); - m_pixelHeight = QByteArray(strm_string_getx(value, "1")).toFloat(); - value = strm_dict_find_rstr(dict, titleKey); m_title = QString::fromLatin1(QByteArray(strm_string_getx(value, nullptr))); @@ -121,18 +124,58 @@ bool MmRendererMetaData::update(const strm_dict_t *dict) value = strm_dict_find_rstr(dict, yearKey); m_year = QByteArray(strm_string_getx(value, "0")).toInt(); - value = strm_dict_find_rstr(dict, bitRateKey); - m_audioBitRate = QByteArray(strm_string_getx(value, "0")).toInt(); - - value = strm_dict_find_rstr(dict, sampleKey); - m_sampleRate = QByteArray(strm_string_getx(value, "0")).toInt(); - value = strm_dict_find_rstr(dict, albumKey); m_album = QString::fromLatin1(QByteArray(strm_string_getx(value, nullptr))); value = strm_dict_find_rstr(dict, trackKey); m_track = QByteArray(strm_string_getx(value, "0")).toInt(); + strm_dict_t *at = mmr_metadata_split(dict, "audio", 0); + if (at) { + value = strm_dict_find_rstr(at, trackSampleKey); + m_sampleRate = QByteArray(strm_string_getx(value, "0")).toInt(); + + value = strm_dict_find_rstr(at, trackBitRateKey); + m_audioBitRate = QByteArray(strm_string_getx(value, "0")).toInt(); + + strm_dict_destroy(at); + } else { + value = strm_dict_find_rstr(dict, sampleKey); + m_sampleRate = QByteArray(strm_string_getx(value, "0")).toInt(); + + value = strm_dict_find_rstr(dict, bitRateKey); + m_audioBitRate = QByteArray(strm_string_getx(value, "0")).toInt(); + } + + strm_dict_t *vt = mmr_metadata_split(dict, "video", 0); + if (vt) { + value = strm_dict_find_rstr(vt, trackWidthKey); + m_width = QByteArray(strm_string_getx(value, "0")).toInt(); + + value = strm_dict_find_rstr(vt, trackHeightKey); + m_height = QByteArray(strm_string_getx(value, "0")).toInt(); + + value = strm_dict_find_rstr(vt, trackPixelWidthKey); + m_pixelWidth = QByteArray(strm_string_getx(value, "1")).toFloat(); + + value = strm_dict_find_rstr(vt, trackPixelHeightKey); + m_pixelHeight = QByteArray(strm_string_getx(value, "1")).toFloat(); + + strm_dict_destroy(vt); + } else { + value = strm_dict_find_rstr(dict, widthKey); + m_width = QByteArray(strm_string_getx(value, "0")).toInt(); + + value = strm_dict_find_rstr(dict, heightKey); + m_height = QByteArray(strm_string_getx(value, "0")).toInt(); + + value = strm_dict_find_rstr(dict, pixelWidthKey); + m_pixelWidth = QByteArray(strm_string_getx(value, "1")).toFloat(); + + value = strm_dict_find_rstr(dict, pixelHeightKey); + m_pixelHeight = QByteArray(strm_string_getx(value, "1")).toFloat(); + } + return true; } diff --git a/src/plugins/windowsaudio/qwindowsaudiooutput.cpp b/src/plugins/windowsaudio/qwindowsaudiooutput.cpp index 26eecb768..f39e1694b 100644 --- a/src/plugins/windowsaudio/qwindowsaudiooutput.cpp +++ b/src/plugins/windowsaudio/qwindowsaudiooutput.cpp @@ -74,6 +74,7 @@ QWindowsAudioOutput::QWindowsAudioOutput(const QByteArray &device) pullMode = true; finished = false; volumeCache = qreal(1.0); + blocks_count = 5; } QWindowsAudioOutput::~QWindowsAudioOutput() @@ -110,8 +111,9 @@ void CALLBACK QWindowsAudioOutput::waveOutProc( HWAVEOUT hWaveOut, UINT uMsg, return; } qAudio->waveFreeBlockCount++; - if(qAudio->waveFreeBlockCount >= qAudio->buffer_size/qAudio->period_size) - qAudio->waveFreeBlockCount = qAudio->buffer_size/qAudio->period_size; + if (qAudio->waveFreeBlockCount >= qAudio->blocks_count) + qAudio->waveFreeBlockCount = qAudio->blocks_count; + qAudio->feedback(); break; default: @@ -144,10 +146,7 @@ WAVEHDR* QWindowsAudioOutput::allocateBlocks(int size, int count) void QWindowsAudioOutput::freeBlocks(WAVEHDR* blockArray) { WAVEHDR* blocks = blockArray; - - int count = buffer_size/period_size; - - for(int i = 0; i < count; i++) { + for (int i = 0; i < blocks_count; ++i) { waveOutUnprepareHeader(hWaveOut,blocks, sizeof(WAVEHDR)); blocks++; } @@ -252,16 +251,26 @@ bool QWindowsAudioOutput::open() return false; } - waveBlocks = allocateBlocks(period_size, buffer_size/period_size); + const int periods = buffer_size / period_size; + bool ok = false; + static int wave_buffers = qEnvironmentVariableIntValue("QT_WAVE_BUFFERS", &ok); + if (wave_buffers < periods) { + if (ok) + qWarning("Number of WAVE buffers (QT_WAVE_BUFFERS=%d) cannot be less than %d.", wave_buffers, periods); + wave_buffers = periods; + } + + blocks_count = wave_buffers; + waveBlocks = allocateBlocks(period_size, blocks_count); mutex.lock(); - waveFreeBlockCount = buffer_size/period_size; + waveFreeBlockCount = blocks_count; mutex.unlock(); waveCurrentBlock = 0; if(audioBuffer == 0) - audioBuffer = new char[buffer_size]; + audioBuffer = new char[blocks_count * period_size]; timeStamp.restart(); elapsedTimeOffset = 0; @@ -440,7 +449,7 @@ qint64 QWindowsAudioOutput::write( const char *data, qint64 len ) totalTimeValue += current->dwBufferLength; waveCurrentBlock++; - waveCurrentBlock %= buffer_size/period_size; + waveCurrentBlock %= blocks_count; current = &waveBlocks[waveCurrentBlock]; current->dwUser = 0; errorState = QAudio::NoError; @@ -547,7 +556,7 @@ bool QWindowsAudioOutput::deviceReady() check = waveFreeBlockCount; mutex.unlock(); - if(check == buffer_size/period_size) { + if (check == blocks_count) { if (deviceState != QAudio::IdleState) { errorState = QAudio::UnderrunError; deviceState = QAudio::IdleState; @@ -567,7 +576,7 @@ bool QWindowsAudioOutput::deviceReady() buffered = waveFreeBlockCount; mutex.unlock(); - if (buffered >= buffer_size/period_size && deviceState == QAudio::ActiveState) { + if (buffered >= blocks_count && deviceState == QAudio::ActiveState) { if (deviceState != QAudio::IdleState) { errorState = QAudio::UnderrunError; deviceState = QAudio::IdleState; diff --git a/src/plugins/windowsaudio/qwindowsaudiooutput.h b/src/plugins/windowsaudio/qwindowsaudiooutput.h index b71f00e98..30ee1defe 100644 --- a/src/plugins/windowsaudio/qwindowsaudiooutput.h +++ b/src/plugins/windowsaudio/qwindowsaudiooutput.h @@ -123,6 +123,7 @@ private: QTime timeStampOpened; qint32 buffer_size; qint32 period_size; + qint32 blocks_count; qint64 totalTimeValue; bool pullMode; int intervalTime; |