MythTV  0.28pre
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 Classes inheriting from RingBuffer must implement a destructor that calls KillReadAheadThread(). 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 rawbitrate)
 Set the raw bit rate, to allow RingBuffer adjust effective bitrate. More...
 
void UpdatePlaySpeed (float playspeed)
 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 ignore)
 
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 newFilename="")
 
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)
 
void SetTimeout (bool is_old) MDEPRECATED
 

Static Public Member Functions

static RingBufferCreate (const QString &lfilename, 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 subExtLock
 
static QStringList subExt
 
static QStringList subExtNoCheck
 

Protected Member Functions

 RingBuffer (RingBufferType rbtype)
 
void run (void)
 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 fill_min, fill_threshold, and 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 type
 
QReadWriteLock poslock
 
long long readpos
 
long long writepos
 
long long internalreadpos
 
long long ignorereadpos
 
QReadWriteLock rbrlock
 
int rbrpos
 
QReadWriteLock rbwlock
 
int rbwpos
 
volatile bool stopreads
 
QReadWriteLock rwlock
 
QString safefilename
 
QString filename
 
QString subtitlefilename
 
QString lastError
 
ThreadedFileWritertfw
 
int fd2
 
bool writemode
 
RemoteFileremotefile
 
uint bufferSize
 
bool low_buffers
 
bool fileismatroska
 
bool unknownbitrate
 
bool startreadahead
 
char * readAheadBuffer
 
bool readaheadrunning
 
bool reallyrunning
 
bool request_pause
 
bool paused
 
bool ateof
 
bool waitforwrite
 
bool beingwritten
 
bool readsallowed
 
bool readsdesired
 
volatile bool recentseek
 
bool setswitchtonext
 
uint rawbitrate
 
float playspeed
 
int fill_threshold
 
int fill_min
 
int readblocksize
 
int wanttoread
 
int numfailures
 
bool commserror
 
bool oldfile
 
LiveTVChainlivetvchain
 
bool ignoreliveeof
 
long long readAdjust
 
int readOffset
 
bool readInternalMode
 
bool bitrateMonitorEnabled
 
QMutex decoderReadLock
 
QMap< qint64, uint64_t > decoderReads
 
QMutex storageReadLock
 
QMap< qint64, uint64_t > storageReads
 
QWaitCondition generalWait
 Condition to signal that the read ahead thread is running. More...
 
- Protected Attributes inherited from MThread
MThreadInternalm_thread
 
QRunnable * m_runnable
 
bool m_prolog_executed
 
bool m_epilog_executed
 

Private Attributes

bool bitrateInitialized
 

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 45 of file libs/libmythtv/ringbuffer.h.

Constructor & Destructor Documentation

§ ~RingBuffer()

RingBuffer::~RingBuffer ( void  )
pure virtual

Deletes 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 279 of file ringbuffer.cpp.

§ RingBuffer()

RingBuffer::RingBuffer ( RingBufferType  rbtype)
protected

Definition at line 218 of file ringbuffer.cpp.

Referenced by Len2Blocks().

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
lfilenameName of file to read or write.
writeIf true an encapsulated writer is created
readaheadIf 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 110 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 1841 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 1876 of file ringbuffer.cpp.

Referenced by FileTransfer::FileTransfer(), FileTransfer::SetTimeout(), and SetTimeout().

§ UpdateRawBitrate()

void RingBuffer::UpdateRawBitrate ( uint  rawbitrate)

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 340 of file ringbuffer.cpp.

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

§ UpdatePlaySpeed()

void RingBuffer::UpdatePlaySpeed ( float  playspeed)

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

Parameters
play_speedSpeed to set. (1.0 for normal speed)

Definition at line 371 of file ringbuffer.cpp.

§ EnableBitrateMonitor()

void RingBuffer::EnableBitrateMonitor ( bool  enable)
inline

Definition at line 62 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 384 of file ringbuffer.cpp.

Referenced by EnableBitrateMonitor(), and AvFormatDecoder::ScanStreams().

§ SetWaitForWrite()

void RingBuffer::SetWaitForWrite ( void  )
inline

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

Referenced by RunCCExtract().

§ GetSafeFilename()

QString RingBuffer::GetSafeFilename ( void  )
inline

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

Referenced by MythPlayer::GetPlaybackData().

§ GetFilename()

QString RingBuffer::GetFilename ( void  ) const

§ GetSubtitleFilename()

QString RingBuffer::GetSubtitleFilename ( void  ) const

§ GetLastError()

QString RingBuffer::GetLastError ( void  ) const

§ GetCommsError()

bool RingBuffer::GetCommsError ( void  ) const
inline

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

Referenced by MythPlayer::EventLoop().

§ ResetCommsError()

void RingBuffer::ResetCommsError ( void  )
inline

Definition at line 72 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 76 of file libs/libmythtv/ringbuffer.h.

Referenced by FileTransfer::FileTransfer(), 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 792 of file ringbuffer.cpp.

Referenced by GetStopReads().

§ GetReadPosition()

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

§ GetDecoderRate()

QString RingBuffer::GetDecoderRate ( void  )

Definition at line 1663 of file ringbuffer.cpp.

Referenced by MythPlayer::GetPlaybackData(), and GetStopReads().

§ GetStorageRate()

QString RingBuffer::GetStorageRate ( void  )

Definition at line 1668 of file ringbuffer.cpp.

Referenced by MythPlayer::GetPlaybackData(), and GetStopReads().

§ GetAvailableBuffer()

QString RingBuffer::GetAvailableBuffer ( void  )

Definition at line 1673 of file ringbuffer.cpp.

Referenced by MythPlayer::GetPlaybackData(), and GetStopReads().

§ GetBufferSize()

uint RingBuffer::GetBufferSize ( void  )
inline

Definition at line 83 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 470 of file ringbuffer.cpp.

Referenced by GetBufferSize(), and 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 94 of file libs/libmythtv/ringbuffer.h.

Referenced by AvFormatDecoder::InitByteContext().

§ BitrateToString()

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

§ 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 523 of file ringbuffer.cpp.

Referenced by GetType().

§ SetReadInternalMode()

bool RingBuffer::SetReadInternalMode ( bool  mode)

Definition at line 591 of file ringbuffer.cpp.

Referenced by GetType(), and AVFRingBuffer::SetInInit().

§ IsReadInternalMode()

bool RingBuffer::IsReadInternalMode ( void  )
inline

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

§ IsDisc()

bool RingBuffer::IsDisc ( void  ) const
inline

§ IsDVD()

bool RingBuffer::IsDVD ( void  ) const
inline

§ IsBD()

bool RingBuffer::IsBD ( void  ) const
inline

§ DVD() [1/2]

const DVDRingBuffer * RingBuffer::DVD ( void  ) const

§ BD() [1/2]

const BDRingBuffer * RingBuffer::BD ( void  ) const

§ DVD() [2/2]

DVDRingBuffer * RingBuffer::DVD ( void  )

Definition at line 1961 of file ringbuffer.cpp.

§ BD() [2/2]

BDRingBuffer * RingBuffer::BD ( void  )

Definition at line 1966 of file ringbuffer.cpp.

§ StartFromBeginning()

virtual bool RingBuffer::StartFromBeginning ( void  )
inlinevirtual

Reimplemented in DVDRingBuffer, and BDRingBuffer.

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

Referenced by AvFormatDecoder::OpenFile(), and DVDRingBuffer::PlayTitleAndPart().

§ IgnoreWaitStates()

virtual void RingBuffer::IgnoreWaitStates ( bool  ignore)
inlinevirtual

Reimplemented in DVDRingBuffer, and BDRingBuffer.

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

Referenced by AvFormatDecoder::OpenFile(), and TV::StopStuff().

§ IsInMenu()

virtual bool RingBuffer::IsInMenu ( void  ) const
inlinevirtual

Reimplemented in DVDRingBuffer, and BDRingBuffer.

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

Referenced by IsInDiscMenuOrStillFrame(), and MythBDPlayer::SetBookmark().

§ 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 116 of file libs/libmythtv/ringbuffer.h.

Referenced by TV::DiscMenuHandleAction(), and DVDRingBuffer::IsInMenu().

§ 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, ICRingBuffer, and StreamingRingBuffer.

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

§ ReOpen()

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

§ 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 1616 of file ringbuffer.cpp.

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

§ Peek()

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

Definition at line 1286 of file ringbuffer.cpp.

Referenced by MythPlayer::OpenFile(), and ReOpen().

§ 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 298 of file ringbuffer.cpp.

Referenced by MythPlayer::FileChangedCallback(), MythPlayer::JumpToProgram(), ICRingBuffer::OpenFile(), ReOpen(), 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  )

§ 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 686 of file ringbuffer.cpp.

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

§ 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 1924 of file ringbuffer.cpp.

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

§ SetLiveMode()

void RingBuffer::SetLiveMode ( LiveTVChain chain)

Assigns a LiveTVChain to this RingBuffer.

See also
LiveMode(void)

Definition at line 1936 of file ringbuffer.cpp.

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

§ IgnoreLiveEOF()

void RingBuffer::IgnoreLiveEOF ( bool  ignore)

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

Definition at line 1944 of file ringbuffer.cpp.

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

§ Write()

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

§ IsIOBound()

bool RingBuffer::IsIOBound ( void  ) const

Referenced by ReOpen().

§ WriterFlush()

void RingBuffer::WriterFlush ( void  )

§ Sync()

void RingBuffer::Sync ( void  )

Calls ThreadedFileWriter::Sync(void)

Definition at line 1794 of file ringbuffer.cpp.

Referenced by ReOpen().

§ 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 1275 of file ringbuffer.cpp.

Referenced by ReOpen(), and MythPlayer::SwitchToProgram().

§ SetTimeout()

void RingBuffer::SetTimeout ( bool  is_old)
inline
Deprecated:
Calls SetOldFile(), do not use

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

§ AVFormatInitNetwork()

void RingBuffer::AVFormatInitNetwork ( void  )
static

§ run()

void RingBuffer::run ( void  )
protectedvirtual

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 913 of file ringbuffer.cpp.

§ CreateReadAheadBuffer()

void RingBuffer::CreateReadAheadBuffer ( void  )
protected

Definition at line 865 of file ringbuffer.cpp.

Referenced by run(), and SetBufferSizeFactors().

§ CalcReadAheadThresh()

void RingBuffer::CalcReadAheadThresh ( void  )
protected

Calculates fill_min, fill_threshold, and readblocksize from the estimated effective bitrate of the stream.

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

Definition at line 400 of file ringbuffer.cpp.

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

§ PauseAndWait()

bool RingBuffer::PauseAndWait ( void  )
protected

Definition at line 822 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 1449 of file ringbuffer.cpp.

Referenced by Peek(), and Read().

§ ReadDirect()

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

Definition at line 1371 of file ringbuffer.cpp.

Referenced by ReadPriv().

§ WaitForReadsAllowed()

bool RingBuffer::WaitForReadsAllowed ( void  )
protected

Definition at line 1298 of file ringbuffer.cpp.

Referenced by ReadPriv().

§ WaitForAvail()

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

Definition at line 1329 of file ringbuffer.cpp.

Referenced by ReadPriv().

§ GetRealFileSizeInternal()

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

§ 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 512 of file ringbuffer.cpp.

Referenced by GetRealFileSizeInternal(), and 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 622 of file ringbuffer.cpp.

Referenced by GetReadBufAvail(), GetRealFileSize(), GetRealFileSizeInternal(), 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 643 of file ringbuffer.cpp.

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

§ KillReadAheadThread()

void RingBuffer::KillReadAheadThread ( void  )
protected

§ UpdateDecoderRate()

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

Definition at line 1682 of file ringbuffer.cpp.

Referenced by GetDecoderRate(), GetRealFileSizeInternal(), and Read().

§ UpdateStorageRate()

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

Definition at line 1716 of file ringbuffer.cpp.

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

Friends And Related Function Documentation

§ ICRingBuffer

friend class ICRingBuffer
friend

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

Member Data Documentation

§ kDefaultOpenTimeout

const int RingBuffer::kDefaultOpenTimeout = 2000
static

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

Referenced by HandleAction(), and mythfile_open().

§ kLiveTVOpenTimeout

const int RingBuffer::kLiveTVOpenTimeout = 10000
static

§ type

RingBufferType RingBuffer::type
protected

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

Referenced by GetAvailableBuffer().

§ poslock

QReadWriteLock RingBuffer::poslock
mutableprotected

§ readpos

long long RingBuffer::readpos
protected

§ writepos

long long RingBuffer::writepos
protected

§ internalreadpos

long long RingBuffer::internalreadpos
protected

§ ignorereadpos

long long RingBuffer::ignorereadpos
protected

§ rbrlock

QReadWriteLock RingBuffer::rbrlock
mutableprotected

§ rbrpos

int RingBuffer::rbrpos
protected

§ rbwlock

QReadWriteLock RingBuffer::rbwlock
mutableprotected

§ rbwpos

int RingBuffer::rbwpos
protected

§ stopreads

volatile bool RingBuffer::stopreads
protected

§ rwlock

QReadWriteLock RingBuffer::rwlock
mutableprotected

§ safefilename

QString RingBuffer::safefilename
protected

§ filename

QString RingBuffer::filename
protected

§ subtitlefilename

QString RingBuffer::subtitlefilename
protected

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

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

§ lastError

QString RingBuffer::lastError
protected

§ tfw

ThreadedFileWriter* RingBuffer::tfw
protected

§ fd2

int RingBuffer::fd2
protected

§ writemode

bool RingBuffer::writemode
protected

§ remotefile

RemoteFile* RingBuffer::remotefile
protected

§ bufferSize

uint RingBuffer::bufferSize
protected

§ low_buffers

bool RingBuffer::low_buffers
protected

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

Referenced by CalcReadAheadThresh(), and WaitForAvail().

§ fileismatroska

bool RingBuffer::fileismatroska
protected

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

Referenced by CreateReadAheadBuffer(), and SetBufferSizeFactors().

§ unknownbitrate

bool RingBuffer::unknownbitrate
protected

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

Referenced by CreateReadAheadBuffer(), and SetBufferSizeFactors().

§ startreadahead

bool RingBuffer::startreadahead
protected

§ readAheadBuffer

char* RingBuffer::readAheadBuffer
protected

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

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

§ readaheadrunning

bool RingBuffer::readaheadrunning
protected

§ reallyrunning

bool RingBuffer::reallyrunning
protected

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

Referenced by run(), and Start().

§ request_pause

bool RingBuffer::request_pause
protected

§ paused

bool RingBuffer::paused
protected

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

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

§ ateof

bool RingBuffer::ateof
protected

§ waitforwrite

bool RingBuffer::waitforwrite
protected

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

Referenced by run(), and SetWaitForWrite().

§ beingwritten

bool RingBuffer::beingwritten
protected

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

Referenced by run().

§ readsallowed

bool RingBuffer::readsallowed
protected

§ readsdesired

bool RingBuffer::readsdesired
protected

§ recentseek

volatile bool RingBuffer::recentseek
protected

§ setswitchtonext

bool RingBuffer::setswitchtonext
protected

§ rawbitrate

uint RingBuffer::rawbitrate
protected

§ playspeed

float RingBuffer::playspeed
protected

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

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

§ fill_threshold

int RingBuffer::fill_threshold
protected

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

Referenced by CalcReadAheadThresh(), and run().

§ fill_min

int RingBuffer::fill_min
protected

§ readblocksize

int RingBuffer::readblocksize
protected

§ wanttoread

int RingBuffer::wanttoread
protected

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

Referenced by ReadPriv(), and WaitForAvail().

§ numfailures

int RingBuffer::numfailures
protected

§ commserror

bool RingBuffer::commserror
protected

§ oldfile

bool RingBuffer::oldfile
protected

§ livetvchain

LiveTVChain* RingBuffer::livetvchain
protected

§ ignoreliveeof

bool RingBuffer::ignoreliveeof
protected

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

Referenced by IgnoreLiveEOF(), and run().

§ readAdjust

long long RingBuffer::readAdjust
protected

§ readOffset

int RingBuffer::readOffset
protected

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

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

§ readInternalMode

bool RingBuffer::readInternalMode
protected

§ bitrateMonitorEnabled

bool RingBuffer::bitrateMonitorEnabled
protected

§ decoderReadLock

QMutex RingBuffer::decoderReadLock
protected

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

Referenced by UpdateDecoderRate().

§ decoderReads

QMap<qint64, uint64_t> RingBuffer::decoderReads
protected

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

Referenced by UpdateDecoderRate().

§ storageReadLock

QMutex RingBuffer::storageReadLock
protected

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

Referenced by UpdateStorageRate().

§ storageReads

QMap<qint64, uint64_t> RingBuffer::storageReads
protected

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

Referenced by UpdateStorageRate().

§ generalWait

QWaitCondition RingBuffer::generalWait
protected

§ subExtLock

QMutex RingBuffer::subExtLock
static

§ subExt

QStringList RingBuffer::subExt
static

§ subExtNoCheck

QStringList RingBuffer::subExtNoCheck
static

Definition at line 284 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 287 of file libs/libmythtv/ringbuffer.h.

Referenced by AVFormatInitNetwork().

§ bitrateInitialized

bool RingBuffer::bitrateInitialized
private

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

Referenced by CalcReadAheadThresh(), and UpdateRawBitrate().


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