Skip to content

Commit 9082e6f

Browse files
committedNov 16, 2018
Pass SubmitEOS message through decode queue
So, the problem is that SubmitEOS is called when demuxer reaches end of file, but not all the encoded frames have been submitted to decoder. m_packets may contain dozens of encoded frames of data at the point SubmitEOS is called. We want those to all be submitted to decoder before the SubmitEOS is called.
1 parent a70e9b4 commit 9082e6f

4 files changed

+36
-2
lines changed
 

‎OMXPlayerAudio.cpp

+17-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,15 @@ void OMXPlayerAudio::Process()
299299
else if(!omx_pkt && !m_packets.empty())
300300
{
301301
omx_pkt = m_packets.front();
302-
m_cached_size -= omx_pkt->size;
302+
if (omx_pkt)
303+
{
304+
m_cached_size -= omx_pkt->size;
305+
}
306+
else
307+
{
308+
assert(m_cached_size == 0);
309+
SubmitEOSInternal();
310+
}
303311
m_packets.pop_front();
304312
}
305313
UnLock();
@@ -491,6 +499,14 @@ double OMXPlayerAudio::GetCacheTotal()
491499
}
492500

493501
void OMXPlayerAudio::SubmitEOS()
502+
{
503+
Lock();
504+
m_packets.push_back(nullptr);
505+
UnLock();
506+
pthread_cond_broadcast(&m_packet_cond);
507+
}
508+
509+
void OMXPlayerAudio::SubmitEOSInternal()
494510
{
495511
if(m_decoder)
496512
m_decoder->SubmitEOS();

‎OMXPlayerAudio.h

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class OMXPlayerAudio : public OMXThread
101101
double GetCacheTotal();
102102
double GetCurrentPTS() { return m_iCurrentPts; };
103103
void SubmitEOS();
104+
void SubmitEOSInternal();
104105
bool IsEOS();
105106
unsigned int GetCached() { return m_cached_size; };
106107
unsigned int GetMaxCached() { return m_config.queue_size * 1024 * 1024; };

‎OMXPlayerVideo.cpp

+17-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,15 @@ void OMXPlayerVideo::Process()
247247
else if(!omx_pkt && !m_packets.empty())
248248
{
249249
omx_pkt = m_packets.front();
250-
m_cached_size -= omx_pkt->size;
250+
if (omx_pkt)
251+
{
252+
m_cached_size -= omx_pkt->size;
253+
}
254+
else
255+
{
256+
assert(m_cached_size == 0);
257+
SubmitEOSInternal();
258+
}
251259
m_packets.pop_front();
252260
}
253261
UnLock();
@@ -371,6 +379,14 @@ int OMXPlayerVideo::GetDecoderFreeSpace()
371379
}
372380

373381
void OMXPlayerVideo::SubmitEOS()
382+
{
383+
Lock();
384+
m_packets.push_back(nullptr);
385+
UnLock();
386+
pthread_cond_broadcast(&m_packet_cond);
387+
}
388+
389+
void OMXPlayerVideo::SubmitEOSInternal()
374390
{
375391
if(m_decoder)
376392
m_decoder->SubmitEOS();

‎OMXPlayerVideo.h

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class OMXPlayerVideo : public OMXThread
9292
unsigned int GetMaxCached() { return m_config.queue_size * 1024 * 1024; };
9393
unsigned int GetLevel() { return m_config.queue_size ? 100.0f * m_cached_size / (m_config.queue_size * 1024.0f * 1024.0f) : 0; };
9494
void SubmitEOS();
95+
void SubmitEOSInternal();
9596
bool IsEOS();
9697
void SetDelay(double delay) { m_iVideoDelay = delay; }
9798
double GetDelay() { return m_iVideoDelay; }

0 commit comments

Comments
 (0)
Please sign in to comment.