MythTV  0.27pre
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Private Attributes | Friends | List of all members
RingBuffer Class Reference

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().
void SetWriteBufferSize (int newSize)
void SetWriteBufferMinWriteSize (int newMinSize)
 Calls ThreadedFileWriter::SetWriteBufferMinWriteSize(int)
void SetOldFile (bool is_old)
 Tell RingBuffer if this is an old file or not.
void UpdateRawBitrate (uint rawbitrate)
 Set the raw bit rate, to allow RingBuffer adjust effective bitrate.
void UpdatePlaySpeed (float playspeed)
 Set the play speed, to allow RingBuffer adjust effective bitrate.
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.
QString GetSafeFilename (void)
QString GetFilename (void) const
 Returns name of file used by this RingBuffer.
QString GetSubtitleFilename (void) const
bool GetStopReads (void) const
 Returns value of stopreads.
bool isPaused (void) const
 Returns false iff read-ahead is not running and read-ahead is not paused.
virtual long long GetReadPosition (void) const =0
 Returns how far into the file we have read.
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.
virtual long long GetRealFileSize (void) const
 Returns the size of the file we are reading/writing, or -1 if the query fails.
bool IsNearEnd (double fps, uint vvf) const
virtual bool IsOpen (void) const =0
 Returns true if open for either reading or writing.
virtual bool IsStreamed (void)
virtual bool IsSeekingAllowed (void)
virtual bool IsBookmarkAllowed (void)
virtual int BestBufferSize (void)
RingBufferType GetType () const
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.
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.
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.
virtual long long Seek (long long pos, int whence, bool has_lock=false)=0
 Seeks to a particular position in the file.
void Pause (void)
 Pauses the read-ahead thread.
void Unpause (void)
 Unpauses the read-ahead thread.
void WaitForPause (void)
 Waits for Pause(void) to take effect.
void Start (void)
 Starts the read-ahead thread.
void StopReads (void)
 ????
void StartReads (void)
 ????
bool LiveMode (void) const
 Returns true if this RingBuffer has been assigned a LiveTVChain.
void SetLiveMode (LiveTVChain *chain)
 Assigns a LiveTVChain to this RingBuffer.
void IgnoreLiveEOF (bool ignore)
 Tells RingBuffer whether to igonre the end-of-file.
int Write (const void *buf, uint count)
 Writes buffer to ThreadedFileWriter::Write(const void*,uint)
bool IsIOBound (void) const
void WriterFlush (void)
 Calls ThreadedFileWriter::Flush(void)
void Sync (void)
 Calls ThreadedFileWriter::Sync(void)
long long WriterSeek (long long pos, int whence, bool has_lock=false)
 Calls ThreadedFileWriter::Seek(long long,int).
long long SetAdjustFilesize (void)
void SetTimeout (bool is_old) MDEPRECATED
 Calls SetOldFile(), do not use.

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.
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.
void CreateReadAheadBuffer (void)
void CalcReadAheadThresh (void)
 Calculates fill_min, fill_threshold, and readblocksize from the estimated effective bitrate of the stream.
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.
int ReadDirect (void *buf, int count, bool peek)
bool WaitForReadsAllowed (void)
bool WaitForAvail (int count)
int ReadBufFree (void) const
 Returns number of bytes available for reading into buffer.
int ReadBufAvail (void) const
 Returns number of bytes available for reading from buffer.
void ResetReadAhead (long long newinternal)
 Restart the read-ahead thread at the 'newinternal' position.
void KillReadAheadThread (void)
 Stops the read-ahead thread, and waits for it to stop.
uint64_t UpdateDecoderRate (uint64_t latest=0)
uint64_t UpdateStorageRate (uint64_t latest=0)
- Protected Member Functions inherited from MThread
 MThread (const QString &objectName)
 Standard constructor.
 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.
virtual ~MThread ()
void RunProlog (void)
 Sets up a thread, call this if you reimplement run().
void RunEpilog (void)
 Cleans up a thread's resources, call this if you reimplement run().
QThread * qthread (void)
 Returns the thread, this will always return the same pointer no matter how often you restart the thread.
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.
void start (QThread::Priority=QThread::InheritPriority)
 Tell MThread to start running the thread in the near future.
void terminate (void)
 Kill a thread unsafely.
void quit (void)
 calls exit(0)
bool wait (unsigned long time=ULONG_MAX)
 Wait for the MThread to exit, with a maximum timeout.
int exec (void)
 Enters the qt event loop. call exit or quit to exit thread.

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
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 readsallowed
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
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.

Static Private Attributes

static bool gAVformat_net_initialised = false

Friends

class ICRingBuffer

Additional Inherited Members

- Static Protected Member Functions inherited from MThread
static void ThreadSetup (const QString &)
 This is to be called on startup in those few threads that haven't been ported to MThread.
static void ThreadCleanup (void)
 This is to be called on exit in those few threads that haven't been ported to MThread.
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.
static void GetAllThreadNames (QStringList &list)
static void GetAllRunningThreadNames (QStringList &list)
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 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 ( 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 231 of file ringbuffer.cpp.

RingBuffer::RingBuffer ( RingBufferType  rbtype)
protected

Definition at line 178 of file ringbuffer.cpp.

Member Function Documentation

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.

Definition at line 105 of file ringbuffer.cpp.

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

void RingBuffer::SetWriteBufferSize ( int  newSize)
void RingBuffer::SetWriteBufferMinWriteSize ( int  newMinSize)

Calls ThreadedFileWriter::SetWriteBufferMinWriteSize(int)

Definition at line 1537 of file ringbuffer.cpp.

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

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

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

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

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

void RingBuffer::EnableBitrateMonitor ( bool  enable)
inline

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

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

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

Referenced by AvFormatDecoder::ScanStreams().

QString RingBuffer::GetSafeFilename ( void  )
inline

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

Referenced by MythPlayer::GetPlaybackData().

QString RingBuffer::GetFilename ( void  ) const
QString RingBuffer::GetSubtitleFilename ( void  ) const

Definition at line 1577 of file ringbuffer.cpp.

bool RingBuffer::GetStopReads ( void  ) const
inline

Returns value of stopreads.

See Also
StartReads(void), StopReads(void)

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

Referenced by FileTransfer::RequestBlock().

bool RingBuffer::isPaused ( void  ) const

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

Definition at line 613 of file ringbuffer.cpp.

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

Definition at line 1359 of file ringbuffer.cpp.

Referenced by MythPlayer::GetPlaybackData().

QString RingBuffer::GetStorageRate ( void  )

Definition at line 1364 of file ringbuffer.cpp.

Referenced by MythPlayer::GetPlaybackData().

QString RingBuffer::GetAvailableBuffer ( void  )

Definition at line 1369 of file ringbuffer.cpp.

Referenced by MythPlayer::GetPlaybackData().

uint RingBuffer::GetBufferSize ( void  )
inline

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

Referenced by MythPlayer::GetPlaybackData().

long long RingBuffer::GetWritePosition ( void  ) const
virtual long long RingBuffer::GetRealFileSize ( void  ) const
inlinevirtual
bool RingBuffer::IsNearEnd ( double  fps,
uint  vvf 
) const

Definition at line 408 of file ringbuffer.cpp.

Referenced by MythPlayer::IsReallyNearEnd().

virtual bool RingBuffer::IsOpen ( void  ) const
pure virtual
virtual bool RingBuffer::IsStreamed ( void  )
inlinevirtual
virtual bool RingBuffer::IsSeekingAllowed ( void  )
inlinevirtual
virtual bool RingBuffer::IsBookmarkAllowed ( void  )
inlinevirtual
virtual int RingBuffer::BestBufferSize ( void  )
inlinevirtual

Reimplemented in DVDRingBuffer.

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

Referenced by AvFormatDecoder::InitByteContext().

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

Definition at line 1326 of file ringbuffer.cpp.

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

RingBufferType RingBuffer::GetType ( void  ) const
inline
bool RingBuffer::IsDisc ( void  ) const
inline
bool RingBuffer::IsDVD ( void  ) const
inline

Definition at line 95 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(), DecoderBase::PosMapFromDb(), AvFormatDecoderDVD::PostProcessTracks(), MythDVDPlayer::PrepareAudioSample(), TV::ProcessKeypress(), TV::ProcessNetworkControlCommand(), AvFormatDecoder::ProcessSubtitlePacket(), AvFormatDecoder::ProcessVideoFrame(), AvFormatDecoder::ProcessVideoPacket(), ReadDirect(), AvFormatDecoder::ScanStreams(), MythDVDPlayer::SeekForScreenGrab(), AvFormatDecoder::SeekReset(), MythDVDPlayer::SetDVDBookmark(), TV::ShowLCDDVDInfo(), TV::ShowOSDStopWatchingRecording(), MythDVDPlayer::StillFrameCheck(), AvFormatDecoderDVD::StreamChangeCheck(), DecoderBase::SyncPositionMap(), AvFormatDecoderDVD::UpdateFramesPlayed(), and MythDVDPlayer::VideoLoop().

bool RingBuffer::IsBD ( void  ) const
inline
const DVDRingBuffer * RingBuffer::DVD ( void  ) const

Definition at line 1627 of file ringbuffer.cpp.

Referenced by TV::ActiveHandleAction(), AvFormatDecoderDVD::AdjustTimestamp(), MythDVDPlayer::CalcMaxFFTime(), MythDVDPlayer::ChangeSpeed(), 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(), AvFormatDecoder::GetTrackDesc(), MythDVDPlayer::GoToDVDProgram(), MythDVDPlayer::GoToMenu(), MythDVDPlayer::InitialSeek(), AvFormatDecoder::MpegPreProcessPkt(), DecoderBase::PosMapFromDb(), AvFormatDecoderDVD::PostProcessTracks(), MythDVDPlayer::PrepareAudioSample(), AvFormatDecoder::ProcessSubtitlePacket(), AvFormatDecoder::ProcessVideoPacket(), AvFormatDecoderDVD::ReadPacket(), AvFormatDecoder::ScanStreams(), MythDVDPlayer::SeekForScreenGrab(), MythDVDPlayer::SetDVDBookmark(), MythDVDPlayer::SetTrack(), TV::ShowLCDDVDInfo(), MythDVDPlayer::StillFrameCheck(), AvFormatDecoderDVD::StreamChangeCheck(), MythDVDPlayer::SwitchAngle(), DecoderBase::SyncPositionMap(), AvFormatDecoderDVD::UpdateFramesPlayed(), and MythDVDPlayer::VideoLoop().

const BDRingBuffer * RingBuffer::BD ( void  ) const
DVDRingBuffer * RingBuffer::DVD ( void  )

Definition at line 1637 of file ringbuffer.cpp.

BDRingBuffer * RingBuffer::BD ( void  )

Definition at line 1642 of file ringbuffer.cpp.

virtual bool RingBuffer::StartFromBeginning ( void  )
inlinevirtual

Reimplemented in DVDRingBuffer, and BDRingBuffer.

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

Referenced by AvFormatDecoder::OpenFile().

virtual void RingBuffer::IgnoreWaitStates ( bool  ignore)
inlinevirtual
virtual bool RingBuffer::IsInMenu ( void  ) const
inlinevirtual

Reimplemented in BDRingBuffer, and DVDRingBuffer.

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

Referenced by IsInDiscMenuOrStillFrame().

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

Reimplemented in BDRingBuffer, and DVDRingBuffer.

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

Referenced by TV::DiscMenuHandleAction().

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

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

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

Reimplemented in FileRingBuffer.

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

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

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

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

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

Definition at line 1010 of file ringbuffer.cpp.

Referenced by MythPlayer::OpenFile().

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

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

virtual long long RingBuffer::Seek ( long long  pos,
int  whence,
bool  has_lock = false 
)
pure virtual
void RingBuffer::Pause ( void  )

Pauses the read-ahead thread.

Calls StopReads(void).

See Also
Unpause(void), WaitForPause(void)

Definition at line 587 of file ringbuffer.cpp.

Referenced by ICRingBuffer::OpenFile(), MythPlayer::PauseBuffer(), TV::StopStuff(), and TV::SwitchCards().

void RingBuffer::Unpause ( void  )

Unpauses the read-ahead thread.

Calls StartReads(void).

See Also
Pause(void)

Definition at line 601 of file ringbuffer.cpp.

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

void RingBuffer::WaitForPause ( void  )

Waits for Pause(void) to take effect.

Definition at line 624 of file ringbuffer.cpp.

Referenced by TV::DoTogglePauseFinish(), MythPlayer::PauseBuffer(), TV::StopStuff(), and TV::SwitchCards().

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

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

void RingBuffer::StopReads ( void  )
void RingBuffer::StartReads ( void  )
bool RingBuffer::LiveMode ( void  ) const

Returns true if this RingBuffer has been assigned a LiveTVChain.

See Also
SetLiveMode(LiveTVChain*)

Definition at line 1600 of file ringbuffer.cpp.

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

void RingBuffer::SetLiveMode ( LiveTVChain chain)

Assigns a LiveTVChain to this RingBuffer.

See Also
LiveMode(void)

Definition at line 1612 of file ringbuffer.cpp.

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

void RingBuffer::IgnoreLiveEOF ( bool  ignore)

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

Definition at line 1620 of file ringbuffer.cpp.

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

int RingBuffer::Write ( const void buf,
uint  count 
)
bool RingBuffer::IsIOBound ( void  ) const
void RingBuffer::WriterFlush ( void  )
void RingBuffer::Sync ( void  )

Calls ThreadedFileWriter::Sync(void)

Definition at line 1490 of file ringbuffer.cpp.

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

Definition at line 999 of file ringbuffer.cpp.

Referenced by MythPlayer::SwitchToProgram().

void RingBuffer::SetTimeout ( bool  is_old)
inline

Calls SetOldFile(), do not use.

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

void RingBuffer::AVFormatInitNetwork ( void  )
static
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 734 of file ringbuffer.cpp.

void RingBuffer::CreateReadAheadBuffer ( void  )
protected

Definition at line 686 of file ringbuffer.cpp.

Referenced by run(), and SetBufferSizeFactors().

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

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

bool RingBuffer::PauseAndWait ( void  )
protected

Definition at line 643 of file ringbuffer.cpp.

Referenced by run().

virtual int RingBuffer::safe_read ( void data,
uint  sz 
)
protectedpure virtual
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 1187 of file ringbuffer.cpp.

Referenced by Peek(), and Read().

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

Definition at line 1115 of file ringbuffer.cpp.

Referenced by ReadPriv().

bool RingBuffer::WaitForReadsAllowed ( void  )
protected

Definition at line 1022 of file ringbuffer.cpp.

Referenced by ReadPriv().

bool RingBuffer::WaitForAvail ( int  count)
protected

Definition at line 1048 of file ringbuffer.cpp.

Referenced by ReadPriv().

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

Referenced by run().

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

Referenced by IsNearEnd(), ReadPriv(), and WaitForAvail().

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

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

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

Definition at line 1378 of file ringbuffer.cpp.

Referenced by GetDecoderRate(), and Read().

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

Definition at line 1412 of file ringbuffer.cpp.

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

Friends And Related Function Documentation

friend class ICRingBuffer
friend

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

Member Data Documentation

const int RingBuffer::kDefaultOpenTimeout = 2000
static

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

Referenced by mythfile_open().

const int RingBuffer::kLiveTVOpenTimeout = 10000
static
RingBufferType RingBuffer::type
protected

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

QReadWriteLock RingBuffer::poslock
mutableprotected
long long RingBuffer::readpos
protected
long long RingBuffer::writepos
protected
long long RingBuffer::internalreadpos
protected
long long RingBuffer::ignorereadpos
protected
QReadWriteLock RingBuffer::rbrlock
mutableprotected
int RingBuffer::rbrpos
protected
QReadWriteLock RingBuffer::rbwlock
mutableprotected
int RingBuffer::rbwpos
protected
volatile bool RingBuffer::stopreads
protected
QReadWriteLock RingBuffer::rwlock
mutableprotected
QString RingBuffer::safefilename
protected
QString RingBuffer::filename
protected
QString RingBuffer::subtitlefilename
protected

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

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

ThreadedFileWriter* RingBuffer::tfw
protected
int RingBuffer::fd2
protected
bool RingBuffer::writemode
protected
RemoteFile* RingBuffer::remotefile
protected
uint RingBuffer::bufferSize
protected
bool RingBuffer::low_buffers
protected

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

Referenced by CalcReadAheadThresh(), and WaitForAvail().

bool RingBuffer::fileismatroska
protected

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

Referenced by CreateReadAheadBuffer(), and SetBufferSizeFactors().

bool RingBuffer::unknownbitrate
protected

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

Referenced by CreateReadAheadBuffer(), and SetBufferSizeFactors().

bool RingBuffer::startreadahead
protected
char* RingBuffer::readAheadBuffer
protected

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

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

bool RingBuffer::readaheadrunning
protected
bool RingBuffer::reallyrunning
protected

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

Referenced by run(), and Start().

bool RingBuffer::request_pause
protected
bool RingBuffer::paused
protected

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

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

bool RingBuffer::ateof
protected
bool RingBuffer::readsallowed
protected
bool RingBuffer::setswitchtonext
protected
uint RingBuffer::rawbitrate
protected
float RingBuffer::playspeed
protected

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

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

int RingBuffer::fill_threshold
protected

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

Referenced by CalcReadAheadThresh(), and run().

int RingBuffer::fill_min
protected
int RingBuffer::readblocksize
protected
int RingBuffer::wanttoread
protected

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

Referenced by ReadPriv(), and WaitForAvail().

int RingBuffer::numfailures
protected
bool RingBuffer::commserror
protected
bool RingBuffer::oldfile
protected
LiveTVChain* RingBuffer::livetvchain
protected
bool RingBuffer::ignoreliveeof
protected

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

Referenced by IgnoreLiveEOF(), and run().

long long RingBuffer::readAdjust
protected
bool RingBuffer::bitrateMonitorEnabled
protected
QMutex RingBuffer::decoderReadLock
protected

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

Referenced by UpdateDecoderRate().

QMap<qint64, uint64_t> RingBuffer::decoderReads
protected

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

Referenced by UpdateDecoderRate().

QMutex RingBuffer::storageReadLock
protected

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

Referenced by UpdateStorageRate().

QMap<qint64, uint64_t> RingBuffer::storageReads
protected

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

Referenced by UpdateStorageRate().

QWaitCondition RingBuffer::generalWait
protected
QMutex RingBuffer::subExtLock
static
QStringList RingBuffer::subExt
static
QStringList RingBuffer::subExtNoCheck
static

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

Referenced by is_subtitle_possible(), and RingBuffer().

bool RingBuffer::gAVformat_net_initialised = false
staticprivate

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

Referenced by AVFormatInitNetwork().


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