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
Regression: video hangs at end of file instead of exiting #511
Comments
I can't reproduce this with either current master or current fixes/32. Both exit at the end of playback as expected. |
In the frontend settings: Video -> Playback -> General Playback -> "Action on playback exit" is "exit without saving" and "prompt at end of recording" is unchecked. On master I can trigger this every time. However, when making changes to the code to aid harmonizing mpegts-mythtv, in some instances it exited as expected, so this may be a race condition. (I am testing on a 2 core Intel Pentium G3258.) From v32: A race condition is highly likely: Samples from https://code.mythtv.org/trac/ticket/13557 : file "a" was race-y, file "b" may also be race-y. |
I tried this and I observe different behavior.
|
The bad change 754d740 was reverted with additional breaking changes in 3f3ee47 . See #512 for my fix. logs with mythfrontend.20220303210456.8601.mythplayer.log |
Scott, try this patch. diff --git a/mythtv/libs/libmythtv/mythplayer.cpp b/mythtv/libs/libmythtv/mythplayer.cpp index 8f7ac450c6..6a9f0738eb 100644 --- a/mythtv/libs/libmythtv/mythplayer.cpp +++ b/mythtv/libs/libmythtv/mythplayer.cpp @@ -833,15 +833,10 @@ bool MythPlayer::PrebufferEnoughFrames(int min_buffers) return false; } - // Make sure we have at least one frame available. The EOF case - // can get here without one. - if (!m_videoOutput->ValidVideoFrames()) - return false; - if (!m_avSync.GetAVSyncAudioPause()) m_audio.Pause(false); SetBuffering(false); - return true; + return m_videoOutput->ValidVideoFrames(); } void MythPlayer::VideoEnd(void) |
This change is equivalent to the third alternative I gave in #512 (comment) and only sometimes works. I will continue investigating where more EOF code is needed. Reopen this issue. |
The issue appears to be: TV::PlaybackLoop() is an infinite loop and repeatedly calls MythPlayerUI::VideoLoop() which calls MythPlayerUI::DisplayNormalFrame() which never progresses since it calls MythPlayer::PrebufferEnoughFrames() which gets stuck returning false when GetEof() returns kEofStateDelayed. |
@gigem if you want to keep MythPlayer::PrebufferEnoughFrames() as is see ulmus-scott@1a60226 for my new fix.
|
I've already told you returning true in PrebufferEnoughFrames() when there are no valid frames is wrong. It causes invalid frames to be accessed. Bypassing the check in DisplayNormalFrame() is equally wrong. It is the eof of playback detection ELSEWHERE that is buggy. It was masked by the bug that allowed access of invalid frames. I will not reintroduce the invalid access bug to "fix" the end of playback bug. Frankly, I don't see why PrebufferEnoughFrames() shouldn't wait normally for additional frames when near end of file has been reached. The only thing that should be different at near end of file is to not require extra frames be queued. Playback should end when the decoder signals end of file AND all frames have been played. I suggest you concentrate your efforts on finding and fixing that bug. |
I belive at least part of the underlying problem has to do with frame counting. Bypassing the PrebufferingEnoughFrames() check and accessing invalid frames will incorrectly inflate the frames played count. |
While not usable as is, this appears to solve the problem:
The audio lines appear to be for audio only recordings. I didn't know MythTV could make audio only recordings. References: (last few seconds of video are not played) https://code.mythtv.org/trac/ticket/6974 Avoid premature playback exit for audio-only recordings. cef316f (Position/duration of audio-only files is incorrect) https://code.mythtv.org/trac/ticket/11357 Guard against a null AudioOutput. 0aedcae Don't wait for paused audio to drain. Fixes #11730. 8b542e2 (Playback doesn't exit at the end of playback) https://code.mythtv.org/trac/ticket/11730 |
I created an audio only TS and a video only TS from a sample and both played until the end and exited correctly. Fixes MythTV#511 For the audio only TS, MythTV appears to create black frames, which means I could not actually test the "audio only" branch.
Scott, please try this patch. It's not necessarily the final fix but might help confirm what I think is happening. diff --git a/mythtv/libs/libmythtv/mythplayerui.cpp b/mythtv/libs/libmythtv/mythplayerui.cpp index 1edb662622..5b31683b14 100644 --- a/mythtv/libs/libmythtv/mythplayerui.cpp +++ b/mythtv/libs/libmythtv/mythplayerui.cpp @@ -244,7 +244,7 @@ void MythPlayerUI::EventLoop() } bool videoDrained = - m_videoOutput && m_videoOutput->ValidVideoFrames() < 1; + m_videoOutput && !m_videoOutput->EnoughDecodedFrames(); bool audioDrained = !m_audio.GetAudioOutput() || m_audio.IsPaused() || |
David, no joy. I took the liberty of adding some logging:
Which gives an infinite stream of:
Another, probably related bug is that the playback loop never exits, even after exiting the frontend, i.e. I had to |
The beginning of that infinite stream is:
So Which is why my fix to ignore the audio buffer for non-Music Choice streams worked. |
What frontend and video profile are you using? |
mythfrontend |
I created an audio only TS and a video only TS from a sample and both played until the end and exited correctly. Fixes MythTV#511 For the audio only TS, MythTV appears to create black frames, which means I could not actually test the "audio only" branch.
normal/video-only content. Fixes #511 Signed-off-by: David Engel <dengel@mythtv.org>
FYI, I still can't reliably reproduce the issue but your last, core fix looks reasonable enough and does't appear to do any harm. Thanks for being persistent. |
Platform: Xubuntu 21.10
Linux htpc 5.13.0-30-generic #33-Ubuntu SMP Fri Feb 4 17:03:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
MythTV version: v33/master
Package version: n/a
Component: mythfrontend
What steps will reproduce the bug?
Play a recording or video and let it play until the end of file.
How often does it reproduce? Is there a required condition?
Always.
What is the expected behaviour?
Playback exits.
What do you see instead?
Playback is paused at end of file.
E decoding error End of file (-541478725)
is shown in the log. Detecting EOF may be a solution.Playback exits with
Esc
as expected or after pausing and playing the video (hittingspace
twice).Additional information
git bisect yielded 754d740 @gigem
The text was updated successfully, but these errors were encountered: