Virtual base class for all video synchronization classes. More...
#include <vsync.h>
Public Member Functions | |
| VideoSync (VideoOutput *, int fi, int ri, bool intr) | |
| Used by BestMethod(VideoOutput*,uint,uint,bool) to initialize video synchronization method. | |
| virtual | ~VideoSync () |
| virtual QString | getName (void) const =0 |
| Returns name of instanciated VSync method. | |
| virtual bool | TryInit (void)=0 |
| Tries to initialize VSync method. | |
| virtual void | Start (void) |
| Start VSync; must be called from main thread. | |
| virtual int | WaitForFrame (int sync_delay)=0 |
| Waits for next a frame or field. | |
| int | getRefreshInterval (void) const |
| Returns the (minimum) refresh interval of the output device. | |
| void | setRefreshInterval (int ri) |
| Sets the refresh interval of the output device. | |
| virtual void | setFrameInterval (int fi) |
| virtual void | Stop (void) |
| Stops VSync; must be called from main thread. | |
Static Public Member Functions | |
| static VideoSync * | BestMethod (VideoOutput *, uint frame_interval, uint refresh_interval, bool interlaced) |
| Returns the most sophisticated video sync method available. | |
Protected Member Functions | |
| int64_t | GetTime (void) |
| int | CalcDelay (void) |
| Calculates the delay to the next frame. | |
| void | KeepPhase (void) |
| Keep our nexttrigger from drifting too close to the exact retrace. | |
Protected Attributes | |
| VideoOutput * | m_video_output |
| int | m_frame_interval |
| int | m_refresh_interval |
| bool | m_interlaced |
| int64_t | m_nexttrigger |
| int | m_delay |
Static Protected Attributes | |
| static int | m_forceskip = 0 |
Virtual base class for all video synchronization classes.
This set of classes implements a variety of algorithms for synching video frames to a display. The better algorithms synchronize to the display's refresh rate, and also attempt to maintain phase with respect to the vertical retrace. The poorer algorithms simply try to display frames at a regular interval.
The factory method BestMethod tries subclasses in roughly quality order until one succeeds.
A/V sync methods may supply the nominal delay per frame. Other than that, video timing is entirely up to these classes. When WaitForFrame returns, it is time to show the frame.
Definition at line 45 of file vsync.h.
| VideoSync::VideoSync | ( | VideoOutput * | video_output, | |
| int | fi, | |||
| int | ri, | |||
| bool | intr | |||
| ) |
Used by BestMethod(VideoOutput*,uint,uint,bool) to initialize video synchronization method.
| virtual QString VideoSync::getName | ( | void | ) | const [pure virtual] |
Returns name of instanciated VSync method.
Implemented in DRMVideoSync, RTCVideoSync, BusyWaitVideoSync, USleepVideoSync, and DummyVideoSync.
Referenced by MythPlayer::InitAVSync().
| virtual bool VideoSync::TryInit | ( | void | ) | [pure virtual] |
Tries to initialize VSync method.
Implemented in DRMVideoSync, RTCVideoSync, BusyWaitVideoSync, USleepVideoSync, and DummyVideoSync.
| void VideoSync::Start | ( | void | ) | [virtual] |
Start VSync; must be called from main thread.
Start(void), WaitForFrame(void), and Stop(void) should always be called from same thread, to prevent bad interactions with threads.
Reimplemented in DRMVideoSync.
Definition at line 131 of file vsync.cpp.
Referenced by MythPlayer::DisplayPauseFrame(), MythPlayer::InitAVSync(), MythPlayer::PrebufferEnoughFrames(), and MythPlayer::VideoStart().
| virtual int VideoSync::WaitForFrame | ( | int | sync_delay | ) | [pure virtual] |
Waits for next a frame or field.
Returns delay to real frame timing in usec
Start(void), WaitForFrame(void), and Stop(void) should always be called from same thread, to prevent bad interactions with threads.
| sync_delay | time until the desired frame or field |
Implemented in DRMVideoSync, RTCVideoSync, BusyWaitVideoSync, USleepVideoSync, and DummyVideoSync.
Referenced by MythPlayer::AVSync().
| int VideoSync::getRefreshInterval | ( | void | ) | const [inline] |
Returns the (minimum) refresh interval of the output device.
Definition at line 78 of file vsync.h.
Referenced by MythPlayer::CanSupportDoubleRate(), and MythPlayer::ReinitVideo().
| void VideoSync::setRefreshInterval | ( | int | ri | ) | [inline] |
Sets the refresh interval of the output device.
Definition at line 80 of file vsync.h.
Referenced by MythPlayer::ReinitVideo().
| virtual void VideoSync::setFrameInterval | ( | int | fi | ) | [inline, virtual] |
Definition at line 82 of file vsync.h.
Referenced by MythPlayer::ChangeSpeed(), and MythPlayer::SetVideoParams().
| virtual void VideoSync::Stop | ( | void | ) | [inline, virtual] |
Stops VSync; must be called from main thread.
Start(void), WaitForFrame(void), and Stop(void) should always be called from same thread, to prevent bad interactions with threads.
| VideoSync * VideoSync::BestMethod | ( | VideoOutput * | video_output, | |
| uint | frame_interval, | |||
| uint | refresh_interval, | |||
| bool | interlaced | |||
| ) | [static] |
Returns the most sophisticated video sync method available.
Definition at line 76 of file vsync.cpp.
Referenced by MythPlayer::VideoStart().
| int64_t VideoSync::GetTime | ( | void | ) | [protected] |
Definition at line 124 of file vsync.cpp.
Referenced by CalcDelay(), and Start().
| int VideoSync::CalcDelay | ( | void | ) | [protected] |
Calculates the delay to the next frame.
Regardless of the timing method, if delay is greater than four full frames (could be greater than 20 or greater than 200), we don't want to freeze while waiting for a huge delay. Instead, contine playing video at half speed and continue to read new audio and video frames from the file until the sync is 'in the ballpark'. Also prevent the nexttrigger from falling too far in the past in case we are trying to speed up video output faster than possible.
Definition at line 147 of file vsync.cpp.
Referenced by USleepVideoSync::WaitForFrame(), BusyWaitVideoSync::WaitForFrame(), RTCVideoSync::WaitForFrame(), and DRMVideoSync::WaitForFrame().
| void VideoSync::KeepPhase | ( | void | ) | [protected] |
Keep our nexttrigger from drifting too close to the exact retrace.
If delay is near zero, some frames will be delay < 0 and others delay > 0 which would cause continous rapid fire stuttering. This method is only useful for those sync methods where WaitForFrame targets hardware retrace rather than targeting nexttrigger. NOTE: deprecated in favor of handling phase issues in mythplayer's AVSync.
VideoOutput* VideoSync::m_video_output [protected] |
int VideoSync::m_frame_interval [protected] |
Definition at line 102 of file vsync.h.
Referenced by CalcDelay(), setFrameInterval(), and BusyWaitVideoSync::WaitForFrame().
int VideoSync::m_refresh_interval [protected] |
Definition at line 103 of file vsync.h.
Referenced by CalcDelay(), getRefreshInterval(), KeepPhase(), setRefreshInterval(), and DRMVideoSync::WaitForFrame().
bool VideoSync::m_interlaced [protected] |
Definition at line 104 of file vsync.h.
Referenced by CalcDelay().
int64_t VideoSync::m_nexttrigger [protected] |
Definition at line 105 of file vsync.h.
Referenced by CalcDelay(), KeepPhase(), Start(), USleepVideoSync::WaitForFrame(), BusyWaitVideoSync::WaitForFrame(), RTCVideoSync::WaitForFrame(), and DRMVideoSync::WaitForFrame().
int VideoSync::m_delay [protected] |
Definition at line 106 of file vsync.h.
Referenced by KeepPhase(), USleepVideoSync::WaitForFrame(), BusyWaitVideoSync::WaitForFrame(), RTCVideoSync::WaitForFrame(), and DRMVideoSync::WaitForFrame().
int VideoSync::m_forceskip = 0 [static, protected] |
Definition at line 108 of file vsync.h.
Referenced by BestMethod().
1.6.3