diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-09-05 09:58:46 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-09-05 13:15:39 +0000 |
commit | be7f8d3a49fc6d5d31e6fe61f9ba2dec43341e90 (patch) | |
tree | e8d249300a22fed7fff1787449b9d3ad8e6c9f98 /src/plugins/directshow/player | |
parent | 8daa96db2991c24c9102e736413f79241813b7df (diff) |
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 <oliver.wolff@qt.io>
Diffstat (limited to 'src/plugins/directshow/player')
5 files changed, 250 insertions, 317 deletions
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<IMemAllocator>(CLSID_MemoryAllocator); + if (*ppActual) { + if ((*ppActual)->SetProperties(pProps, &actualProperties) == S_OK) { + m_source->setAllocator(*ppActual); return S_OK; - } else { - *ppActual = com_new<IMemAllocator>(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<qint64>(length, m_device->bytesAvailable()); - - *bytesRead = m_device->read(reinterpret_cast<char *>(buffer), maxBytes); + } + const qint64 maxBytes = qMin<qint64>(length, m_device->bytesAvailable()); - if (*bytesRead != length) { - ::memset(buffer + *bytesRead, 0, length - *bytesRead); + *bytesRead = m_device->read(reinterpret_cast<char *>(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<IBaseFilter *>(this); } else if (riid == iid_IAmFilterMiscFlags) { *ppvObject = static_cast<IAMFilterMiscFlags *>(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<IPin *>() << this); - return S_OK; - } + *ppEnum = new DirectShowPinEnum(QList<IPin *>() << 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<LPWSTR>(::CoTaskMemAlloc(bytes)); - - ::memcpy(*Id, m_pinId.utf16(), bytes); - return S_OK; - } + const int bytes = (m_pinId.length() + 1) * 2; + *Id = static_cast<LPWSTR>(::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<QMutex *>(&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<IMediaSeeking>(m_graph, IID_IMediaSeeking)) { + if (IMediaSeeking *seeking = com_cast<IMediaSeeking>(m_graph, IID_IMediaSeeking)) { LONGLONG position = 0; seeking->GetCurrentPosition(&position); @@ -1117,9 +1117,9 @@ QMediaTimeRange DirectShowPlayerService::availablePlaybackRanges() const QMutexLocker locker(const_cast<QMutex *>(&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<IMediaSeeking>(m_graph, IID_IMediaSeeking)) { + if (IMediaSeeking *seeking = com_cast<IMediaSeeking>(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); } |