From be7f8d3a49fc6d5d31e6fe61f9ba2dec43341e90 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 5 Sep 2018 09:58:46 +0200 Subject: DirectShow: Fix clang-tidy warnings about else after return - Unindent the code or replace by switch () - Smaller fixups when reindenting (nullptr, use QStringView for comparison against wchar_t) Change-Id: I249cb00b9ebe375b089d8d53b10c2d16d5771680 Reviewed-by: Oliver Wolff --- src/plugins/common/evr/evrcustompresenter.cpp | 24 ++- src/plugins/common/evr/evrhelpers.cpp | 8 +- .../camera/directshowcameraexposurecontrol.cpp | 18 +- src/plugins/directshow/camera/dscamerasession.cpp | 18 +- .../directshow/common/directshowbasefilter.cpp | 75 ++++--- .../directshow/common/directshowmediatype.cpp | 3 +- .../directshow/common/directshowmediatypeenum.cpp | 34 ++-- src/plugins/directshow/common/directshowpin.cpp | 92 ++++----- .../directshow/common/directshowpinenum.cpp | 35 ++-- src/plugins/directshow/dsserviceplugin.cpp | 7 +- .../directshow/player/directshowioreader.cpp | 218 +++++++++------------ .../directshow/player/directshowiosource.cpp | 214 ++++++++------------ .../player/directshowmetadatacontrol.cpp | 92 +++++---- .../directshow/player/directshowplayerservice.cpp | 11 +- .../directshow/player/videosurfacefilter.cpp | 32 +-- 15 files changed, 388 insertions(+), 493 deletions(-) diff --git a/src/plugins/common/evr/evrcustompresenter.cpp b/src/plugins/common/evr/evrcustompresenter.cpp index 7a8985301..5ebde2dda 100644 --- a/src/plugins/common/evr/evrcustompresenter.cpp +++ b/src/plugins/common/evr/evrcustompresenter.cpp @@ -1582,12 +1582,10 @@ HRESULT EVRCustomPresenter::processOutput() // Try to get a free sample from the video sample pool. hr = m_samplePool.getSample(&sample); - if (hr == MF_E_SAMPLEALLOCATOR_EMPTY) { - // No free samples. Try again when a sample is released. + if (hr == MF_E_SAMPLEALLOCATOR_EMPTY) // No free samples. Try again when a sample is released. return S_FALSE; - } else if (FAILED(hr)) { + if (FAILED(hr)) return hr; - } // From now on, we have a valid video sample pointer, where the mixer will // write the video data. @@ -2020,23 +2018,23 @@ static QVideoFrame::PixelFormat pixelFormatFromMediaType(IMFMediaType *type) if (subtype == MFVideoFormat_RGB32) return QVideoFrame::Format_RGB32; - else if (subtype == MFVideoFormat_ARGB32) + if (subtype == MFVideoFormat_ARGB32) return QVideoFrame::Format_ARGB32; - else if (subtype == MFVideoFormat_RGB24) + if (subtype == MFVideoFormat_RGB24) return QVideoFrame::Format_RGB24; - else if (subtype == MFVideoFormat_RGB565) + if (subtype == MFVideoFormat_RGB565) return QVideoFrame::Format_RGB565; - else if (subtype == MFVideoFormat_RGB555) + if (subtype == MFVideoFormat_RGB555) return QVideoFrame::Format_RGB555; - else if (subtype == MFVideoFormat_AYUV) + if (subtype == MFVideoFormat_AYUV) return QVideoFrame::Format_AYUV444; - else if (subtype == MFVideoFormat_I420) + if (subtype == MFVideoFormat_I420) return QVideoFrame::Format_YUV420P; - else if (subtype == MFVideoFormat_UYVY) + if (subtype == MFVideoFormat_UYVY) return QVideoFrame::Format_UYVY; - else if (subtype == MFVideoFormat_YV12) + if (subtype == MFVideoFormat_YV12) return QVideoFrame::Format_YV12; - else if (subtype == MFVideoFormat_NV12) + if (subtype == MFVideoFormat_NV12) return QVideoFrame::Format_NV12; return QVideoFrame::Format_Invalid; diff --git a/src/plugins/common/evr/evrhelpers.cpp b/src/plugins/common/evr/evrhelpers.cpp index 96b61e2eb..a315f1a73 100644 --- a/src/plugins/common/evr/evrhelpers.cpp +++ b/src/plugins/common/evr/evrhelpers.cpp @@ -69,7 +69,7 @@ bool qt_evr_areMediaTypesEqual(IMFMediaType *type1, IMFMediaType *type2) { if (!type1 && !type2) return true; - else if (!type1 || !type2) + if (!type1 || !type2) return false; DWORD dwFlags = 0; @@ -84,10 +84,10 @@ HRESULT qt_evr_validateVideoArea(const MFVideoArea& area, UINT32 width, UINT32 h float fOffsetY = qt_evr_MFOffsetToFloat(area.OffsetY); if ( ((LONG)fOffsetX + area.Area.cx > (LONG)width) || - ((LONG)fOffsetY + area.Area.cy > (LONG)height) ) + ((LONG)fOffsetY + area.Area.cy > (LONG)height) ) { return MF_E_INVALIDMEDIATYPE; - else - return S_OK; + } + return S_OK; } bool qt_evr_isSampleTimePassed(IMFClock *clock, IMFSample *sample) diff --git a/src/plugins/directshow/camera/directshowcameraexposurecontrol.cpp b/src/plugins/directshow/camera/directshowcameraexposurecontrol.cpp index 7ece366ea..6f138450c 100644 --- a/src/plugins/directshow/camera/directshowcameraexposurecontrol.cpp +++ b/src/plugins/directshow/camera/directshowcameraexposurecontrol.cpp @@ -68,13 +68,16 @@ DirectShowCameraExposureControl::DirectShowCameraExposureControl(DSCameraSession bool DirectShowCameraExposureControl::isParameterSupported(QCameraExposureControl::ExposureParameter parameter) const { - if (parameter == ShutterSpeed) - return (m_shutterSpeedValues.caps & CameraControl_Flags_Manual); - if (parameter == Aperture) + switch (parameter) { + case QCameraExposureControl::Aperture: return (m_apertureValues.caps & CameraControl_Flags_Manual); - if (parameter == ExposureMode) + case QCameraExposureControl::ShutterSpeed: + return (m_shutterSpeedValues.caps & CameraControl_Flags_Manual); + case QCameraExposureControl::ExposureMode: return true; - + default: + break; + } return false; } @@ -156,10 +159,9 @@ bool DirectShowCameraExposureControl::setValue(QCameraExposureControl::ExposureP if (parameter == ShutterSpeed) { m_requestedShutterSpeed = newValue; return setShutterSpeed(cameraControl, m_requestedShutterSpeed); - } else { - m_requestedAperture = newValue; - return setAperture(cameraControl, m_requestedAperture); } + m_requestedAperture = newValue; + return setAperture(cameraControl, m_requestedAperture); } if (parameter == ExposureMode) { diff --git a/src/plugins/directshow/camera/dscamerasession.cpp b/src/plugins/directshow/camera/dscamerasession.cpp index 6b3662290..bf81262d6 100644 --- a/src/plugins/directshow/camera/dscamerasession.cpp +++ b/src/plugins/directshow/camera/dscamerasession.cpp @@ -130,30 +130,28 @@ void DSCameraSession::setViewfinderSettings(const QCameraViewfinderSettings &set qreal DSCameraSession::scaledImageProcessingParameterValue( const ImageProcessingParameterInfo &sourceValueInfo) { - if (sourceValueInfo.currentValue == sourceValueInfo.defaultValue) { + if (sourceValueInfo.currentValue == sourceValueInfo.defaultValue) return 0.0f; - } else if (sourceValueInfo.currentValue < sourceValueInfo.defaultValue) { + if (sourceValueInfo.currentValue < sourceValueInfo.defaultValue) { return ((sourceValueInfo.currentValue - sourceValueInfo.minimumValue) / qreal(sourceValueInfo.defaultValue - sourceValueInfo.minimumValue)) + (-1.0f); - } else { - return ((sourceValueInfo.currentValue - sourceValueInfo.defaultValue) - / qreal(sourceValueInfo.maximumValue - sourceValueInfo.defaultValue)); } + return ((sourceValueInfo.currentValue - sourceValueInfo.defaultValue) + / qreal(sourceValueInfo.maximumValue - sourceValueInfo.defaultValue)); } qint32 DSCameraSession::sourceImageProcessingParameterValue( qreal scaledValue, const ImageProcessingParameterInfo &valueRange) { - if (qFuzzyIsNull(scaledValue)) { + if (qFuzzyIsNull(scaledValue)) return valueRange.defaultValue; - } else if (scaledValue < 0.0f) { + if (scaledValue < 0.0f) { return ((scaledValue - (-1.0f)) * (valueRange.defaultValue - valueRange.minimumValue)) + valueRange.minimumValue; - } else { - return (scaledValue * (valueRange.maximumValue - valueRange.defaultValue)) - + valueRange.defaultValue; } + return (scaledValue * (valueRange.maximumValue - valueRange.defaultValue)) + + valueRange.defaultValue; } static QCameraImageProcessingControl::ProcessingParameter searchRelatedResultingParameter( diff --git a/src/plugins/directshow/common/directshowbasefilter.cpp b/src/plugins/directshow/common/directshowbasefilter.cpp index 1e45eea51..2792dc3c6 100644 --- a/src/plugins/directshow/common/directshowbasefilter.cpp +++ b/src/plugins/directshow/common/directshowbasefilter.cpp @@ -172,51 +172,43 @@ HRESULT DirectShowBaseFilter::SetSyncSource(IReferenceClock *pClock) HRESULT DirectShowBaseFilter::GetSyncSource(IReferenceClock **ppClock) { - if (!ppClock) { + if (!ppClock) return E_POINTER; - } else { - if (!m_clock) { - *ppClock = 0; - - return S_FALSE; - } else { - m_clock->AddRef(); - *ppClock = m_clock; - - return S_OK; - } + if (!m_clock) { + *ppClock = nullptr; + return S_FALSE; } + m_clock->AddRef(); + *ppClock = m_clock; + return S_OK; } HRESULT DirectShowBaseFilter::EnumPins(IEnumPins **ppEnum) { - if (!ppEnum) { + if (!ppEnum) return E_POINTER; - } else { - *ppEnum = new DirectShowPinEnum(this); - return S_OK; - } + *ppEnum = new DirectShowPinEnum(this); + return S_OK; } HRESULT DirectShowBaseFilter::FindPin(LPCWSTR Id, IPin **ppPin) { - if (!ppPin || !Id) { + if (!ppPin || !Id) return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - const QList pinList = pins(); - for (DirectShowPin *pin : pinList) { - if (QString::fromWCharArray(Id) == pin->name()) { - pin->AddRef(); - *ppPin = pin; - return S_OK; - } - } - *ppPin = 0; - return VFW_E_NOT_FOUND; + QMutexLocker locker(&m_mutex); + const QList pinList = pins(); + for (DirectShowPin *pin : pinList) { + if (pin->name() == QStringView(Id)) { + pin->AddRef(); + *ppPin = pin; + return S_OK; + } } + + *ppPin = 0; + return VFW_E_NOT_FOUND; } HRESULT DirectShowBaseFilter::JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName) @@ -237,24 +229,23 @@ HRESULT DirectShowBaseFilter::JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pNam HRESULT DirectShowBaseFilter::QueryFilterInfo(FILTER_INFO *pInfo) { - if (!pInfo) { + if (!pInfo) return E_POINTER; - } else { - QString name = m_filterName; - if (name.length() >= MAX_FILTER_NAME) - name.truncate(MAX_FILTER_NAME - 1); + QString name = m_filterName; - int length = name.toWCharArray(pInfo->achName); - pInfo->achName[length] = '\0'; + if (name.length() >= MAX_FILTER_NAME) + name.truncate(MAX_FILTER_NAME - 1); - if (m_graph) - m_graph->AddRef(); + int length = name.toWCharArray(pInfo->achName); + pInfo->achName[length] = '\0'; - pInfo->pGraph = m_graph; + if (m_graph) + m_graph->AddRef(); - return S_OK; - } + pInfo->pGraph = m_graph; + + return S_OK; } HRESULT DirectShowBaseFilter::QueryVendorInfo(LPWSTR *pVendorInfo) diff --git a/src/plugins/directshow/common/directshowmediatype.cpp b/src/plugins/directshow/common/directshowmediatype.cpp index dc8e598f0..fe86e0204 100644 --- a/src/plugins/directshow/common/directshowmediatype.cpp +++ b/src/plugins/directshow/common/directshowmediatype.cpp @@ -250,7 +250,8 @@ QVideoSurfaceFormat DirectShowMediaType::videoFormatFromType(const AM_MEDIA_TYPE format.setScanLineDirection(scanLineDirection(format.pixelFormat(), header->bmiHeader)); return format; - } else if (IsEqualGUID(type->formattype, FORMAT_VideoInfo2)) { + } + if (IsEqualGUID(type->formattype, FORMAT_VideoInfo2)) { VIDEOINFOHEADER2 *header = reinterpret_cast(type->pbFormat); QVideoSurfaceFormat format( diff --git a/src/plugins/directshow/common/directshowmediatypeenum.cpp b/src/plugins/directshow/common/directshowmediatypeenum.cpp index a6afcd5f1..10623a246 100644 --- a/src/plugins/directshow/common/directshowmediatypeenum.cpp +++ b/src/plugins/directshow/common/directshowmediatypeenum.cpp @@ -78,21 +78,20 @@ HRESULT DirectShowMediaTypeEnum::QueryInterface(REFIID riid, void **ppv) HRESULT DirectShowMediaTypeEnum::Next(ULONG cMediaTypes, AM_MEDIA_TYPE **ppMediaTypes, ULONG *pcFetched) { - if (ppMediaTypes && (pcFetched || cMediaTypes == 1)) { - ULONG count = qBound(0, cMediaTypes, m_mediaTypes.count() - m_index); - - for (ULONG i = 0; i < count; ++i, ++m_index) { - ppMediaTypes[i] = reinterpret_cast(CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE))); - DirectShowMediaType::copyToUninitialized(ppMediaTypes[i], &m_mediaTypes.at(m_index)); - } + if (!ppMediaTypes || (!pcFetched && cMediaTypes != 1)) + return E_POINTER; - if (pcFetched) - *pcFetched = count; + ULONG count = qBound(0, cMediaTypes, m_mediaTypes.count() - m_index); - return count == cMediaTypes ? S_OK : S_FALSE; - } else { - return E_POINTER; + for (ULONG i = 0; i < count; ++i, ++m_index) { + ppMediaTypes[i] = reinterpret_cast(CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE))); + DirectShowMediaType::copyToUninitialized(ppMediaTypes[i], &m_mediaTypes.at(m_index)); } + + if (pcFetched) + *pcFetched = count; + + return count == cMediaTypes ? S_OK : S_FALSE; } HRESULT DirectShowMediaTypeEnum::Skip(ULONG cMediaTypes) @@ -109,14 +108,9 @@ HRESULT DirectShowMediaTypeEnum::Reset() HRESULT DirectShowMediaTypeEnum::Clone(IEnumMediaTypes **ppEnum) { - if (ppEnum) { - if (m_pin) - *ppEnum = new DirectShowMediaTypeEnum(m_pin); - else - *ppEnum = new DirectShowMediaTypeEnum(m_mediaTypes); - return S_OK; - } else { + if (!ppEnum) return E_POINTER; - } + *ppEnum = m_pin ? new DirectShowMediaTypeEnum(m_pin) : new DirectShowMediaTypeEnum(m_mediaTypes); + return S_OK; } diff --git a/src/plugins/directshow/common/directshowpin.cpp b/src/plugins/directshow/common/directshowpin.cpp index 0dae72d0a..508a9b21d 100644 --- a/src/plugins/directshow/common/directshowpin.cpp +++ b/src/plugins/directshow/common/directshowpin.cpp @@ -230,70 +230,60 @@ HRESULT DirectShowPin::Disconnect() HRESULT DirectShowPin::ConnectedTo(IPin **ppPin) { - if (!ppPin) { + if (!ppPin) return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - - if (!m_peerPin) { - *ppPin = 0; - return VFW_E_NOT_CONNECTED; - } else { - m_peerPin->AddRef(); - *ppPin = m_peerPin; - return S_OK; - } + + QMutexLocker locker(&m_mutex); + if (!m_peerPin) { + *ppPin = 0; + return VFW_E_NOT_CONNECTED; } + m_peerPin->AddRef(); + *ppPin = m_peerPin; + return S_OK; } HRESULT DirectShowPin::ConnectionMediaType(AM_MEDIA_TYPE *pmt) { - if (!pmt) { + if (!pmt) return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - if (!m_peerPin) { - DirectShowMediaType::init(pmt); - return VFW_E_NOT_CONNECTED; - } else { - DirectShowMediaType::copy(pmt, &m_mediaType); - return S_OK; - } + QMutexLocker locker(&m_mutex); + if (!m_peerPin) { + DirectShowMediaType::init(pmt); + return VFW_E_NOT_CONNECTED; } + DirectShowMediaType::copy(pmt, &m_mediaType); + return S_OK; } HRESULT DirectShowPin::QueryPinInfo(PIN_INFO *pInfo) { - if (!pInfo) { + if (!pInfo) return E_POINTER; - } else { - pInfo->pFilter = m_filter; - if (m_filter) { - m_filter->AddRef(); - } - pInfo->dir = m_direction; - QString name = m_name; - if (name.length() >= MAX_PIN_NAME) - name.truncate(MAX_PIN_NAME - 1); - int length = name.toWCharArray(pInfo->achName); - pInfo->achName[length] = '\0'; + pInfo->pFilter = m_filter; + if (m_filter) + m_filter->AddRef(); + pInfo->dir = m_direction; - return S_OK; - } + QString name = m_name; + if (name.length() >= MAX_PIN_NAME) + name.truncate(MAX_PIN_NAME - 1); + int length = name.toWCharArray(pInfo->achName); + pInfo->achName[length] = '\0'; + + return S_OK; } HRESULT DirectShowPin::QueryId(LPWSTR *Id) { - if (!Id) { + if (!Id) return E_POINTER; - } else { - const int bytes = (m_name.length() + 1) * 2; - *Id = static_cast(::CoTaskMemAlloc(bytes)); - ::memcpy(*Id, m_name.utf16(), bytes); - return S_OK; - } + const int bytes = (m_name.length() + 1) * 2; + *Id = static_cast(::CoTaskMemAlloc(bytes)); + ::memcpy(*Id, m_name.utf16(), bytes); + return S_OK; } HRESULT DirectShowPin::QueryAccept(const AM_MEDIA_TYPE *pmt) @@ -309,12 +299,10 @@ HRESULT DirectShowPin::QueryAccept(const AM_MEDIA_TYPE *pmt) HRESULT DirectShowPin::EnumMediaTypes(IEnumMediaTypes **ppEnum) { - if (!ppEnum) { + if (!ppEnum) return E_POINTER; - } else { - *ppEnum = new DirectShowMediaTypeEnum(this); - return S_OK; - } + *ppEnum = new DirectShowMediaTypeEnum(this); + return S_OK; } HRESULT DirectShowPin::QueryInternalConnections(IPin **apPin, ULONG *nPin) @@ -349,12 +337,10 @@ HRESULT DirectShowPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, d HRESULT DirectShowPin::QueryDirection(PIN_DIRECTION *pPinDir) { - if (!pPinDir) { + if (!pPinDir) return E_POINTER; - } else { - *pPinDir = m_direction; - return S_OK; - } + *pPinDir = m_direction; + return S_OK; } QList DirectShowPin::supportedMediaTypes() diff --git a/src/plugins/directshow/common/directshowpinenum.cpp b/src/plugins/directshow/common/directshowpinenum.cpp index e0ab58d19..20fa93d6e 100644 --- a/src/plugins/directshow/common/directshowpinenum.cpp +++ b/src/plugins/directshow/common/directshowpinenum.cpp @@ -87,21 +87,20 @@ HRESULT DirectShowPinEnum::QueryInterface(REFIID riid, void **ppv) HRESULT DirectShowPinEnum::Next(ULONG cPins, IPin **ppPins, ULONG *pcFetched) { - if (ppPins && (pcFetched || cPins == 1)) { - ULONG count = qBound(0, cPins, m_pins.count() - m_index); - - for (ULONG i = 0; i < count; ++i, ++m_index) { - ppPins[i] = m_pins.at(m_index); - ppPins[i]->AddRef(); - } + if (!ppPins || (!pcFetched && cPins != 1)) + return E_POINTER; - if (pcFetched) - *pcFetched = count; + ULONG count = qBound(0, cPins, m_pins.count() - m_index); - return count == cPins ? S_OK : S_FALSE; - } else { - return E_POINTER; + for (ULONG i = 0; i < count; ++i, ++m_index) { + ppPins[i] = m_pins.at(m_index); + ppPins[i]->AddRef(); } + + if (pcFetched) + *pcFetched = count; + + return count == cPins ? S_OK : S_FALSE; } HRESULT DirectShowPinEnum::Skip(ULONG cPins) @@ -120,16 +119,10 @@ HRESULT DirectShowPinEnum::Reset() HRESULT DirectShowPinEnum::Clone(IEnumPins **ppEnum) { - if (ppEnum) { - if (m_filter) - *ppEnum = new DirectShowPinEnum(m_filter); - else - *ppEnum = new DirectShowPinEnum(m_pins); - - return S_OK; - } else { + if (!ppEnum) return E_POINTER; - } + *ppEnum = m_filter ? new DirectShowPinEnum(m_filter) : new DirectShowPinEnum(m_pins); + return S_OK; } QT_END_NAMESPACE diff --git a/src/plugins/directshow/dsserviceplugin.cpp b/src/plugins/directshow/dsserviceplugin.cpp index cb4f0cdf9..64b30f561 100644 --- a/src/plugins/directshow/dsserviceplugin.cpp +++ b/src/plugins/directshow/dsserviceplugin.cpp @@ -114,10 +114,9 @@ void DSServicePlugin::release(QMediaService *service) QMediaServiceProviderHint::Features DSServicePlugin::supportedFeatures( const QByteArray &service) const { - if (service == Q_MEDIASERVICE_MEDIAPLAYER) - return QMediaServiceProviderHint::StreamPlayback | QMediaServiceProviderHint::VideoSurface; - else - return QMediaServiceProviderHint::Features(); + return service == Q_MEDIASERVICE_MEDIAPLAYER + ? (QMediaServiceProviderHint::StreamPlayback | QMediaServiceProviderHint::VideoSurface) + : QMediaServiceProviderHint::Features(); } QByteArray DSServicePlugin::defaultDevice(const QByteArray &service) const diff --git a/src/plugins/directshow/player/directshowioreader.cpp b/src/plugins/directshow/player/directshowioreader.cpp index 7f3303633..3482cee02 100644 --- a/src/plugins/directshow/player/directshowioreader.cpp +++ b/src/plugins/directshow/player/directshowioreader.cpp @@ -123,76 +123,65 @@ ULONG DirectShowIOReader::Release() HRESULT DirectShowIOReader::RequestAllocator( IMemAllocator *pPreferred, ALLOCATOR_PROPERTIES *pProps, IMemAllocator **ppActual) { - if (!ppActual || !pProps) { + if (!ppActual || !pProps) return E_POINTER; - } else { - ALLOCATOR_PROPERTIES actualProperties; - if (pProps->cbAlign == 0) - pProps->cbAlign = 1; + ALLOCATOR_PROPERTIES actualProperties; - if (pPreferred && pPreferred->SetProperties(pProps, &actualProperties) == S_OK) { - pPreferred->AddRef(); + if (pProps->cbAlign == 0) + pProps->cbAlign = 1; - *ppActual = pPreferred; + if (pPreferred && pPreferred->SetProperties(pProps, &actualProperties) == S_OK) { + pPreferred->AddRef(); - m_source->setAllocator(*ppActual); + *ppActual = pPreferred; + m_source->setAllocator(*ppActual); + return S_OK; + } + *ppActual = com_new(CLSID_MemoryAllocator); + if (*ppActual) { + if ((*ppActual)->SetProperties(pProps, &actualProperties) == S_OK) { + m_source->setAllocator(*ppActual); return S_OK; - } else { - *ppActual = com_new(CLSID_MemoryAllocator); - - if (*ppActual) { - if ((*ppActual)->SetProperties(pProps, &actualProperties) != S_OK) { - (*ppActual)->Release(); - } else { - m_source->setAllocator(*ppActual); - - return S_OK; - } - } } - ppActual = 0; - - return E_FAIL; + (*ppActual)->Release(); } + ppActual = nullptr; + return E_FAIL; } HRESULT DirectShowIOReader::Request(IMediaSample *pSample, DWORD_PTR dwUser) { QMutexLocker locker(&m_mutex); - if (!pSample) { + if (!pSample) return E_POINTER; - } else if (m_flushing) { + if (m_flushing) return VFW_E_WRONG_STATE; - } else { - REFERENCE_TIME startTime = 0; - REFERENCE_TIME endTime = 0; - BYTE *buffer; - if (pSample->GetTime(&startTime, &endTime) != S_OK - || pSample->GetPointer(&buffer) != S_OK) { - return VFW_E_SAMPLE_TIME_NOT_SET; - } else { - LONGLONG position = startTime / 10000000; - LONG length = (endTime - startTime) / 10000000; - - DirectShowSampleRequest *request = new DirectShowSampleRequest( - pSample, dwUser, position, length, buffer); + REFERENCE_TIME startTime = 0; + REFERENCE_TIME endTime = 0; + BYTE *buffer; - if (m_pendingTail) { - m_pendingTail->next = request; - } else { - m_pendingHead = request; + if (pSample->GetTime(&startTime, &endTime) != S_OK + || pSample->GetPointer(&buffer) != S_OK) { + return VFW_E_SAMPLE_TIME_NOT_SET; + } + LONGLONG position = startTime / 10000000; + LONG length = (endTime - startTime) / 10000000; - m_loop->postEvent(this, new QEvent(QEvent::User)); - } - m_pendingTail = request; + auto request = new DirectShowSampleRequest(pSample, dwUser, position, length, buffer); - return S_OK; - } + if (m_pendingTail) { + m_pendingTail->next = request; + } else { + m_pendingHead = request; + m_loop->postEvent(this, new QEvent(QEvent::User)); } + m_pendingTail = request; + + return S_OK; } HRESULT DirectShowIOReader::WaitForNext( @@ -220,7 +209,8 @@ HRESULT DirectShowIOReader::WaitForNext( delete request; return hr; - } else if (m_flushing) { + } + if (m_flushing) { *ppSample = 0; *pdwUser = 0; @@ -236,90 +226,80 @@ HRESULT DirectShowIOReader::WaitForNext( HRESULT DirectShowIOReader::SyncReadAligned(IMediaSample *pSample) { - if (!pSample) { + if (!pSample) return E_POINTER; - } else { - REFERENCE_TIME startTime = 0; - REFERENCE_TIME endTime = 0; - BYTE *buffer; - if (pSample->GetTime(&startTime, &endTime) != S_OK - || pSample->GetPointer(&buffer) != S_OK) { - return VFW_E_SAMPLE_TIME_NOT_SET; - } else { - LONGLONG position = startTime / 10000000; - LONG length = (endTime - startTime) / 10000000; + REFERENCE_TIME startTime = 0; + REFERENCE_TIME endTime = 0; + BYTE *buffer; - QMutexLocker locker(&m_mutex); + if (pSample->GetTime(&startTime, &endTime) != S_OK + || pSample->GetPointer(&buffer) != S_OK) { + return VFW_E_SAMPLE_TIME_NOT_SET; + } + LONGLONG position = startTime / 10000000; + LONG length = (endTime - startTime) / 10000000; - if (thread() == QThread::currentThread()) { - qint64 bytesRead = 0; + QMutexLocker locker(&m_mutex); - HRESULT hr = blockingRead(position, length, buffer, &bytesRead); + if (thread() == QThread::currentThread()) { + qint64 bytesRead = 0; - if (SUCCEEDED(hr)) - pSample->SetActualDataLength(bytesRead); + HRESULT hr = blockingRead(position, length, buffer, &bytesRead); + if (SUCCEEDED(hr)) + pSample->SetActualDataLength(bytesRead); - return hr; - } else { - m_synchronousPosition = position; - m_synchronousLength = length; - m_synchronousBuffer = buffer; + return hr; + } + m_synchronousPosition = position; + m_synchronousLength = length; + m_synchronousBuffer = buffer; - m_loop->postEvent(this, new QEvent(QEvent::User)); + m_loop->postEvent(this, new QEvent(QEvent::User)); - m_wait.wait(&m_mutex); + m_wait.wait(&m_mutex); - m_synchronousBuffer = 0; + m_synchronousBuffer = nullptr; - if (SUCCEEDED(m_synchronousResult)) - pSample->SetActualDataLength(m_synchronousBytesRead); + if (SUCCEEDED(m_synchronousResult)) + pSample->SetActualDataLength(m_synchronousBytesRead); - return m_synchronousResult; - } - } - } + return m_synchronousResult; } HRESULT DirectShowIOReader::SyncRead(LONGLONG llPosition, LONG lLength, BYTE *pBuffer) { - if (!pBuffer) { + if (!pBuffer) return E_POINTER; - } else { - if (thread() == QThread::currentThread()) { - qint64 bytesRead; - return blockingRead(llPosition, lLength, pBuffer, &bytesRead); - } else { - QMutexLocker locker(&m_mutex); + if (thread() == QThread::currentThread()) { + qint64 bytesRead; + return blockingRead(llPosition, lLength, pBuffer, &bytesRead); + } + QMutexLocker locker(&m_mutex); - m_synchronousPosition = llPosition; - m_synchronousLength = lLength; - m_synchronousBuffer = pBuffer; + m_synchronousPosition = llPosition; + m_synchronousLength = lLength; + m_synchronousBuffer = pBuffer; - m_loop->postEvent(this, new QEvent(QEvent::User)); + m_loop->postEvent(this, new QEvent(QEvent::User)); - m_wait.wait(&m_mutex); + m_wait.wait(&m_mutex); - m_synchronousBuffer = 0; + m_synchronousBuffer = nullptr; - return m_synchronousResult; - } - } + return m_synchronousResult; } HRESULT DirectShowIOReader::Length(LONGLONG *pTotal, LONGLONG *pAvailable) { - if (!pTotal || !pAvailable) { + if (!pTotal || !pAvailable) return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - *pTotal = m_totalLength; - *pAvailable = m_availableLength; - - return S_OK; - } + QMutexLocker locker(&m_mutex); + *pTotal = m_totalLength; + *pAvailable = m_availableLength; + return S_OK; } @@ -432,9 +412,8 @@ HRESULT DirectShowIOReader::blockingRead( ::memset(buffer + *bytesRead, 0, length - *bytesRead); return S_FALSE; - } else { - return S_OK; } + return S_OK; } bool DirectShowIOReader::nonBlockingRead( @@ -447,30 +426,29 @@ bool DirectShowIOReader::nonBlockingRead( *result = S_FALSE; return true; - } else if (m_device->bytesAvailable() + m_device->pos() >= maxSize) { + } + if (m_device->bytesAvailable() + m_device->pos() >= maxSize) { if (m_device->pos() != position && !m_device->seek(position)) { *bytesRead = 0; *result = S_FALSE; return true; - } else { - const qint64 maxBytes = qMin(length, m_device->bytesAvailable()); - - *bytesRead = m_device->read(reinterpret_cast(buffer), maxBytes); + } + const qint64 maxBytes = qMin(length, m_device->bytesAvailable()); - if (*bytesRead != length) { - ::memset(buffer + *bytesRead, 0, length - *bytesRead); + *bytesRead = m_device->read(reinterpret_cast(buffer), maxBytes); - *result = S_FALSE; - } else { - *result = S_OK; - } + if (*bytesRead != length) { + ::memset(buffer + *bytesRead, 0, length - *bytesRead); - return true; + *result = S_FALSE; + } else { + *result = S_OK; } - } else { - return false; + + return true; } + return false; } void DirectShowIOReader::flushRequests() diff --git a/src/plugins/directshow/player/directshowiosource.cpp b/src/plugins/directshow/player/directshowiosource.cpp index 5722e6411..31e9a1300 100644 --- a/src/plugins/directshow/player/directshowiosource.cpp +++ b/src/plugins/directshow/player/directshowiosource.cpp @@ -140,12 +140,11 @@ HRESULT DirectShowIOSource::QueryInterface(REFIID riid, void **ppvObject) static const GUID iid_IAmFilterMiscFlags = { 0x2dd74950, 0xa890, 0x11d1, {0xab, 0xe8, 0x00, 0xa0, 0xc9, 0x05, 0xf3, 0x75}}; - if (!ppvObject) { + if (!ppvObject) return E_POINTER; - } else if (riid == IID_IUnknown - || riid == IID_IPersist - || riid == IID_IMediaFilter - || riid == IID_IBaseFilter) { + + if (riid == IID_IUnknown || riid == IID_IPersist || riid == IID_IMediaFilter + || riid == IID_IBaseFilter) { *ppvObject = static_cast(this); } else if (riid == iid_IAmFilterMiscFlags) { *ppvObject = static_cast(this); @@ -222,15 +221,12 @@ HRESULT DirectShowIOSource::GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *pSt { Q_UNUSED(dwMilliSecsTimeout); - if (!pState) { + if (!pState) return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - - *pState = m_state; - return S_OK; - } + QMutexLocker locker(&m_mutex); + *pState = m_state; + return S_OK; } HRESULT DirectShowIOSource::SetSyncSource(IReferenceClock *pClock) @@ -250,53 +246,41 @@ HRESULT DirectShowIOSource::SetSyncSource(IReferenceClock *pClock) HRESULT DirectShowIOSource::GetSyncSource(IReferenceClock **ppClock) { - if (!ppClock) { + if (!ppClock) return E_POINTER; - } else { - if (!m_clock) { - *ppClock = 0; - - return S_FALSE; - } else { - m_clock->AddRef(); - *ppClock = m_clock; - - return S_OK; - } + if (!m_clock) { + *ppClock = nullptr; + return S_FALSE; } + m_clock->AddRef(); + *ppClock = m_clock; + return S_OK; } // IBaseFilter HRESULT DirectShowIOSource::EnumPins(IEnumPins **ppEnum) { - if (!ppEnum) { + if (!ppEnum) return E_POINTER; - } else { - *ppEnum = new DirectShowPinEnum(QList() << this); - return S_OK; - } + *ppEnum = new DirectShowPinEnum(QList() << this); + return S_OK; } HRESULT DirectShowIOSource::FindPin(LPCWSTR Id, IPin **ppPin) { - if (!ppPin || !Id) { + if (!ppPin || !Id) return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - if (QString::fromWCharArray(Id) == m_pinId) { - AddRef(); - - *ppPin = this; - return S_OK; - } else { - *ppPin = 0; - - return VFW_E_NOT_FOUND; - } + QMutexLocker locker(&m_mutex); + if (m_pinId == QStringView(Id)) { + AddRef(); + *ppPin = this; + return S_OK; } + *ppPin = nullptr; + return VFW_E_NOT_FOUND; } HRESULT DirectShowIOSource::JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName) @@ -311,24 +295,22 @@ HRESULT DirectShowIOSource::JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName) HRESULT DirectShowIOSource::QueryFilterInfo(FILTER_INFO *pInfo) { - if (!pInfo) { + if (!pInfo) return E_POINTER; - } else { - QString name = m_filterName; - if (name.length() >= MAX_FILTER_NAME) - name.truncate(MAX_FILTER_NAME - 1); + QString name = m_filterName; + if (name.length() >= MAX_FILTER_NAME) + name.truncate(MAX_FILTER_NAME - 1); - int length = name.toWCharArray(pInfo->achName); - pInfo->achName[length] = '\0'; + int length = name.toWCharArray(pInfo->achName); + pInfo->achName[length] = '\0'; - if (m_graph) - m_graph->AddRef(); + if (m_graph) + m_graph->AddRef(); - pInfo->pGraph = m_graph; + pInfo->pGraph = m_graph; - return S_OK; - } + return S_OK; } HRESULT DirectShowIOSource::QueryVendorInfo(LPWSTR *pVendorInfo) @@ -424,121 +406,96 @@ HRESULT DirectShowIOSource::Disconnect() { QMutexLocker locker(&m_mutex); - if (!m_peerPin) { + if (!m_peerPin) return S_FALSE; - } else if (m_state != State_Stopped) { + if (m_state != State_Stopped) return VFW_E_NOT_STOPPED; - } else { - HRESULT hr = m_peerPin->Disconnect(); - if (!SUCCEEDED(hr)) - return hr; + HRESULT hr = m_peerPin->Disconnect(); + if (!SUCCEEDED(hr)) + return hr; - if (m_allocator) { - m_allocator->Release(); - m_allocator = 0; - } + if (m_allocator) { + m_allocator->Release(); + m_allocator = nullptr; + } - m_peerPin->Release(); - m_peerPin = 0; + m_peerPin->Release(); + m_peerPin = nullptr; - return S_OK; - } + return S_OK; } HRESULT DirectShowIOSource::ConnectedTo(IPin **ppPin) { - if (!ppPin) { + if (!ppPin) return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - if (!m_peerPin) { - *ppPin = 0; - - return VFW_E_NOT_CONNECTED; - } else { - m_peerPin->AddRef(); - - *ppPin = m_peerPin; - - return S_OK; - } + QMutexLocker locker(&m_mutex); + if (!m_peerPin) { + *ppPin = nullptr; + return VFW_E_NOT_CONNECTED; } + m_peerPin->AddRef(); + *ppPin = m_peerPin; + return S_OK; } HRESULT DirectShowIOSource::ConnectionMediaType(AM_MEDIA_TYPE *pmt) { - if (!pmt) { + if (!pmt) return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - - if (!m_peerPin) { - pmt = 0; - return VFW_E_NOT_CONNECTED; - } else { - DirectShowMediaType::copy(pmt, &m_connectionMediaType); - - return S_OK; - } + QMutexLocker locker(&m_mutex); + if (!m_peerPin) { + pmt = nullptr; + return VFW_E_NOT_CONNECTED; } + DirectShowMediaType::copy(pmt, &m_connectionMediaType); + return S_OK; } HRESULT DirectShowIOSource::QueryPinInfo(PIN_INFO *pInfo) { - if (!pInfo) { + if (!pInfo) return E_POINTER; - } else { - AddRef(); - pInfo->pFilter = this; - pInfo->dir = PINDIR_OUTPUT; + AddRef(); - const int bytes = qMin(MAX_FILTER_NAME, (m_pinId.length() + 1) * 2); + pInfo->pFilter = this; + pInfo->dir = PINDIR_OUTPUT; - ::memcpy(pInfo->achName, m_pinId.utf16(), bytes); + const int bytes = qMin(MAX_FILTER_NAME, (m_pinId.length() + 1) * 2); - return S_OK; - } + ::memcpy(pInfo->achName, m_pinId.utf16(), bytes); + + return S_OK; } HRESULT DirectShowIOSource::QueryId(LPWSTR *Id) { - if (!Id) { + if (!Id) return E_POINTER; - } else { - const int bytes = (m_pinId.length() + 1) * 2; - - *Id = static_cast(::CoTaskMemAlloc(bytes)); - - ::memcpy(*Id, m_pinId.utf16(), bytes); - return S_OK; - } + const int bytes = (m_pinId.length() + 1) * 2; + *Id = static_cast(::CoTaskMemAlloc(bytes)); + ::memcpy(*Id, m_pinId.utf16(), bytes); + return S_OK; } HRESULT DirectShowIOSource::QueryAccept(const AM_MEDIA_TYPE *pmt) { - if (!pmt) { + if (!pmt) return E_POINTER; - } else if (pmt->majortype == MEDIATYPE_Stream) { - return S_OK; - } else { - return S_FALSE; - } + return pmt->majortype == MEDIATYPE_Stream ? S_OK : S_FALSE; } HRESULT DirectShowIOSource::EnumMediaTypes(IEnumMediaTypes **ppEnum) { - if (!ppEnum) { + if (!ppEnum) return E_POINTER; - } else { - *ppEnum = new DirectShowMediaTypeEnum(m_supportedMediaTypes); - - return S_OK; - } + *ppEnum = new DirectShowMediaTypeEnum(m_supportedMediaTypes); + return S_OK; } HRESULT DirectShowIOSource::QueryInternalConnections(IPin **apPin, ULONG *nPin) @@ -575,13 +532,10 @@ HRESULT DirectShowIOSource::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tSt HRESULT DirectShowIOSource::QueryDirection(PIN_DIRECTION *pPinDir) { - if (!pPinDir) { + if (!pPinDir) return E_POINTER; - } else { - *pPinDir = PINDIR_OUTPUT; - - return S_OK; - } + *pPinDir = PINDIR_OUTPUT; + return S_OK; } QT_END_NAMESPACE diff --git a/src/plugins/directshow/player/directshowmetadatacontrol.cpp b/src/plugins/directshow/player/directshowmetadatacontrol.cpp index c9b0f9793..90d2b3e7d 100644 --- a/src/plugins/directshow/player/directshowmetadatacontrol.cpp +++ b/src/plugins/directshow/player/directshowmetadatacontrol.cpp @@ -113,101 +113,99 @@ static QString nameForGUIDString(const QString &guid) // Audio formats if (guid == "{00001610-0000-0010-8000-00AA00389B71}" || guid == "{000000FF-0000-0010-8000-00AA00389B71}") return QStringLiteral("MPEG AAC Audio"); - else if (guid == "{00001600-0000-0010-8000-00AA00389B71}") + if (guid == "{00001600-0000-0010-8000-00AA00389B71}") return QStringLiteral("MPEG ADTS AAC Audio"); - else if (guid == "{00000092-0000-0010-8000-00AA00389B71}") + if (guid == "{00000092-0000-0010-8000-00AA00389B71}") return QStringLiteral("Dolby AC-3 SPDIF"); - else if (guid == "{E06D802C-DB46-11CF-B4D1-00805F6CBBEA}" || guid == "{00002000-0000-0010-8000-00AA00389B71}") + if (guid == "{E06D802C-DB46-11CF-B4D1-00805F6CBBEA}" || guid == "{00002000-0000-0010-8000-00AA00389B71}") return QStringLiteral("Dolby AC-3"); - else if (guid == "{A7FB87AF-2D02-42FB-A4D4-05CD93843BDD}") + if (guid == "{A7FB87AF-2D02-42FB-A4D4-05CD93843BDD}") return QStringLiteral("Dolby Digital Plus"); - else if (guid == "{00000009-0000-0010-8000-00AA00389B71}") + if (guid == "{00000009-0000-0010-8000-00AA00389B71}") return QStringLiteral("DRM"); - else if (guid == "{00000008-0000-0010-8000-00AA00389B71}") + if (guid == "{00000008-0000-0010-8000-00AA00389B71}") return QStringLiteral("Digital Theater Systems Audio (DTS)"); - else if (guid == "{00000003-0000-0010-8000-00AA00389B71}") + if (guid == "{00000003-0000-0010-8000-00AA00389B71}") return QStringLiteral("IEEE Float Audio"); - else if (guid == "{00000055-0000-0010-8000-00AA00389B71}") + if (guid == "{00000055-0000-0010-8000-00AA00389B71}") return QStringLiteral("MPEG Audio Layer-3 (MP3)"); - else if (guid == "{00000050-0000-0010-8000-00AA00389B71}") + if (guid == "{00000050-0000-0010-8000-00AA00389B71}") return QStringLiteral("MPEG-1 Audio"); - else if (guid == "{2E6D7033-767A-494D-B478-F29D25DC9037}") + if (guid == "{2E6D7033-767A-494D-B478-F29D25DC9037}") return QStringLiteral("MPEG Audio Layer 1/2"); - else if (guid == "{0000000A-0000-0010-8000-00AA00389B71}") + if (guid == "{0000000A-0000-0010-8000-00AA00389B71}") return QStringLiteral("Windows Media Audio Voice"); - else if (guid == "{00000001-0000-0010-8000-00AA00389B71}") + if (guid == "{00000001-0000-0010-8000-00AA00389B71}") return QStringLiteral("Uncompressed PCM Audio"); - else if (guid == "{00000164-0000-0010-8000-00AA00389B71}") + if (guid == "{00000164-0000-0010-8000-00AA00389B71}") return QStringLiteral("Windows Media Audio 9 SPDIF"); - else if (guid == "{00000161-0000-0010-8000-00AA00389B71}") + if (guid == "{00000161-0000-0010-8000-00AA00389B71}") return QStringLiteral("Windows Media Audio 8 (WMA2)"); - else if (guid == "{00000162-0000-0010-8000-00AA00389B71}") + if (guid == "{00000162-0000-0010-8000-00AA00389B71}") return QStringLiteral("Windows Media Audio 9 (WMA3"); - else if (guid == "{00000163-0000-0010-8000-00AA00389B71}") + if (guid == "{00000163-0000-0010-8000-00AA00389B71}") return QStringLiteral("Windows Media Audio 9 Lossless"); - else if (guid == "{8D2FD10B-5841-4a6b-8905-588FEC1ADED9}") + if (guid == "{8D2FD10B-5841-4a6b-8905-588FEC1ADED9}") return QStringLiteral("Vorbis"); - else if (guid == "{0000F1AC-0000-0010-8000-00AA00389B71}") + if (guid == "{0000F1AC-0000-0010-8000-00AA00389B71}") return QStringLiteral("Free Lossless Audio Codec (FLAC)"); - else if (guid == "{00006C61-0000-0010-8000-00AA00389B71}") + if (guid == "{00006C61-0000-0010-8000-00AA00389B71}") return QStringLiteral("Apple Lossless Audio Codec (ALAC)"); // Video formats if (guid == "{35327664-0000-0010-8000-00AA00389B71}") return QStringLiteral("DVCPRO 25 (DV25)"); - else if (guid == "{30357664-0000-0010-8000-00AA00389B71}") + if (guid == "{30357664-0000-0010-8000-00AA00389B71}") return QStringLiteral("DVCPRO 50 (DV50)"); - else if (guid == "{20637664-0000-0010-8000-00AA00389B71}") + if (guid == "{20637664-0000-0010-8000-00AA00389B71}") return QStringLiteral("DVC/DV Video"); - else if (guid == "{31687664-0000-0010-8000-00AA00389B71}") + if (guid == "{31687664-0000-0010-8000-00AA00389B71}") return QStringLiteral("DVCPRO 100 (DVH1)"); - else if (guid == "{64687664-0000-0010-8000-00AA00389B71}") + if (guid == "{64687664-0000-0010-8000-00AA00389B71}") return QStringLiteral("HD-DVCR (DVHD)"); - else if (guid == "{64737664-0000-0010-8000-00AA00389B71}") + if (guid == "{64737664-0000-0010-8000-00AA00389B71}") return QStringLiteral("SDL-DVCR (DVSD)"); - else if (guid == "{6C737664-0000-0010-8000-00AA00389B71}") + if (guid == "{6C737664-0000-0010-8000-00AA00389B71}") return QStringLiteral("SD-DVCR (DVSL)"); - else if (guid == "{33363248-0000-0010-8000-00AA00389B71}") + if (guid == "{33363248-0000-0010-8000-00AA00389B71}") return QStringLiteral("H.263 Video"); - else if (guid == "{34363248-0000-0010-8000-00AA00389B71}") + if (guid == "{34363248-0000-0010-8000-00AA00389B71}") return QStringLiteral("H.264 Video"); - else if (guid == "{35363248-0000-0010-8000-00AA00389B71}") + if (guid == "{35363248-0000-0010-8000-00AA00389B71}") return QStringLiteral("H.265 Video"); - else if (guid == "{43564548-0000-0010-8000-00AA00389B71}") + if (guid == "{43564548-0000-0010-8000-00AA00389B71}") return QStringLiteral("High Efficiency Video Coding (HEVC)"); - else if (guid == "{3253344D-0000-0010-8000-00AA00389B71}") + if (guid == "{3253344D-0000-0010-8000-00AA00389B71}") return QStringLiteral("MPEG-4 part 2 Video (M4S2)"); - else if (guid == "{47504A4D-0000-0010-8000-00AA00389B71}") + if (guid == "{47504A4D-0000-0010-8000-00AA00389B71}") return QStringLiteral("Motion JPEG (MJPG)"); - else if (guid == "{3334504D-0000-0010-8000-00AA00389B71}") + if (guid == "{3334504D-0000-0010-8000-00AA00389B71}") return QStringLiteral("Microsoft MPEG 4 version 3 (MP43)"); - else if (guid == "{5334504D-0000-0010-8000-00AA00389B71}") + if (guid == "{5334504D-0000-0010-8000-00AA00389B71}") return QStringLiteral("ISO MPEG 4 version 1 (MP4S)"); - else if (guid == "{5634504D-0000-0010-8000-00AA00389B71}") + if (guid == "{5634504D-0000-0010-8000-00AA00389B71}") return QStringLiteral("MPEG-4 part 2 Video (MP4V)"); - else if (guid == "{E06D8026-DB46-11CF-B4D1-00805F6CBBEA}") + if (guid == "{E06D8026-DB46-11CF-B4D1-00805F6CBBEA}") return QStringLiteral("MPEG-2 Video"); - else if (guid == "{3147504D-0000-0010-8000-00AA00389B71}") + if (guid == "{3147504D-0000-0010-8000-00AA00389B71}") return QStringLiteral("MPEG-1 Video"); - else if (guid == "{3153534D-0000-0010-8000-00AA00389B71}") + if (guid == "{3153534D-0000-0010-8000-00AA00389B71}") return QStringLiteral("Windows Media Screen 1 (MSS1)"); - else if (guid == "{3253534D-0000-0010-8000-00AA00389B71}") + if (guid == "{3253534D-0000-0010-8000-00AA00389B71}") return QStringLiteral("Windows Media Video 9 Screen (MSS2)"); - else if (guid == "{31564D57-0000-0010-8000-00AA00389B71}") + if (guid == "{31564D57-0000-0010-8000-00AA00389B71}") return QStringLiteral("Windows Media Video 7 (WMV1)"); - else if (guid == "{32564D57-0000-0010-8000-00AA00389B71}") + if (guid == "{32564D57-0000-0010-8000-00AA00389B71}") return QStringLiteral("Windows Media Video 8 (WMV2)"); - else if (guid == "{33564D57-0000-0010-8000-00AA00389B71}") + if (guid == "{33564D57-0000-0010-8000-00AA00389B71}") return QStringLiteral("Windows Media Video 9 (WMV3)"); - else if (guid == "{31435657-0000-0010-8000-00AA00389B71}") + if (guid == "{31435657-0000-0010-8000-00AA00389B71}") return QStringLiteral("Windows Media Video VC1 (WVC1)"); - else if (guid == "{30385056-0000-0010-8000-00AA00389B71}") + if (guid == "{30385056-0000-0010-8000-00AA00389B71}") return QStringLiteral("VP8 Video"); - else if (guid == "{30395056-0000-0010-8000-00AA00389B71}") + if (guid == "{30395056-0000-0010-8000-00AA00389B71}") return QStringLiteral("VP9 Video"); - - else - return QStringLiteral("Unknown codec"); + return QStringLiteral("Unknown codec"); } typedef HRESULT (WINAPI *q_SHCreateItemFromParsingName)(PCWSTR, IBindCtx *, const GUID&, void **); diff --git a/src/plugins/directshow/player/directshowplayerservice.cpp b/src/plugins/directshow/player/directshowplayerservice.cpp index 6d524e71a..27108063d 100644 --- a/src/plugins/directshow/player/directshowplayerservice.cpp +++ b/src/plugins/directshow/player/directshowplayerservice.cpp @@ -1096,9 +1096,9 @@ qint64 DirectShowPlayerService::position() const QMutexLocker locker(const_cast(&m_mutex)); if (m_graphStatus == Loaded) { - if (m_executingTask == Seek || m_executingTask == SetRate || (m_pendingTasks & Seek)) { + if (m_executingTask == Seek || m_executingTask == SetRate || (m_pendingTasks & Seek)) return m_position; - } else if (IMediaSeeking *seeking = com_cast(m_graph, IID_IMediaSeeking)) { + if (IMediaSeeking *seeking = com_cast(m_graph, IID_IMediaSeeking)) { LONGLONG position = 0; seeking->GetCurrentPosition(&position); @@ -1117,9 +1117,9 @@ QMediaTimeRange DirectShowPlayerService::availablePlaybackRanges() const QMutexLocker locker(const_cast(&m_mutex)); if (m_graphStatus == Loaded) { - if (m_executingTask == Seek || m_executingTask == SetRate || (m_pendingTasks & Seek)) { + if (m_executingTask == Seek || m_executingTask == SetRate || (m_pendingTasks & Seek)) return m_playbackRange; - } else if (IMediaSeeking *seeking = com_cast(m_graph, IID_IMediaSeeking)) { + if (IMediaSeeking *seeking = com_cast(m_graph, IID_IMediaSeeking)) { LONGLONG minimum = 0; LONGLONG maximum = 0; @@ -1200,9 +1200,8 @@ int DirectShowPlayerService::bufferStatus() const reader->Release(); return percentage; - } else { - return 0; } + return 0; #else return 0; #endif diff --git a/src/plugins/directshow/player/videosurfacefilter.cpp b/src/plugins/directshow/player/videosurfacefilter.cpp index c521a251b..826d26bdb 100644 --- a/src/plugins/directshow/player/videosurfacefilter.cpp +++ b/src/plugins/directshow/player/videosurfacefilter.cpp @@ -330,12 +330,11 @@ bool VideoSurfaceFilter::setMediaType(const AM_MEDIA_TYPE *type) m_surfaceFormat = QVideoSurfaceFormat(); m_bytesPerLine = 0; return true; - } else { - m_surfaceFormat = DirectShowMediaType::videoFormatFromType(type); - m_bytesPerLine = DirectShowMediaType::bytesPerLine(m_surfaceFormat); - qCDebug(qLcRenderFilter) << "setMediaType -->" << m_surfaceFormat; - return m_surfaceFormat.isValid(); } + m_surfaceFormat = DirectShowMediaType::videoFormatFromType(type); + m_bytesPerLine = DirectShowMediaType::bytesPerLine(m_surfaceFormat); + qCDebug(qLcRenderFilter) << "setMediaType -->" << m_surfaceFormat; + return m_surfaceFormat.isValid(); } HRESULT VideoSurfaceFilter::completeConnection(IPin *pin) @@ -344,10 +343,7 @@ HRESULT VideoSurfaceFilter::completeConnection(IPin *pin) qCDebug(qLcRenderFilter, "completeConnection"); - if (!startSurface()) - return VFW_E_TYPE_NOT_ACCEPTED; - else - return S_OK; + return startSurface() ? S_OK : VFW_E_TYPE_NOT_ACCEPTED; } HRESULT VideoSurfaceFilter::connectionEnded() @@ -783,32 +779,40 @@ void VideoSurfaceFilter::renderPendingSample() bool VideoSurfaceFilter::event(QEvent *e) { - if (e->type() == QEvent::Type(StartSurface)) { + switch (e->type()) { + case StartSurface: { QMutexLocker locker(&m_mutex); startSurface(); m_waitSurface.wakeAll(); return true; - } else if (e->type() == QEvent::Type(StopSurface)) { + } + case StopSurface: { QMutexLocker locker(&m_mutex); stopSurface(); m_waitSurface.wakeAll(); return true; - } else if (e->type() == QEvent::Type(RestartSurface)) { + } + case RestartSurface: { QMutexLocker locker(&m_mutex); restartSurface(); m_waitSurface.wakeAll(); return true; - } else if (e->type() == QEvent::Type(FlushSurface)) { + } + case FlushSurface: { QMutexLocker locker(&m_mutex); flushSurface(); m_waitSurface.wakeAll(); return true; - } else if (e->type() == QEvent::Type(RenderSample)) { + } + case RenderSample: { QMutexLocker locker(&m_mutex); renderPendingSample(); m_waitSurface.wakeAll(); return true; } + default: + break; + } return QObject::event(e); } -- cgit v1.2.3