MythTV  master
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Attributes | Static Private Attributes | Friends | List of all members
RingBuffer Class Referenceabstract

Implements a file/stream reader/writer. More...

#include <ringbuffer.h>

Inheritance diagram for RingBuffer:
Inheritance graph
[legend]
Collaboration diagram for RingBuffer:
Collaboration graph
[legend]

Public Member Functions

virtual ~RingBuffer ()=0
 Deletes. More...
 
void SetWriteBufferSize (int newSize)
 
void SetWriteBufferMinWriteSize (int newMinSize)
 Calls ThreadedFileWriter::SetWriteBufferMinWriteSize(int) More...
 
void SetOldFile (bool is_old)
 Tell RingBuffer if this is an old file or not. More...
 
void UpdateRawBitrate (uint raw_bitrate)
 Set the raw bit rate, to allow RingBuffer adjust effective bitrate. More...
 
void UpdatePlaySpeed (float play_speed)
 Set the play speed, to allow RingBuffer adjust effective bitrate. More...
 
void EnableBitrateMonitor (bool enable)
 
void SetBufferSizeFactors (bool estbitrate, bool matroska)
 Tells RingBuffer that the raw bitrate may be innacurate and the underlying container is matroska, both of which may require a larger buffer size. More...
 
void SetWaitForWrite (void)
 
QString GetSafeFilename (void)
 
QString GetFilename (void) const
 Returns name of file used by this RingBuffer. More...
 
QString GetSubtitleFilename (void) const
 
QString GetLastError (void) const
 
bool GetCommsError (void) const
 
void ResetCommsError (void)
 
bool GetStopReads (void) const
 Returns value of stopreads. More...
 
bool isPaused (void) const
 Returns false iff read-ahead is not running and read-ahead is not paused. More...
 
virtual long long GetReadPosition (void) const =0
 Returns how far into the file we have read. More...
 
QString GetDecoderRate (void)
 
QString GetStorageRate (void)
 
QString GetAvailableBuffer (void)
 
uint GetBufferSize (void)
 
long long GetWritePosition (void) const
 Returns how far into a ThreadedFileWriter file we have written. More...
 
long long GetRealFileSize (void) const
 Returns the size of the file we are reading/writing, or -1 if the query fails. More...
 
bool IsNearEnd (double fps, uint vvf) const
 
virtual bool IsOpen (void) const =0
 Returns true if open for either reading or writing. More...
 
virtual bool IsStreamed (void)
 
virtual bool IsSeekingAllowed (void)
 
virtual bool IsBookmarkAllowed (void)
 
virtual int BestBufferSize (void)
 
RingBufferType GetType () const
 
int GetReadBufAvail () const
 Returns number of bytes available for reading from buffer. More...
 
bool SetReadInternalMode (bool mode)
 
bool IsReadInternalMode (void)
 
bool IsDisc (void) const
 
bool IsDVD (void) const
 
bool IsBD (void) const
 
const DVDRingBufferDVD (void) const
 
const BDRingBufferBD (void) const
 
DVDRingBufferDVD (void)
 
BDRingBufferBD (void)
 
virtual bool StartFromBeginning (void)
 
virtual void IgnoreWaitStates (bool)
 
virtual bool IsInMenu (void) const
 
virtual bool IsInStillFrame (void) const
 
virtual bool IsInDiscMenuOrStillFrame (void) const
 
virtual bool HandleAction (const QStringList &, int64_t)
 
virtual bool OpenFile (const QString &lfilename, uint retry_ms=kDefaultOpenTimeout)=0
 Opens a file for reading. More...
 
virtual bool ReOpen (QString="")
 
int Read (void *buf, int count)
 This is the public method for reading from a file, it calls the appropriate read method if the file is remote or buffered, or a BD/DVD. More...
 
int Peek (void *buf, int count)
 
void Reset (bool full=false, bool toAdjust=false, bool resetInternal=false)
 Resets the read-ahead thread and our position in the file. More...
 
long long Seek (long long pos, int whence, bool has_lock=false)
 Seeks to a particular position in the file. More...
 
void Pause (void)
 Pauses the read-ahead thread. More...
 
void Unpause (void)
 Unpauses the read-ahead thread. More...
 
void WaitForPause (void)
 Waits for Pause(void) to take effect. More...
 
void Start (void)
 Starts the read-ahead thread. More...
 
void StopReads (void)
 ???? More...
 
void StartReads (void)
 ???? More...
 
bool LiveMode (void) const
 Returns true if this RingBuffer has been assigned a LiveTVChain. More...
 
void SetLiveMode (LiveTVChain *chain)
 Assigns a LiveTVChain to this RingBuffer. More...
 
void IgnoreLiveEOF (bool ignore)
 Tells RingBuffer whether to ignore the end-of-file. More...
 
int Write (const void *buf, uint count)
 Writes buffer to ThreadedFileWriter::Write(const void*,uint) More...
 
bool IsIOBound (void) const
 
void WriterFlush (void)
 Calls ThreadedFileWriter::Flush(void) More...
 
void Sync (void)
 Calls ThreadedFileWriter::Sync(void) More...
 
long long WriterSeek (long long pos, int whence, bool has_lock=false)
 Calls ThreadedFileWriter::Seek(long long,int). More...
 
bool WriterSetBlocking (bool lock=true)
 Calls ThreadedFileWriter::SetBlocking(bool) More...
 
long long SetAdjustFilesize (void)
 

Static Public Member Functions

static RingBufferCreate (const QString &xfilename, bool write, bool usereadahead=true, int timeout_ms=kDefaultOpenTimeout, bool stream_only=false)
 Creates a RingBuffer instance. More...
 
static QString BitrateToString (uint64_t rate, bool hz=false)
 
static void AVFormatInitNetwork (void)
 

Static Public Attributes

static const int kDefaultOpenTimeout = 2000
 
static const int kLiveTVOpenTimeout = 10000
 
static QMutex s_subExtLock
 
static QStringList s_subExt
 
static QStringList s_subExtNoCheck
 

Protected Member Functions

 RingBuffer (RingBufferType rbtype)
 
void run (void) override
 Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead. More...
 
void CreateReadAheadBuffer (void)
 
void CalcReadAheadThresh (void)
 Calculates m_fillMin, m_fillThreshold, and m_readBlockSize from the estimated effective bitrate of the stream. More...
 
bool PauseAndWait (void)
 
virtual int safe_read (void *data, uint sz)=0
 
int ReadPriv (void *buf, int count, bool peek)
 When possible reads from the read-ahead buffer, otherwise reads directly from the device. More...
 
int ReadDirect (void *buf, int count, bool peek)
 
bool WaitForReadsAllowed (void)
 
int WaitForAvail (int count, int timeout)
 
virtual long long GetRealFileSizeInternal (void) const
 
virtual long long SeekInternal (long long pos, int whence)=0
 
int ReadBufFree (void) const
 Returns number of bytes available for reading into buffer. More...
 
int ReadBufAvail (void) const
 Returns number of bytes available for reading from buffer. More...
 
void ResetReadAhead (long long newinternal)
 Restart the read-ahead thread at the 'newinternal' position. More...
 
void KillReadAheadThread (void)
 Stops the read-ahead thread, and waits for it to stop. More...
 
uint64_t UpdateDecoderRate (uint64_t latest=0)
 
uint64_t UpdateStorageRate (uint64_t latest=0)
 
- Protected Member Functions inherited from MThread
int exec (void)
 Enters the qt event loop. call exit or quit to exit thread. More...
 
 MThread (const QString &objectName)
 Standard constructor. More...
 
 MThread (const QString &objectName, QRunnable *runnable)
 Use this constructor if you want the default run() method to run the QRunnable's run() method instead of entering the Qt event loop. More...
 
virtual ~MThread ()
 
void RunProlog (void)
 Sets up a thread, call this if you reimplement run(). More...
 
void RunEpilog (void)
 Cleans up a thread's resources, call this if you reimplement run(). More...
 
QThread * qthread (void)
 Returns the thread, this will always return the same pointer no matter how often you restart the thread. More...
 
void setObjectName (const QString &name)
 
QString objectName (void) const
 
void setPriority (QThread::Priority priority)
 
QThread::Priority priority (void) const
 
bool isFinished (void) const
 
bool isRunning (void) const
 
void setStackSize (uint stackSize)
 
uint stackSize (void) const
 
void exit (int retcode=0)
 Use this to exit from the thread if you are using a Qt event loop. More...
 
void start (QThread::Priority=QThread::InheritPriority)
 Tell MThread to start running the thread in the near future. More...
 
void terminate (void)
 Kill a thread unsafely. More...
 
void quit (void)
 calls exit(0) More...
 
bool wait (unsigned long time=ULONG_MAX)
 Wait for the MThread to exit, with a maximum timeout. More...
 

Protected Attributes

RingBufferType m_type
 
QReadWriteLock m_posLock
 
long long m_readPos {0}
 
long long m_writePos {0}
 
long long m_internalReadPos {0}
 
long long m_ignoreReadPos {-1}
 
QReadWriteLock m_rbrLock
 
int m_rbrPos {0}
 
QReadWriteLock m_rbwLock
 
int m_rbwPos {0}
 
volatile bool m_stopReads {false}
 
QString m_safeFilename
 
QReadWriteLock m_rwLock
 
QString m_filename
 
QString m_subtitleFilename
 
QString m_lastError
 
ThreadedFileWriterm_tfw {nullptr}
 
int m_fd2 {-1}
 
bool m_writeMode {false}
 
RemoteFilem_remotefile {nullptr}
 
uint m_bufferSize {BUFFER_SIZE_MINIMUM}
 
bool m_lowBuffers {false}
 
bool m_fileIsMatroska {false}
 
bool m_unknownBitrate {false}
 
bool m_startReadAhead {false}
 
char * m_readAheadBuffer {nullptr}
 
bool m_readAheadRunning {false}
 
bool m_reallyRunning {false}
 
bool m_requestPause {false}
 
bool m_paused {false}
 
bool m_ateof {false}
 
bool m_waitForWrite {false}
 
bool m_beingWritten {false}
 
bool m_readsAllowed {false}
 
bool m_readsDesired {false}
 
volatile bool m_recentSeek {true}
 
bool m_setSwitchToNext {false}
 
uint m_rawBitrate {8000}
 
float m_playSpeed {1.0F}
 
int m_fillThreshold {65536}
 
int m_fillMin {-1}
 
int m_readBlockSize {CHUNK}
 
int m_wantToRead {0}
 
int m_numFailures {0}
 
bool m_commsError {false}
 
bool m_oldfile {false}
 
LiveTVChainm_liveTVChain {nullptr}
 
bool m_ignoreLiveEOF {false}
 
long long m_readAdjust {0}
 
int m_readOffset {0}
 
bool m_readInternalMode {false}
 
bool m_bitrateMonitorEnabled {false}
 
QMutex m_decoderReadLock
 
QMap< qint64, uint64_t > m_decoderReads
 
QMutex m_storageReadLock
 
QMap< qint64, uint64_t > m_storageReads
 
QWaitCondition m_generalWait
 Condition to signal that the read ahead thread is running. More...
 
- Protected Attributes inherited from MThread
MThreadInternalm_thread {nullptr}
 
QRunnable * m_runnable {nullptr}
 
bool m_prolog_executed {true}
 
bool m_epilog_executed {true}
 

Private Attributes

bool m_bitrateInitialized {false}
 

Static Private Attributes

static bool gAVformat_net_initialised = false
 

Friends

class ICRingBuffer
 

Additional Inherited Members

- Static Protected Member Functions inherited from MThread
static void setTerminationEnabled (bool enabled=true)
 
static void sleep (unsigned long time)
 
static void msleep (unsigned long time)
 
static void usleep (unsigned long time)
 
static void ThreadSetup (const QString &)
 This is to be called on startup in those few threads that haven't been ported to MThread. More...
 
static void ThreadCleanup (void)
 This is to be called on exit in those few threads that haven't been ported to MThread. More...
 
static void Cleanup (void)
 This will print out all the running threads, call exit(1) on each and then wait up to 5 seconds total for all the threads to exit. More...
 
static void GetAllThreadNames (QStringList &list)
 
static void GetAllRunningThreadNames (QStringList &list)
 
- Static Protected Attributes inherited from MThread
static const int kDefaultStartTimeout
 

Detailed Description

Implements a file/stream reader/writer.

This class, despite its name, no-longer provides a ring buffer. It can buffer reads and provide support for streaming files. It also provides a wrapper for the ThreadedFileWriter which makes sure that the file reader does not read past where the wrapped TFW has written new data.

Definition at line 53 of file libs/libmythtv/ringbuffer.h.

Constructor & Destructor Documentation

◆ ~RingBuffer()

RingBuffer::~RingBuffer ( void  )
pure virtual

Deletes.

Note
Classes inheriting from RingBuffer must implement a destructor that calls KillReadAheadThread(). We can not do that here because this would leave pure virtual functions without implementations during destruction.

Definition at line 246 of file ringbuffer.cpp.

◆ RingBuffer()

RingBuffer::RingBuffer ( RingBufferType  rbtype)
explicitprotected

Definition at line 212 of file ringbuffer.cpp.

Member Function Documentation

◆ Create()

RingBuffer * RingBuffer::Create ( const QString &  xfilename,
bool  write,
bool  usereadahead = true,
int  timeout_ms = kDefaultOpenTimeout,
bool  stream_only = false 
)
static

Creates a RingBuffer instance.

You can explicitly disable the readahead thread by setting readahead to false, or by just not calling Start(void).

Parameters
xfilenameName of file to read or write.
writeIf true an encapsulated writer is created
usereadaheadIf false a call to Start(void) will not a pre-buffering thread, otherwise Start(void) will start a pre-buffering thread.
timeout_msif < 0, then we will not open the file. Otherwise it's how long to try opening the file after the first failure in milliseconds before giving up.
stream_onlyIf true, prevent DVD and Bluray (used by FileTransfer)

Definition at line 104 of file ringbuffer.cpp.

Referenced by CopyFile(), FlagCommercials(), TVRec::GetProgramRingBufferForLiveTV(), PreviewGenerator::GetScreenGrab(), TV::HandleStateChange(), NuppelVideoRecorder::Initialize(), mythfile_open(), AVFormatWriter::OpenFile(), pid_counter(), pid_filter(), pid_printer(), RebuildSeekTable(), ImportRecorder::run(), RunCCExtract(), TV::SwitchInputs(), TVRec::SwitchRecordingRingBuffer(), VideoPerformanceTest::Test(), Transcode::TranscodeFile(), and TVRec::TuningNewRecorder().

◆ SetWriteBufferSize()

void RingBuffer::SetWriteBufferSize ( int  newSize)

◆ SetWriteBufferMinWriteSize()

void RingBuffer::SetWriteBufferMinWriteSize ( int  newMinSize)

Calls ThreadedFileWriter::SetWriteBufferMinWriteSize(int)

Definition at line 1811 of file ringbuffer.cpp.

◆ SetOldFile()

void RingBuffer::SetOldFile ( bool  is_old)

Tell RingBuffer if this is an old file or not.

Normally the RingBuffer determines that the file is old if it has not been modified in the last minute. This allows one to override that determination externally.

If for instance you are slowly writing to the file you could call this with the value of false. If you just finished writing the file you could call it with the value true. Knowing that the file is old allows MythTV to determine that a read at the end of the file is really an end-of-file condition more quickly. But if the file is growing it can also cause the RingBuffer to report an end-of-file condition prematurely.

Definition at line 1846 of file ringbuffer.cpp.

Referenced by FileTransfer::SetTimeout().

◆ UpdateRawBitrate()

void RingBuffer::UpdateRawBitrate ( uint  raw_bitrate)

Set the raw bit rate, to allow RingBuffer adjust effective bitrate.

Parameters
raw_bitrateStreams average number of kilobits per second when playspeed is 1.0

Definition at line 307 of file ringbuffer.cpp.

Referenced by NuppelDecoder::GetFrame(), MythPlayer::JumpToProgram(), MythPlayer::JumpToStream(), NuppelDecoder::OpenFile(), AvFormatDecoder::ScanStreams(), and MythPlayer::SwitchToProgram().

◆ UpdatePlaySpeed()

void RingBuffer::UpdatePlaySpeed ( float  play_speed)

Set the play speed, to allow RingBuffer adjust effective bitrate.

Parameters
play_speedSpeed to set. (1.0 for normal speed)

Definition at line 338 of file ringbuffer.cpp.

◆ EnableBitrateMonitor()

void RingBuffer::EnableBitrateMonitor ( bool  enable)
inline

Definition at line 70 of file libs/libmythtv/ringbuffer.h.

Referenced by TV::timerEvent(), and TV::ToggleOSDDebug().

◆ SetBufferSizeFactors()

void RingBuffer::SetBufferSizeFactors ( bool  estbitrate,
bool  matroska 
)

Tells RingBuffer that the raw bitrate may be innacurate and the underlying container is matroska, both of which may require a larger buffer size.

Definition at line 351 of file ringbuffer.cpp.

Referenced by AvFormatDecoder::ScanStreams().

◆ SetWaitForWrite()

void RingBuffer::SetWaitForWrite ( void  )
inline

Definition at line 72 of file libs/libmythtv/ringbuffer.h.

Referenced by RunCCExtract().

◆ GetSafeFilename()

QString RingBuffer::GetSafeFilename ( void  )
inline

Definition at line 75 of file libs/libmythtv/ringbuffer.h.

Referenced by MythPlayer::GetPlaybackData().

◆ GetFilename()

QString RingBuffer::GetFilename ( void  ) const

◆ GetSubtitleFilename()

QString RingBuffer::GetSubtitleFilename ( void  ) const

Definition at line 1863 of file ringbuffer.cpp.

Referenced by PlayerContext::CreatePlayer(), and MythPlayer::JumpToProgram().

◆ GetLastError()

QString RingBuffer::GetLastError ( void  ) const

◆ GetCommsError()

bool RingBuffer::GetCommsError ( void  ) const
inline

Definition at line 79 of file libs/libmythtv/ringbuffer.h.

Referenced by MythPlayer::EventLoop().

◆ ResetCommsError()

void RingBuffer::ResetCommsError ( void  )
inline

Definition at line 80 of file libs/libmythtv/ringbuffer.h.

Referenced by MythPlayer::EventLoop().

◆ GetStopReads()

bool RingBuffer::GetStopReads ( void  ) const
inline

Returns value of stopreads.

See also
StartReads(void), StopReads(void)

Definition at line 84 of file libs/libmythtv/ringbuffer.h.

Referenced by MythPlayer::OpenFile(), and FileTransfer::RequestBlock().

◆ isPaused()

bool RingBuffer::isPaused ( void  ) const

Returns false iff read-ahead is not running and read-ahead is not paused.

Definition at line 759 of file ringbuffer.cpp.

◆ GetReadPosition()

virtual long long RingBuffer::GetReadPosition ( void  ) const
pure virtual

◆ GetDecoderRate()

QString RingBuffer::GetDecoderRate ( void  )

Definition at line 1632 of file ringbuffer.cpp.

Referenced by MythPlayer::GetPlaybackData().

◆ GetStorageRate()

QString RingBuffer::GetStorageRate ( void  )

Definition at line 1637 of file ringbuffer.cpp.

Referenced by MythPlayer::GetPlaybackData().

◆ GetAvailableBuffer()

QString RingBuffer::GetAvailableBuffer ( void  )

Definition at line 1642 of file ringbuffer.cpp.

Referenced by MythPlayer::GetPlaybackData().

◆ GetBufferSize()

uint RingBuffer::GetBufferSize ( void  )
inline

Definition at line 91 of file libs/libmythtv/ringbuffer.h.

Referenced by MythPlayer::GetPlaybackData().

◆ GetWritePosition()

long long RingBuffer::GetWritePosition ( void  ) const

◆ GetRealFileSize()

long long RingBuffer::GetRealFileSize ( void  ) const

◆ IsNearEnd()

bool RingBuffer::IsNearEnd ( double  fps,
uint  vvf 
) const

Definition at line 437 of file ringbuffer.cpp.

Referenced by MythPlayer::IsReallyNearEnd().

◆ IsOpen()

virtual bool RingBuffer::IsOpen ( void  ) const
pure virtual

◆ IsStreamed()

virtual bool RingBuffer::IsStreamed ( void  )
inlinevirtual

◆ IsSeekingAllowed()

virtual bool RingBuffer::IsSeekingAllowed ( void  )
inlinevirtual

◆ IsBookmarkAllowed()

virtual bool RingBuffer::IsBookmarkAllowed ( void  )
inlinevirtual

◆ BestBufferSize()

virtual int RingBuffer::BestBufferSize ( void  )
inlinevirtual

Reimplemented in DVDRingBuffer.

Definition at line 102 of file libs/libmythtv/ringbuffer.h.

Referenced by AvFormatDecoder::InitByteContext().

◆ BitrateToString()

QString RingBuffer::BitrateToString ( uint64_t  rate,
bool  hz = false 
)
static

Definition at line 1599 of file ringbuffer.cpp.

Referenced by GetDecoderRate(), MythPlayer::GetPlaybackData(), and GetStorageRate().

◆ GetType()

RingBufferType RingBuffer::GetType ( void  ) const
inline

◆ GetReadBufAvail()

int RingBuffer::GetReadBufAvail ( void  ) const

Returns number of bytes available for reading from buffer.

Definition at line 490 of file ringbuffer.cpp.

Referenced by AvFormatDecoder::InitByteContext().

◆ SetReadInternalMode()

bool RingBuffer::SetReadInternalMode ( bool  mode)

Definition at line 558 of file ringbuffer.cpp.

Referenced by AVFRingBuffer::SetInInit().

◆ IsReadInternalMode()

bool RingBuffer::IsReadInternalMode ( void  )
inline

Definition at line 109 of file libs/libmythtv/ringbuffer.h.

◆ IsDisc()

bool RingBuffer::IsDisc ( void  ) const
inline

◆ IsDVD()

bool RingBuffer::IsDVD ( void  ) const
inline

Definition at line 113 of file libs/libmythtv/ringbuffer.h.

Referenced by MythDVDPlayer::CalcMaxFFTime(), MythDVDPlayer::ChangeSpeed(), TV::ChangeVolume(), MythDVDPlayer::DecoderGetFrameREW(), MythDVDPlayer::DisableCaptions(), MythDVDPlayer::DisplayDVDButton(), MythDVDPlayer::DisplayPauseFrame(), DecoderBase::DoFastForward(), AvFormatDecoderDVD::DoFastForwardSeek(), MythDVDPlayer::DoJumpChapter(), AvFormatDecoderDVD::DoRewindSeek(), AvFormatDecoderDVD::DVDFindPosition(), MythDVDPlayer::EnableCaptions(), AvFormatDecoderDVD::GetAudioLanguage(), MythDVDPlayer::GetBookmark(), MythDVDPlayer::GetChapterTimes(), MythDVDPlayer::GetCurrentChapter(), MythDVDPlayer::GetNumChapters(), MythDVDPlayer::GetSecondsPlayed(), AvFormatDecoder::GetTrackDesc(), MythDVDPlayer::GoToDVDProgram(), MythDVDPlayer::GoToMenu(), TV::HandleLCDTimerEvent(), TV::HandleStateChange(), AvFormatDecoder::InitVideoCodec(), IsDisc(), AvFormatDecoder::MpegPreProcessPkt(), AvFormatDecoder::OpenFile(), TV::OSDDialogEvent(), DecoderBase::PosMapFromDb(), AvFormatDecoderDVD::PostProcessTracks(), MythDVDPlayer::PrepareAudioSample(), TV::ProcessKeypressOrGesture(), TV::ProcessNetworkControlCommand(), AvFormatDecoder::ProcessSubtitlePacket(), AvFormatDecoder::ProcessVideoFrame(), AvFormatDecoder::ProcessVideoPacket(), ReadDirect(), AvFormatDecoder::ScanStreams(), MythDVDPlayer::SeekForScreenGrab(), AvFormatDecoder::SeekReset(), MythDVDPlayer::SetBookmark(), TV::ShowLCDDVDInfo(), TV::ShowOSDStopWatchingRecording(), MythDVDPlayer::StillFrameCheck(), AvFormatDecoderDVD::StreamChangeCheck(), DecoderBase::SyncPositionMap(), AvFormatDecoderDVD::UpdateFramesPlayed(), and MythDVDPlayer::VideoLoop().

◆ IsBD()

bool RingBuffer::IsBD ( void  ) const
inline

◆ DVD() [1/2]

const DVDRingBuffer * RingBuffer::DVD ( void  ) const

Definition at line 1921 of file ringbuffer.cpp.

Referenced by TV::ActiveHandleAction(), MythDVDPlayer::CalcMaxFFTime(), MythDVDPlayer::ChangeSpeed(), AvFormatDecoderDVD::CheckContext(), MythDVDPlayer::DecoderGetFrameREW(), MythDVDPlayer::DisableCaptions(), MythDVDPlayer::DisplayDVDButton(), MythDVDPlayer::DisplayPauseFrame(), DecoderBase::DoFastForward(), MythDVDPlayer::DoJumpChapter(), AvFormatDecoderDVD::DVDFindPosition(), MythDVDPlayer::EnableCaptions(), MythDVDPlayer::EventEnd(), MythDVDPlayer::EventStart(), AvFormatDecoderDVD::GetAudioLanguage(), AvFormatDecoderDVD::GetAudioTrackType(), MythDVDPlayer::GetBookmark(), MythDVDPlayer::GetChapterTimes(), MythDVDPlayer::GetCurrentAngle(), MythDVDPlayer::GetCurrentChapter(), MythDVDPlayer::GetNumAngles(), MythDVDPlayer::GetNumChapters(), MythDVDPlayer::GetSecondsPlayed(), MythDVDPlayer::GoToDVDProgram(), MythDVDPlayer::GoToMenu(), MythDVDPlayer::InitialSeek(), AvFormatDecoder::MpegPreProcessPkt(), DecoderBase::PosMapFromDb(), AvFormatDecoderDVD::PostProcessTracks(), MythDVDPlayer::PrepareAudioSample(), AvFormatDecoderDVD::ProcessDataPacket(), AvFormatDecoder::ProcessSubtitlePacket(), AvFormatDecoderDVD::ProcessVideoPacket(), AvFormatDecoderDVD::ReadPacket(), AvFormatDecoder::ScanStreams(), MythDVDPlayer::SeekForScreenGrab(), MythDVDPlayer::SetBookmark(), MythDVDPlayer::SetTrack(), TV::ShowLCDDVDInfo(), MythDVDPlayer::StillFrameCheck(), AvFormatDecoderDVD::StreamChangeCheck(), MythDVDPlayer::SwitchAngle(), DecoderBase::SyncPositionMap(), AvFormatDecoderDVD::UpdateFramesPlayed(), MythDVDPlayer::VideoLoop(), and MythDVDPlayer::VideoStart().

◆ BD() [1/2]

const BDRingBuffer * RingBuffer::BD ( void  ) const

◆ DVD() [2/2]

DVDRingBuffer * RingBuffer::DVD ( void  )

Definition at line 1931 of file ringbuffer.cpp.

◆ BD() [2/2]

BDRingBuffer * RingBuffer::BD ( void  )

Definition at line 1936 of file ringbuffer.cpp.

◆ StartFromBeginning()

virtual bool RingBuffer::StartFromBeginning ( void  )
inlinevirtual

Reimplemented in DVDRingBuffer, and BDRingBuffer.

Definition at line 119 of file libs/libmythtv/ringbuffer.h.

Referenced by AvFormatDecoder::OpenFile().

◆ IgnoreWaitStates()

virtual void RingBuffer::IgnoreWaitStates ( bool  )
inlinevirtual

◆ IsInMenu()

virtual bool RingBuffer::IsInMenu ( void  ) const
inlinevirtual

◆ IsInStillFrame()

virtual bool RingBuffer::IsInStillFrame ( void  ) const
inlinevirtual

◆ IsInDiscMenuOrStillFrame()

virtual bool RingBuffer::IsInDiscMenuOrStillFrame ( void  ) const
inlinevirtual

◆ HandleAction()

virtual bool RingBuffer::HandleAction ( const QStringList &  ,
int64_t   
)
inlinevirtual

Reimplemented in DVDRingBuffer, and BDRingBuffer.

Definition at line 124 of file libs/libmythtv/ringbuffer.h.

Referenced by TV::DiscMenuHandleAction().

◆ OpenFile()

virtual bool RingBuffer::OpenFile ( const QString &  lfilename,
uint  retry_ms = kDefaultOpenTimeout 
)
pure virtual

Opens a file for reading.

Parameters
lfilenameName of file to read
retry_msHow many ms to retry reading the file after the first try before giving up.

Implemented in DVDRingBuffer, BDRingBuffer, HLSRingBuffer, DVDStream, FileRingBuffer, StreamingRingBuffer, and ICRingBuffer.

Referenced by MythPlayer::JumpToProgram(), MythPlayer::JumpToStream(), and MythPlayer::SwitchToProgram().

◆ ReOpen()

virtual bool RingBuffer::ReOpen ( QString  = "")
inlinevirtual

Reimplemented in FileRingBuffer.

Definition at line 136 of file libs/libmythtv/ringbuffer.h.

Referenced by FileTransfer::ReOpen(), and AVFormatWriter::ReOpen().

◆ Read()

int RingBuffer::Read ( void *  buf,
int  count 
)

This is the public method for reading from a file, it calls the appropriate read method if the file is remote or buffered, or a BD/DVD.

Parameters
bufPointer to where data will be written
countNumber of bytes to read
Returns
Returns number of bytes read

Definition at line 1585 of file ringbuffer.cpp.

Referenced by CopyFile(), NuppelDecoder::GetFrame(), NuppelDecoder::OpenFile(), pid_counter(), pid_filter(), pid_printer(), NuppelDecoder::ReadFileheader(), NuppelDecoder::ReadFrameheader(), and FileTransfer::RequestBlock().

◆ Peek()

int RingBuffer::Peek ( void *  buf,
int  count 
)

Definition at line 1255 of file ringbuffer.cpp.

Referenced by MythPlayer::OpenFile().

◆ Reset()

void RingBuffer::Reset ( bool  full = false,
bool  toAdjust = false,
bool  resetInternal = false 
)

Resets the read-ahead thread and our position in the file.

Definition at line 265 of file ringbuffer.cpp.

Referenced by MythPlayer::FileChanged(), MythPlayer::JumpToProgram(), ICRingBuffer::OpenFile(), and MythPlayer::SwitchToProgram().

◆ Seek()

long long RingBuffer::Seek ( long long  pos,
int  whence,
bool  has_lock = false 
)

◆ Pause()

void RingBuffer::Pause ( void  )

◆ Unpause()

void RingBuffer::Unpause ( void  )

Unpauses the read-ahead thread.

Calls StartReads(void).

See also
Pause(void)

Definition at line 747 of file ringbuffer.cpp.

Referenced by TV::CreatePBP(), TV::RestartAllPlayers(), MythPlayer::SwitchToProgram(), ICRingBuffer::Take(), and MythPlayer::UnpauseBuffer().

◆ WaitForPause()

void RingBuffer::WaitForPause ( void  )

◆ Start()

void RingBuffer::Start ( void  )

Starts the read-ahead thread.

If the RingBuffer constructor was not called with a usereadahead of true of if this was reset to false because we're dealing with a DVD the read ahead thread will not be started.

If this RingBuffer is in write-mode a warning will be printed and the read ahead thread will not be started.

If the read ahead thread is already running a warning will be printed and the read ahead thread will not be started.

Definition at line 653 of file ringbuffer.cpp.

Referenced by FileTransfer::FileTransfer(), mythfile_open(), and MythPlayer::OpenFile().

◆ StopReads()

void RingBuffer::StopReads ( void  )

◆ StartReads()

void RingBuffer::StartReads ( void  )

◆ LiveMode()

bool RingBuffer::LiveMode ( void  ) const

Returns true if this RingBuffer has been assigned a LiveTVChain.

See also
SetLiveMode(LiveTVChain*)

Definition at line 1894 of file ringbuffer.cpp.

Referenced by NuppelDecoder::GetFrame(), NuppelVideoRecorder::Initialize(), IsStreamed(), and MythPlayer::OpenFile().

◆ SetLiveMode()

void RingBuffer::SetLiveMode ( LiveTVChain chain)

Assigns a LiveTVChain to this RingBuffer.

See also
LiveMode(void)

Definition at line 1906 of file ringbuffer.cpp.

Referenced by TV::HandleStateChange(), and TV::SwitchInputs().

◆ IgnoreLiveEOF()

void RingBuffer::IgnoreLiveEOF ( bool  ignore)

Tells RingBuffer whether to ignore the end-of-file.

Definition at line 1914 of file ringbuffer.cpp.

Referenced by MythPlayer::JumpToProgram(), TV::PauseLiveTV(), TV::SwitchInputs(), and TV::UnpauseLiveTV().

◆ Write()

int RingBuffer::Write ( const void *  buf,
uint  count 
)

◆ IsIOBound()

bool RingBuffer::IsIOBound ( void  ) const

◆ WriterFlush()

void RingBuffer::WriterFlush ( void  )

◆ Sync()

void RingBuffer::Sync ( void  )

Calls ThreadedFileWriter::Sync(void)

Definition at line 1764 of file ringbuffer.cpp.

◆ WriterSeek()

long long RingBuffer::WriterSeek ( long long  pos,
int  whence,
bool  has_lock = false 
)

◆ WriterSetBlocking()

bool RingBuffer::WriterSetBlocking ( bool  lock = true)

◆ SetAdjustFilesize()

long long RingBuffer::SetAdjustFilesize ( void  )

Definition at line 1244 of file ringbuffer.cpp.

Referenced by MythPlayer::SwitchToProgram().

◆ AVFormatInitNetwork()

void RingBuffer::AVFormatInitNetwork ( void  )
static

◆ run()

void RingBuffer::run ( void  )
overrideprotectedvirtual

Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.

Note
If you override this method you must call RunProlog before you do any work and RunEpilog before you exit the run method.

Reimplemented from MThread.

Definition at line 880 of file ringbuffer.cpp.

◆ CreateReadAheadBuffer()

void RingBuffer::CreateReadAheadBuffer ( void  )
protected

Definition at line 832 of file ringbuffer.cpp.

Referenced by run(), and SetBufferSizeFactors().

◆ CalcReadAheadThresh()

void RingBuffer::CalcReadAheadThresh ( void  )
protected

Calculates m_fillMin, m_fillThreshold, and m_readBlockSize from the estimated effective bitrate of the stream.

WARNING: Must be called with rwlock in write lock state.

Definition at line 367 of file ringbuffer.cpp.

Referenced by CreateReadAheadBuffer(), ICRingBuffer::OpenFile(), FileRingBuffer::OpenFile(), BDRingBuffer::OpenFile(), DVDRingBuffer::OpenFile(), ResetReadAhead(), run(), UpdatePlaySpeed(), and UpdateRawBitrate().

◆ PauseAndWait()

bool RingBuffer::PauseAndWait ( void  )
protected

Definition at line 789 of file ringbuffer.cpp.

Referenced by run().

◆ safe_read()

virtual int RingBuffer::safe_read ( void *  data,
uint  sz 
)
protectedpure virtual

◆ ReadPriv()

int RingBuffer::ReadPriv ( void *  buf,
int  count,
bool  peek 
)
protected

When possible reads from the read-ahead buffer, otherwise reads directly from the device.

Parameters
bufPointer to where data will be written
countNumber of bytes to read
peekIf true, don't increment read count
Returns
Returns number of bytes read

Definition at line 1418 of file ringbuffer.cpp.

Referenced by Peek(), and Read().

◆ ReadDirect()

int RingBuffer::ReadDirect ( void *  buf,
int  count,
bool  peek 
)
protected

Definition at line 1340 of file ringbuffer.cpp.

Referenced by ReadPriv().

◆ WaitForReadsAllowed()

bool RingBuffer::WaitForReadsAllowed ( void  )
protected

Definition at line 1267 of file ringbuffer.cpp.

Referenced by ReadPriv().

◆ WaitForAvail()

int RingBuffer::WaitForAvail ( int  count,
int  timeout 
)
protected

Definition at line 1298 of file ringbuffer.cpp.

Referenced by ReadPriv().

◆ GetRealFileSizeInternal()

virtual long long RingBuffer::GetRealFileSizeInternal ( void  ) const
inlineprotectedvirtual

Reimplemented in HLSRingBuffer, FileRingBuffer, StreamingRingBuffer, and ICRingBuffer.

Definition at line 191 of file libs/libmythtv/ringbuffer.h.

Referenced by GetRealFileSize().

◆ SeekInternal()

virtual long long RingBuffer::SeekInternal ( long long  pos,
int  whence 
)
protectedpure virtual

◆ ReadBufFree()

int RingBuffer::ReadBufFree ( void  ) const
protected

Returns number of bytes available for reading into buffer.

WARNING: Must be called with rwlock in locked state.

Definition at line 479 of file ringbuffer.cpp.

Referenced by run().

◆ ReadBufAvail()

int RingBuffer::ReadBufAvail ( void  ) const
protected

Returns number of bytes available for reading from buffer.

WARNING: Must be called with rwlock in locked state.

Definition at line 589 of file ringbuffer.cpp.

Referenced by GetReadBufAvail(), GetRealFileSize(), ReadPriv(), Seek(), and WaitForAvail().

◆ ResetReadAhead()

void RingBuffer::ResetReadAhead ( long long  newinternal)
protected

Restart the read-ahead thread at the 'newinternal' position.

This is called after a Seek(long long, int) so that the read-ahead buffer doesn't contain any stale data, and so that it will read any new data from the new position in the file.

WARNING: Must be called with rwlock and poslock in write lock state.

Parameters
newinternalPosition in file to start reading data from

Definition at line 610 of file ringbuffer.cpp.

Referenced by Reset(), run(), ICRingBuffer::SeekInternal(), FileRingBuffer::SeekInternal(), BDRingBuffer::SeekInternal(), and DVDRingBuffer::SeekInternal().

◆ KillReadAheadThread()

void RingBuffer::KillReadAheadThread ( void  )
protected

◆ UpdateDecoderRate()

uint64_t RingBuffer::UpdateDecoderRate ( uint64_t  latest = 0)
protected

Definition at line 1652 of file ringbuffer.cpp.

Referenced by GetDecoderRate(), and Read().

◆ UpdateStorageRate()

uint64_t RingBuffer::UpdateStorageRate ( uint64_t  latest = 0)
protected

Definition at line 1686 of file ringbuffer.cpp.

Referenced by GetStorageRate(), ReadDirect(), and run().

Friends And Related Function Documentation

◆ ICRingBuffer

friend class ICRingBuffer
friend

Definition at line 55 of file libs/libmythtv/ringbuffer.h.

Member Data Documentation

◆ kDefaultOpenTimeout

const int RingBuffer::kDefaultOpenTimeout = 2000
static

Definition at line 173 of file libs/libmythtv/ringbuffer.h.

Referenced by mythfile_open().

◆ kLiveTVOpenTimeout

const int RingBuffer::kLiveTVOpenTimeout = 10000
static

◆ m_type

RingBufferType RingBuffer::m_type
protected

Definition at line 204 of file libs/libmythtv/ringbuffer.h.

Referenced by GetAvailableBuffer(), GetType(), IsBD(), and IsDVD().

◆ m_posLock

QReadWriteLock RingBuffer::m_posLock
mutableprotected

◆ m_readPos

long long RingBuffer::m_readPos {0}
protected

◆ m_writePos

long long RingBuffer::m_writePos {0}
protected

◆ m_internalReadPos

long long RingBuffer::m_internalReadPos {0}
protected

◆ m_ignoreReadPos

long long RingBuffer::m_ignoreReadPos {-1}
protected

◆ m_rbrLock

QReadWriteLock RingBuffer::m_rbrLock
mutableprotected

◆ m_rbrPos

int RingBuffer::m_rbrPos {0}
protected

◆ m_rbwLock

QReadWriteLock RingBuffer::m_rbwLock
mutableprotected

◆ m_rbwPos

int RingBuffer::m_rbwPos {0}
protected

◆ m_stopReads

volatile bool RingBuffer::m_stopReads {false}
protected

◆ m_safeFilename

QString RingBuffer::m_safeFilename
protected

◆ m_rwLock

QReadWriteLock RingBuffer::m_rwLock
mutableprotected

◆ m_filename

QString RingBuffer::m_filename
protected

◆ m_subtitleFilename

QString RingBuffer::m_subtitleFilename
protected

Definition at line 241 of file libs/libmythtv/ringbuffer.h.

Referenced by GetSubtitleFilename(), and FileRingBuffer::OpenFile().

◆ m_lastError

QString RingBuffer::m_lastError
protected

◆ m_tfw

ThreadedFileWriter* RingBuffer::m_tfw {nullptr}
protected

◆ m_fd2

int RingBuffer::m_fd2 {-1}
protected

◆ m_writeMode

bool RingBuffer::m_writeMode {false}
protected

◆ m_remotefile

RemoteFile* RingBuffer::m_remotefile {nullptr}
protected

◆ m_bufferSize

uint RingBuffer::m_bufferSize {BUFFER_SIZE_MINIMUM}
protected

◆ m_lowBuffers

bool RingBuffer::m_lowBuffers {false}
protected

Definition at line 252 of file libs/libmythtv/ringbuffer.h.

Referenced by CalcReadAheadThresh(), and WaitForAvail().

◆ m_fileIsMatroska

bool RingBuffer::m_fileIsMatroska {false}
protected

Definition at line 253 of file libs/libmythtv/ringbuffer.h.

Referenced by CreateReadAheadBuffer(), and SetBufferSizeFactors().

◆ m_unknownBitrate

bool RingBuffer::m_unknownBitrate {false}
protected

Definition at line 254 of file libs/libmythtv/ringbuffer.h.

Referenced by CreateReadAheadBuffer(), and SetBufferSizeFactors().

◆ m_startReadAhead

bool RingBuffer::m_startReadAhead {false}
protected

◆ m_readAheadBuffer

char* RingBuffer::m_readAheadBuffer {nullptr}
protected

Definition at line 256 of file libs/libmythtv/ringbuffer.h.

Referenced by CreateReadAheadBuffer(), ReadPriv(), run(), and ~RingBuffer().

◆ m_readAheadRunning

bool RingBuffer::m_readAheadRunning {false}
protected

◆ m_reallyRunning

bool RingBuffer::m_reallyRunning {false}
protected

Definition at line 258 of file libs/libmythtv/ringbuffer.h.

Referenced by run(), and Start().

◆ m_requestPause

bool RingBuffer::m_requestPause {false}
protected

◆ m_paused

bool RingBuffer::m_paused {false}
protected

Definition at line 260 of file libs/libmythtv/ringbuffer.h.

Referenced by IsNearEnd(), isPaused(), PauseAndWait(), and WaitForPause().

◆ m_ateof

bool RingBuffer::m_ateof {false}
protected

◆ m_waitForWrite

bool RingBuffer::m_waitForWrite {false}
protected

Definition at line 262 of file libs/libmythtv/ringbuffer.h.

Referenced by run(), and SetWaitForWrite().

◆ m_beingWritten

bool RingBuffer::m_beingWritten {false}
protected

Definition at line 263 of file libs/libmythtv/ringbuffer.h.

Referenced by run().

◆ m_readsAllowed

bool RingBuffer::m_readsAllowed {false}
protected

◆ m_readsDesired

bool RingBuffer::m_readsDesired {false}
protected

◆ m_recentSeek

volatile bool RingBuffer::m_recentSeek {true}
protected

◆ m_setSwitchToNext

bool RingBuffer::m_setSwitchToNext {false}
protected

◆ m_rawBitrate

uint RingBuffer::m_rawBitrate {8000}
protected

◆ m_playSpeed

float RingBuffer::m_playSpeed {1.0F}
protected

Definition at line 269 of file libs/libmythtv/ringbuffer.h.

Referenced by CalcReadAheadThresh(), IsNearEnd(), and UpdatePlaySpeed().

◆ m_fillThreshold

int RingBuffer::m_fillThreshold {65536}
protected

Definition at line 270 of file libs/libmythtv/ringbuffer.h.

Referenced by CalcReadAheadThresh(), and run().

◆ m_fillMin

int RingBuffer::m_fillMin {-1}
protected

◆ m_readBlockSize

int RingBuffer::m_readBlockSize {CHUNK}
protected

◆ m_wantToRead

int RingBuffer::m_wantToRead {0}
protected

Definition at line 273 of file libs/libmythtv/ringbuffer.h.

Referenced by ReadPriv(), and WaitForAvail().

◆ m_numFailures

int RingBuffer::m_numFailures {0}
protected

◆ m_commsError

bool RingBuffer::m_commsError {false}
protected

◆ m_oldfile

bool RingBuffer::m_oldfile {false}
protected

◆ m_liveTVChain

LiveTVChain* RingBuffer::m_liveTVChain {nullptr}
protected

◆ m_ignoreLiveEOF

bool RingBuffer::m_ignoreLiveEOF {false}
protected

Definition at line 280 of file libs/libmythtv/ringbuffer.h.

Referenced by IgnoreLiveEOF(), and run().

◆ m_readAdjust

long long RingBuffer::m_readAdjust {0}
protected

◆ m_readOffset

int RingBuffer::m_readOffset {0}
protected

Definition at line 285 of file libs/libmythtv/ringbuffer.h.

Referenced by ReadPriv(), ResetReadAhead(), Seek(), and SetReadInternalMode().

◆ m_readInternalMode

bool RingBuffer::m_readInternalMode {false}
protected

◆ m_bitrateMonitorEnabled

bool RingBuffer::m_bitrateMonitorEnabled {false}
protected

◆ m_decoderReadLock

QMutex RingBuffer::m_decoderReadLock
protected

Definition at line 293 of file libs/libmythtv/ringbuffer.h.

Referenced by UpdateDecoderRate().

◆ m_decoderReads

QMap<qint64, uint64_t> RingBuffer::m_decoderReads
protected

Definition at line 294 of file libs/libmythtv/ringbuffer.h.

Referenced by UpdateDecoderRate().

◆ m_storageReadLock

QMutex RingBuffer::m_storageReadLock
protected

Definition at line 295 of file libs/libmythtv/ringbuffer.h.

Referenced by UpdateStorageRate().

◆ m_storageReads

QMap<qint64, uint64_t> RingBuffer::m_storageReads
protected

Definition at line 296 of file libs/libmythtv/ringbuffer.h.

Referenced by UpdateStorageRate().

◆ m_generalWait

QWaitCondition RingBuffer::m_generalWait
protected

◆ s_subExtLock

QMutex RingBuffer::s_subExtLock
static

◆ s_subExt

QStringList RingBuffer::s_subExt
static

◆ s_subExtNoCheck

QStringList RingBuffer::s_subExtNoCheck
static

Definition at line 310 of file libs/libmythtv/ringbuffer.h.

Referenced by is_subtitle_possible(), and RingBuffer().

◆ gAVformat_net_initialised

bool RingBuffer::gAVformat_net_initialised = false
staticprivate

Definition at line 313 of file libs/libmythtv/ringbuffer.h.

Referenced by AVFormatInitNetwork().

◆ m_bitrateInitialized

bool RingBuffer::m_bitrateInitialized {false}
private

Definition at line 314 of file libs/libmythtv/ringbuffer.h.

Referenced by CalcReadAheadThresh(), and UpdateRawBitrate().


The documentation for this class was generated from the following files: