Skip to content

Commit

Permalink
VideoBuffers: Improved pause frame handling.
Browse files Browse the repository at this point in the history
- actually add the pause frame to the pause queue

- include all buffers in the debug output

- in GetScratchFrame, return the pause frame as added to the pause queue
rather than the last video buffer - which will prevent issues in the
future should we move to dynamically resizing the video buffers.
  • Loading branch information
Mark Kendall committed Apr 11, 2011
1 parent 3aef196 commit f54bfcb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
27 changes: 9 additions & 18 deletions mythtv/libs/libmythtv/videobuffers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ YUVInfo::YUVInfo(uint w, uint h, uint sz, const int *p, const int *o)
VideoBuffers::VideoBuffers()
: numbuffers(0), needfreeframes(0), needprebufferframes(0),
needprebufferframes_normal(0), needprebufferframes_small(0),
keepprebufferframes(0), need_extra_for_pause(false), rpos(0), vpos(0),
keepprebufferframes(0), createdpauseframe(false), rpos(0), vpos(0),
global_lock(QMutex::Recursive)
{
}
Expand Down Expand Up @@ -182,7 +182,10 @@ void VideoBuffers::Init(uint numdecode, bool extra_for_pause,
needprebufferframes_normal = needprebuffer_normal;
needprebufferframes_small = needprebuffer_small;
keepprebufferframes = keepprebuffer;
need_extra_for_pause = extra_for_pause;
createdpauseframe = extra_for_pause;

if (createdpauseframe)
enqueue(kVideoBuffer_pause, at(numcreate - 1));

for (uint i = 0; i < numdecode; i++)
enqueue(kVideoBuffer_avail, at(i));
Expand Down Expand Up @@ -580,26 +583,14 @@ bool VideoBuffers::contains(BufferType type, VideoFrame *frame) const

VideoFrame *VideoBuffers::GetScratchFrame(void)
{
if (!need_extra_for_pause)
{
VERBOSE(VB_IMPORTANT,
"GetScratchFrame() called, but not allocated");
}

QMutexLocker locker(&global_lock);
return at(allocSize()-1);
}

const VideoFrame *VideoBuffers::GetScratchFrame(void) const
{
if (!need_extra_for_pause)
if (!createdpauseframe || !head(kVideoBuffer_pause))
{
VERBOSE(VB_IMPORTANT,
"GetScratchFrame() called, but not allocated");
}

QMutexLocker locker(&global_lock);
return at(allocSize()-1);
return head(kVideoBuffer_pause);
}

/**
Expand Down Expand Up @@ -801,8 +792,8 @@ void VideoBuffers::DeleteBuffers()
static unsigned long long to_bitmap(const frame_queue_t& list);
QString VideoBuffers::GetStatus(int n) const
{
if (0 > n)
n = numbuffers;
if (n <= 0)
n = allocSize();

QString str("");
if (global_lock.tryLock())
Expand Down
3 changes: 1 addition & 2 deletions mythtv/libs/libmythtv/videobuffers.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ class VideoBuffers
bool contains(BufferType type, VideoFrame*) const;

VideoFrame *GetScratchFrame(void);
const VideoFrame *GetScratchFrame() const;
VideoFrame *GetLastDecodedFrame(void) { return at(vpos); }
VideoFrame *GetLastShownFrame(void) { return at(rpos); }
void SetLastShownFrameToScratch() { rpos = size(); }
Expand Down Expand Up @@ -145,7 +144,7 @@ class VideoBuffers
uint needprebufferframes_normal;
uint needprebufferframes_small;;
uint keepprebufferframes;
bool need_extra_for_pause;
bool createdpauseframe;

uint rpos;
uint vpos;
Expand Down

0 comments on commit f54bfcb

Please sign in to comment.