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