Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/Mediaportal/MP1-5177-MP_Audiore…
Browse files Browse the repository at this point in the history
…nderer_video_audio_sync_issuse_while_seek_resume' into MP1.32_Final_Test5
  • Loading branch information
andrewjswan committed Oct 28, 2023
2 parents f60daab + 16aea06 commit ab977d8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
14 changes: 13 additions & 1 deletion DirectShowFilters/MPAudioRenderer/source/MpAudioRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,19 @@ STDMETHODIMP CMPAudioRenderer::GetState(DWORD dwMSecs, FILTER_STATE* State)
if (m_State == State_Paused && (m_pRenderer->BufferredDataDuration() <= (m_pSettings->GetOutputBuffer() * 10000)) &&
(GetCurrentTimestamp() - m_lastSampleArrivalTime < SAMPLE_RECEIVE_TIMEOUT))
{
NotifyEvent(EC_STARVATION, 0, 0);
/*
EC_STARVATION
A filter is not receiving enough data.
The event is not sent to the application.
If the filter graph is running, the filter graph manager pauses the graph and waits for the pause to complete. Then it runs the graph again.
The filter sending the event should not complete its transition to paused until it has enough data to resume.
If the filter graph is not running, the filter graph manager ignores this event.
*/

// We should not report this event while in paused state: it sometimes causes graph to pause/resume again right after the resume is complete,
// and it leads to issues in WASAPI renderer (early sample check)
//NotifyEvent(EC_STARVATION, 0, 0);

*State = State_Paused;

return VFW_S_STATE_INTERMEDIATE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ HRESULT CWASAPIRenderFilter::CheckStreamTimeline(IMediaSample* pSample, REFERENC

return MPAR_S_DROP_SAMPLE;
}
else if ((m_nSampleNum == 0 && *pDueTime > rtHWTime) || resync)
else if ((m_nSampleNum == 0 && *pDueTime > rtHWTime) || (m_nSampleNum <= 20 && (*pDueTime - rtHWTime) > 150000) || resync)
{
m_nSampleNum++;

Expand Down Expand Up @@ -580,6 +580,8 @@ void CWASAPIRenderFilter::UpdateAudioClock()
Log("UpdateAudioClock: prevPos: %6.3f > ullHwClock: %6.3f diff: %6.3f QPC diff: %6.3f m_llPosError: %6.3f correction: %6.3f",
m_ullPrevPos / 10000000.0, ullHwClock / 10000000.0, (m_ullPrevPos - ullHwClock) / 10000000.0, (qpc - m_ullPrevQpc) / 10000000.0,
m_llPosError / 10000000.0, correction / 10000000.0);

m_nSampleNum = 0;
}

m_ullPrevPos = ullHwClock;
Expand Down Expand Up @@ -841,6 +843,7 @@ DWORD CWASAPIRenderFilter::ThreadProc()
{
sampleProcessed = false;
writeSilence = 0;
m_nSampleNum = 0;
m_state = StateRunning;
if (!m_pCurrentSample)
{
Expand Down

0 comments on commit ab977d8

Please sign in to comment.