MythTV  master
videodecodebuffer.cpp
Go to the documentation of this file.
1 #include "videodecodebuffer.h"
2 
3 #include "mythplayer.h"
4 
5 #include <chrono> // for milliseconds
6 #include <thread> // for sleep_for
7 
9 {
10  m_runThread = false;
11  m_frameWaitCond.wakeAll();
12 
13  while (m_isRunning)
14  std::this_thread::sleep_for(std::chrono::milliseconds(50));
15 }
16 
18 {
19  m_runThread = false;
20  m_frameWaitCond.wakeAll();
21 
22  while (m_isRunning)
23  std::this_thread::sleep_for(std::chrono::milliseconds(50));
24 }
25 
27 {
28  m_isRunning = true;
29  while (m_runThread)
30  {
31  QMutexLocker locker(&m_queueLock);
32 
33  if (m_frameList.size() < m_maxFrames && !m_eof)
34  {
35  locker.unlock();
36 
37  DecodedFrameInfo tfInfo;
38  tfInfo.frame = nullptr;
39  tfInfo.didFF = 0;
40  tfInfo.isKey = false;
41 
43  tfInfo.isKey, m_honorCutlist))
44  {
46 
47  locker.relock();
48  m_frameList.append(tfInfo);
49  }
50  else if (m_player->GetEof() != kEofStateNone)
51  {
52  locker.relock();
53  m_eof = true;
54  }
55  else
56  continue;
57 
58  m_frameWaitCond.wakeAll();
59  }
60  else
61  {
62  m_frameWaitCond.wait(locker.mutex());
63  }
64  }
65  m_isRunning = false;
66 }
67 
68 VideoFrame *VideoDecodeBuffer::GetFrame(int &didFF, bool &isKey)
69 {
70  QMutexLocker locker(&m_queueLock);
71 
72  if (m_frameList.isEmpty())
73  {
74  if (m_eof)
75  return nullptr;
76 
77  m_frameWaitCond.wait(locker.mutex());
78 
79  if (m_frameList.isEmpty())
80  return nullptr;
81  }
82 
83  DecodedFrameInfo tfInfo = m_frameList.takeFirst();
84  locker.unlock();
85  m_frameWaitCond.wakeAll();
86 
87  didFF = tfInfo.didFF;
88  isKey = tfInfo.isKey;
89 
90  return tfInfo.frame;
91 }
92 
93 /* vim: set expandtab tabstop=4 shiftwidth=4: */
94 
virtual VideoFrame * GetLastDecodedFrame(void)
virtual ~VideoDecodeBuffer()
QList< DecodedFrameInfo > m_frameList
bool volatile m_runThread
MythVideoOutput *const m_videoOutput
bool TranscodeGetNextFrame(int &did_ff, bool &is_key, bool honorCutList)
QWaitCondition m_frameWaitCond
bool volatile m_isRunning
EofState GetEof(void) const
MythPlayer *const m_player
bool const m_honorCutlist
void run() override
VideoFrame * GetFrame(int &didFF, bool &isKey)