Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VideoPlayer] Ensure video queue is not in intermediate state when flushing #15716

Merged
merged 1 commit into from Mar 11, 2019

Conversation

Projects
None yet
2 participants
@peak3d
Copy link
Contributor

commented Mar 10, 2019

Description

If VPV receives a Flush() command from VP thread, it is possible that VPV thread has a video packet in process which will be stacked back (decoder resetted / not ready to receive input data after reset)

VP and VPV thread are not synchronized regarding completeness of the msgqueue, and especially after seek the packet with the old PTS value leads to long pause until VP has synced audio and video again.

This PR ensures that all packets are in VPV messagequeue and will be flushed by the VPV::FlushMessages call.

Kodi log snippet:

2019-03-09 23:54:23.297 T:20238   DEBUG: CVideoPlayer::FlushBuffers - flushing buffers
2019-03-09 23:54:23.301 T:20248   DEBUG: CDVDVideoCodecAndroidMediaCodec::AddData dts:354542000.00 pts:354542000.00 sz:9785 indexBuffer:-1 current state (3)
2019-03-09 23:54:23.301 T:20248   DEBUG: CDVDVideoCodecAndroidMediaCodec::SignalEndOfStream: state: 3
2019-03-09 23:54:23.301 T:20248   DEBUG: CDVDVideoCodecAndroidMediaCodec::SignalEndOfStream: ReleaseMediaCodecBuffers
2019-03-09 23:54:23.302 T:20248   DEBUG: CMediaCodecVideoBuffer::ReleaseOutputBuffer index(5), render(0), time:0, offset:0
2019-03-09 23:54:23.302 T:20248   DEBUG: CMediaCodecVideoBuffer::ReleaseOutputBuffer index(12), render(0), time:0, offset:0
2019-03-09 23:54:23.303 T:20248   DEBUG: CMediaCodecVideoBuffer::ReleaseOutputBuffer index(4), render(0), time:0, offset:0
2019-03-09 23:54:23.303 T:20248   DEBUG: CDVDVideoCodecAndroidMediaCodec::SignalEndOfStream: BUFFER_FLAG_END_OF_STREAM send
2019-03-09 23:54:23.303 T:20248   DEBUG: CDVDVideoCodecAndroidMediaCodec::Reset Current state (3)
2019-03-09 23:54:23.309 T:19495   DEBUG: CAnnouncementManager - Announcement: OnSeek from xbmc
2019-03-09 23:54:23.309 T:19495   DEBUG: GOT ANNOUNCEMENT, type: 1, from xbmc, message OnSeek
2019-03-09 23:54:23.310 T:20249   DEBUG: CDVDAudio::Pause - pausing audio stream
2019-03-09 23:54:23.357 T:20249   DEBUG: CDVDAudio::Flush - flush audio stream
2019-03-09 23:54:23.357 T:20249   DEBUG: CDVDAudio::Pause - pausing audio stream
2019-03-09 23:54:23.357 T:20249   DEBUG: CVideoPlayerAudio - CDVDMsg::GENERAL_SYNCHRONIZE
2019-03-09 23:54:23.358 T:20248   DEBUG: CVideoPlayerVideo - CDVDMsg::GENERAL_SYNCHRONIZE
2019-03-09 23:54:23.358 T:20248    INFO: CVideoPlayerVideo - Stillframe left, switching to normal playback
2019-03-09 23:54:23.358 T:20248   DEBUG: CVideoPlayerVideo::CalcDropRequirement - hurry: 0
2019-03-09 23:54:23.358 T:20248   DEBUG: CDVDVideoCodecAndroidMediaCodec::SetCodecControl 0->4000000
2019-03-09 23:54:23.358 T:20248   DEBUG: CDVDVideoCodecAndroidMediaCodec::AddData dts:354542000.00 pts:354542000.00 sz:9785 indexBuffer:-1 current state (2)
2019-03-09 23:54:23.370 T:20248   DEBUG: CDVDVideoCodecAndroidMediaCodec::GetPicture VC_BUFFER
2019-03-09 23:54:23.370 T:20248   DEBUG: CVideoPlayerVideo::CalcDropRequirement - hurry: 0
2019-03-09 23:54:23.370 T:20248   DEBUG: CDVDVideoCodecAndroidMediaCodec::AddData dts:354542000.00 pts:354542000.00 sz:9785 indexBuffer:0 current state (2)
2019-03-09 23:54:23.372 T:20248   DEBUG: CDVDVideoCodecAndroidMediaCodec::GetPicture index: 1, pts:354542000.0000
2019-03-09 23:54:23.379 T:20238   DEBUG: CVideoPlayer::HandleMessages - player started 2
2019-03-09 23:54:23.382 T:19491   DEBUG: CMediaCodecVideoBuffer::ReleaseOutputBuffer index(1), render(1), time:46004559865300, offset:20135350
2019-03-09 23:54:23.383 T:20238   DEBUG: CVideoPlayer::HandleMessages - player started 1
2019-03-09 23:54:23.384 T:20238   DEBUG: CVideoPlayer::SetCaching - caching state 3
2019-03-09 23:54:23.384 T:20227   DEBUG: OnAVChange: CApplication::OnAVChange
2019-03-09 23:54:23.384 T:20238   DEBUG: CDVDClock::SetSpeedAdjust - adjusted:0.000000
2019-03-09 23:54:23.385 T:20238   DEBUG: CVideoPlayer::SetCaching - caching state 0
2019-03-09 23:54:23.385 T:20238   DEBUG: CDVDClock::SetSpeedAdjust - adjusted:0.000000
2019-03-09 23:54:23.385 T:20238   DEBUG: VideoPlayer::Sync - Audio - pts: 385703000.000000, cache: 303728.974831, totalcache: 664166.688919
2019-03-09 23:54:23.385 T:20238   DEBUG: VideoPlayer::Sync - Video - pts: 354542000.000000, cache: 50000.000000, totalcache: 100000.000000

Motivation and Context

Often stalls when seeking Video streams

How Has This Been Tested?

Android, play any stream and seek around some times

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • Clean up (non-breaking change which removes non-working, unmaintained functionality)
  • Improvement (non-breaking change which improves existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that will cause existing functionality to change)
  • Cosmetic change (non-breaking change that doesn't touch code)
  • None of the above (please explain below)

@peak3d peak3d added this to the Leia 18.2-rc1 milestone Mar 10, 2019

@peak3d peak3d force-pushed the peak3d:vpv branch 2 times, most recently from c83d0c7 to 5c92238 Mar 10, 2019

@peak3d

This comment has been minimized.

Copy link
Contributor Author

commented Mar 10, 2019

jenkins build this please

@peak3d peak3d changed the title [VideoPlayer] Ensure queue is not in intermediate state when flushing [VideoPlayer] Ensure video queue is not in intermediate state when flushing Mar 10, 2019

SendMessage(new CDVDMsgBool(CDVDMsg::GENERAL_FLUSH, sync), 1);
m_bAbortOutput = true;
m_flushEvent.Wait();

This comment has been minimized.

Copy link
@FernetMenta

FernetMenta Mar 11, 2019

Member

there is no need to wait here and bypassing the method VP provides for sync. VP syncs with streamplayers by sending a CDVDMsgGeneralSynchronize msg. This is done in CVideoPlayer::FlushBuffers

This comment has been minimized.

Copy link
@peak3d

peak3d Mar 11, 2019

Author Contributor

Thx for looking at it @FernetMenta , Do I understand your comment right that no new packet is send from VP to VPV while VPV thread is waiting for the FLUSH message to be processed?

This comment has been minimized.

Copy link
@peak3d

peak3d Mar 11, 2019

Author Contributor

Thx!

@peak3d peak3d force-pushed the peak3d:vpv branch from 5c92238 to d7b381b Mar 11, 2019

@peak3d

This comment has been minimized.

Copy link
Contributor Author

commented Mar 11, 2019

jenkins build this please

@peak3d peak3d merged commit 79425b7 into xbmc:master Mar 11, 2019

1 check passed

default You're awesome. Have a cookie
Details

@peak3d peak3d deleted the peak3d:vpv branch Mar 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.