Skip to content

Commit

Permalink
Fix white flash at the end of playback. (popcornmix#658)
Browse files Browse the repository at this point in the history
  • Loading branch information
jehutting committed Nov 13, 2018
1 parent a70e9b4 commit 580c93d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
5 changes: 4 additions & 1 deletion OMXAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,10 @@ bool COMXAudio::IsEOS()
unsigned int latency = GetAudioRenderingLatency();
CSingleLock lock (m_critSection);

if (!m_failed_eos && !(m_omx_decoder.IsEOS() && latency == 0))
bool hdmi_eos = ( !m_omx_render_hdmi.IsInitialized() || m_omx_render_hdmi.IsEOS());
bool analog_eos = ( !m_omx_render_analog.IsInitialized() || m_omx_render_analog.IsEOS());

if (!m_failed_eos && !(hdmi_eos && analog_eos && latency == 0))
return false;

if (m_submitted_eos)
Expand Down
23 changes: 18 additions & 5 deletions OMXPlayerAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,18 @@ bool OMXPlayerAudio::Decode(OMXPacket *pkt)
void OMXPlayerAudio::Process()
{
OMXPacket *omx_pkt = NULL;
unsigned int decoded_size = 0;

while(true)
{
Lock();

if(decoded_size)
{
m_cached_size -= decoded_size;
decoded_size = 0;
}

if(!(m_bStop || m_bAbort) && m_packets.empty())
pthread_cond_wait(&m_packet_cond, &m_lock);

Expand All @@ -299,9 +307,9 @@ void OMXPlayerAudio::Process()
else if(!omx_pkt && !m_packets.empty())
{
omx_pkt = m_packets.front();
m_cached_size -= omx_pkt->size;
m_packets.pop_front();
}
decoded_size = 0;
}
UnLock();

LockDecoder();
Expand All @@ -313,6 +321,7 @@ void OMXPlayerAudio::Process()
}
else if(omx_pkt && Decode(omx_pkt))
{
decoded_size = omx_pkt->size;
OMXReader::FreePacket(omx_pkt);
omx_pkt = NULL;
}
Expand Down Expand Up @@ -492,12 +501,16 @@ double OMXPlayerAudio::GetCacheTotal()

void OMXPlayerAudio::SubmitEOS()
{
if(m_decoder)
m_decoder->SubmitEOS();
assert(m_cached_size == 0);
assert(m_decoder);
assert(m_packets.empty());
m_decoder->SubmitEOS();
}

bool OMXPlayerAudio::IsEOS()
{
return m_packets.empty() && (!m_decoder || m_decoder->IsEOS());
assert(m_decoder);
assert(m_packets.empty());
return m_decoder->IsEOS();
}

24 changes: 18 additions & 6 deletions OMXPlayerVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,18 @@ bool OMXPlayerVideo::Decode(OMXPacket *pkt)
void OMXPlayerVideo::Process()
{
OMXPacket *omx_pkt = NULL;
unsigned int decoded_size = 0;

while(true)
{
Lock();

if(decoded_size)
{
m_cached_size -= decoded_size;
decoded_size = 0;
}

if(!(m_bStop || m_bAbort) && m_packets.empty())
pthread_cond_wait(&m_packet_cond, &m_lock);

Expand All @@ -247,8 +255,8 @@ void OMXPlayerVideo::Process()
else if(!omx_pkt && !m_packets.empty())
{
omx_pkt = m_packets.front();
m_cached_size -= omx_pkt->size;
m_packets.pop_front();
decoded_size = 0;
}
UnLock();

Expand All @@ -261,6 +269,7 @@ void OMXPlayerVideo::Process()
}
else if(omx_pkt && Decode(omx_pkt))
{
decoded_size = omx_pkt->size;
OMXReader::FreePacket(omx_pkt);
omx_pkt = NULL;
}
Expand Down Expand Up @@ -372,14 +381,17 @@ int OMXPlayerVideo::GetDecoderFreeSpace()

void OMXPlayerVideo::SubmitEOS()
{
if(m_decoder)
m_decoder->SubmitEOS();
assert(m_cached_size == 0);
assert(m_decoder);
assert(m_packets.empty());
m_decoder->SubmitEOS();

}

bool OMXPlayerVideo::IsEOS()
{
if(!m_decoder)
return false;
return m_packets.empty() && (!m_decoder || m_decoder->IsEOS());
assert(m_decoder);
assert(m_packets.empty());
return m_decoder->IsEOS();
}

0 comments on commit 580c93d

Please sign in to comment.