Skip to content

Commit

Permalink
MP1-5178: Mediatype change: Set sample mediatype if previous sample w…
Browse files Browse the repository at this point in the history
…as not delivered
  • Loading branch information
epbk committed Oct 30, 2023
1 parent 86ea20b commit 155074f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
20 changes: 19 additions & 1 deletion DirectShowFilters/MPAudioswitcher/source/StreamSwitcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ CStreamSwitcherInputPin::CStreamSwitcherInputPin(CStreamSwitcherFilter* pFilter,
, m_bSampleSkipped(FALSE)
, m_bQualityChanged(FALSE)
, m_bUsingOwnAllocator(FALSE)
, m_bSampleSetMedia(FALSE)
, m_evBlock(TRUE)
, m_fCanBlock(false)
, m_hNotifyEvent(NULL)
Expand Down Expand Up @@ -760,6 +761,8 @@ STDMETHODIMP CStreamSwitcherInputPin::Receive(IMediaSample* pSample)
((CStreamSwitcherFilter*)m_pFilter)->OnNewOutputMediaType(m_mt, mtOut);
pOutSample->SetMediaType(&mtOut);
}
else if (m_bSampleSetMedia)
pOutSample->SetMediaType(&mtOut);

// Transform

Expand All @@ -770,7 +773,22 @@ STDMETHODIMP CStreamSwitcherInputPin::Receive(IMediaSample* pSample)
if(S_OK == hr)
{
hr = pOut->Deliver(pOutSample);
m_bSampleSkipped = FALSE;
if (FAILED(hr))
{
//sample was not delivered (usually becouse of flushing)
if (fTypeChanged)
{
//next sample must carry the mediatype and AM_SAMPLE_TYPECHANGED flag set
m_bSampleSetMedia = TRUE;
}

m_bSampleSkipped = TRUE;
}
else
{
m_bSampleSetMedia = FALSE;
m_bSampleSkipped = FALSE;
}
/*
if(FAILED(hr))
{
Expand Down
1 change: 1 addition & 0 deletions DirectShowFilters/MPAudioswitcher/source/StreamSwitcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class CStreamSwitcherInputPin : public CBaseInputPin, public IPinConnection, pub
BOOL m_bSampleSkipped;
BOOL m_bQualityChanged;
BOOL m_bUsingOwnAllocator;
BOOL m_bSampleSetMedia;

CAMEvent m_evBlock;
bool m_fCanBlock;
Expand Down

0 comments on commit 155074f

Please sign in to comment.