diff options
author | Hendrik Leppkes <h.leppkes@gmail.com> | 2014-09-01 17:24:13 +0400 |
---|---|---|
committer | Hendrik Leppkes <h.leppkes@gmail.com> | 2014-09-01 17:24:13 +0400 |
commit | 289e158b3507ff50c77768a28eb18bfc6cd707f2 (patch) | |
tree | 5690bbe1cccae89b5081484c9c4d5be24d4b5a30 /demuxer | |
parent | 06b6e4489b9022f953c1654e1ba02393597c2a72 (diff) |
Workaround an issue with the Microsoft File Source (URL) and EOF handling
Fixes issue 463
Diffstat (limited to 'demuxer')
-rw-r--r-- | demuxer/LAVSplitter/InputPin.cpp | 25 | ||||
-rw-r--r-- | demuxer/LAVSplitter/InputPin.h | 2 |
2 files changed, 21 insertions, 6 deletions
diff --git a/demuxer/LAVSplitter/InputPin.cpp b/demuxer/LAVSplitter/InputPin.cpp index d4c1ac86..10cd1284 100644 --- a/demuxer/LAVSplitter/InputPin.cpp +++ b/demuxer/LAVSplitter/InputPin.cpp @@ -108,15 +108,23 @@ HRESULT CLAVInputPin::CompleteConnect(IPin* pPin) } m_llPos = 0; + m_bURLSource = false; - if (FAILED(pPin->QueryInterface(&m_pStreamControl))) { - PIN_INFO pinInfo = {0}; - if (SUCCEEDED(pPin->QueryPinInfo(&pinInfo)) && pinInfo.pFilter) { + if (FAILED(pPin->QueryInterface(&m_pStreamControl))) + m_pStreamControl = nullptr; + + PIN_INFO pinInfo = {0}; + if (SUCCEEDED(pPin->QueryPinInfo(&pinInfo)) && pinInfo.pFilter) { + CLSID clsidFilter = GUID_NULL; + if (SUCCEEDED(pinInfo.pFilter->GetClassID(&clsidFilter))) { + m_bURLSource = (clsidFilter == CLSID_URLReader); + } + + if (m_pStreamControl == nullptr) if (FAILED(pinInfo.pFilter->QueryInterface(&m_pStreamControl))) m_pStreamControl = nullptr; - SafeRelease(&(pinInfo.pFilter)); - } else - m_pStreamControl = nullptr; + + SafeRelease(&(pinInfo.pFilter)); } if(FAILED(hr = (static_cast<CLAVSplitter *>(m_pFilter))->CompleteInputConnection())) { @@ -131,8 +139,13 @@ int CLAVInputPin::Read(void *opaque, uint8_t *buf, int buf_size) CLAVInputPin *pin = static_cast<CLAVInputPin *>(opaque); CAutoLock lock(pin); + // The URL source doesn't properly signal EOF in all cases, so make sure no stale data is in the buffer + if (pin->m_bURLSource) + memset(buf, 0, buf_size); + HRESULT hr = pin->m_pAsyncReader->SyncRead(pin->m_llPos, buf_size, buf); if (FAILED(hr)) { + DbgLog((LOG_TRACE, 10, L"Read failed at pos: %I64d, hr: 0x%X", pin->m_llPos, hr)); return -1; } if (hr == S_FALSE) { diff --git a/demuxer/LAVSplitter/InputPin.h b/demuxer/LAVSplitter/InputPin.h index 7227d189..afcbe788 100644 --- a/demuxer/LAVSplitter/InputPin.h +++ b/demuxer/LAVSplitter/InputPin.h @@ -59,4 +59,6 @@ private: AVIOContext *m_pAVIOContext = nullptr; IStreamSourceControl *m_pStreamControl = nullptr; + + BOOL m_bURLSource = false; }; |