Store grabber used along with inetref to ensure correct reuse.

This stores the name of the grabber that returned an inetref, prepended
to the beginning of the inetref, separate by a colon (:). This is then
used to ensure that same grabber, or one that understands its indexing,
is called any time that inetref is used. This resolves an issue where an
inetref from the Television grabber would subsequently be used to pull
data through the Movie grabber, resulting in incorrect information.

This adds a caching mechanism for the grabbers, such that the available
grabbers do not need to be rescanned each time an inetref is to be used.
This cache is expired after 60 seconds, or any time the user enters the
metadata grabber selection screen.

Fixes #12149
Specify supported previous grabbers in tmdb3.py

This specifies that tmdb3.py is able to accept the inetref indexing used
by past tmdb.py and tmdb.pl. The metadata library will then use tmdb3.py
for any existing content tagged with "tmdb.py:xxxx" or "tmdb.pl:xxxx".

Those grabbers were deprecated before the inetref tagging was added, and
so will never be used in practice, but are added for example of how to
use the mechanism.

Refs #12149
BE: Fix 'MythSocket: Programmer error, QEventLoop isn't running...' during BE exit

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
Fix compilation warnings
Mythframe: fix cpuid for Mingw32

Patch by Lawrence Rust <lvr@softsystem.co.uk>
Fix 0b9470c Fix fileringbuffer locking...

Commit 0b9470c (Fix fileringbuffer locking up on read()) modified
FileRingBuffer::safe_read to use fstat() to check the file size
before reading.  The new code compares (internalreadpos + tot)
with the reported size.  This is mostly correct except when
MythPlayer::SwitchProgram detects the transition across a livetv
programme boundary.  In this case internalreadpos holds the read
position for the old file until the decoder calls FileChanged().

This patch includes readAdjust (set by SetAdjustFilesize()) to
correctly determine the current read position in the file.

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
VO: Fail VAAPI reinit from decoder thread to avoid Qt abort in doneCurrent

If a recording starts without a video stream then if the video
subsequently becomes active the decoder attempts to re-init the
display.  However, the OpenGL functions fail if called outside of the
UI thread and this results in an unbalanced series of calls to
doneCurrebt which triggers a Qt abort (debug build) due to a recursive
mutex overflow.

This bug is tickled by the CloseShave video which started recording
at just before 7pm on BBC3, which is just before the start of normal
BBC prgrams.  The initial stream consists of MHEG data only.

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
Player: Increase OpenFile timeout to allow playing encrypted isos on a remote FE

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
AFD: Read packets until audio PTS >= video PTS

If the 'Extra audio buffering' setting is disabled then the audio
stream PTS can lag the video by up to a second.  This can sometimes
cause A/V sync problems but also causes sync problems when displaying
the audio output graph when editing the cutlist.

This patch ensures that the last audio PTS at least equals the video
PTS before exiting GetFrame.  This ensures there are matching audio
samples for the pause frame shown in the cutlkist editor.

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
TV: Quit the TV playback loop when the primary player reports a fatal error

If MythPlayer::OpenFile fails (for instance network congestion) then
TV::StartTV continues by restarting TV instance which then causes problems
for the backend.

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
Player: DecoderLoop sleeps until audio buffers available

DVB radio streams (e.g. UK FreeView & FreeSat) burn 100% CPU time when
playing back a recording.

This patch adds a 1mS sleep loop until the audio buffer has space
available.

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
CoreContext: Add missing QRunnable header

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
AO: SetStretchFactor sets pause until buffered to smooth playback start

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
AO: Pause resets PauseUntilBuffered

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
TV UnpauseLiveTV calls tvchain->SwitchTo opposed to JumpTo to minimise visible disruption

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
AO: Don't disable Pulse if no valid output

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
AO: Cache the result of IsPulseAudioRunning

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
OpenGL: Reduce video playback overhead

This patch introduces 2 changes to reduce video frame overhead and
hence reduce CPU load.

1. In MythRenderOpenGL::doneCurrent don't call QGLContext::doneCurrent
as it's strictly not necessary and causes the next call to makeCurrent
to take considerably longer.  Saves ~ 11mS per frame.

2. In VideoOutputOpenGL::Show only call gl_context->swapBuffers if
the current format is double buffered,  Saves ~2mS per frame.

Timings from an Intel i5 661 @ 3.33GHz using onboard graphics with
Linux 3.4 KMS.

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
libmyth: Prevent SEGV in avcodec_decode_video2 when playing nuv material

Under certain circumstances NuppelDecoder::DecodeFrame can call
avcodec_decode_video2 when mpa_vidctx is NULL and thus cause a SEGV.

This patch adds a test for a NULL mpa_vidctx exits with error.

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
Player: Improve low bit rate / high latency stream playback

DVB-S radio programs are low bit rate (64Kbps..256Kbps) and suffer
occasional latency.

MHEG interaction streams are internet sourced and often suffer congestion
resulting in high latency for some packets.

- Fix a number of issues to do with changing program to DVB-S radio and
  the lack of video stream causing garbage video display.

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>