Skip to content

Commit

Permalink
Fix looping video issues, and white flicker upon end of video
Browse files Browse the repository at this point in the history
See several looping short video issues (e.g. popcornmix#449) and white flicker popcornmix#250
  • Loading branch information
jehutting committed May 9, 2016
1 parent 2085f85 commit 401b015
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 61 deletions.
5 changes: 4 additions & 1 deletion OMXAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,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
60 changes: 20 additions & 40 deletions OMXPlayerAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ void OMXPlayerAudio::Process()
while(true)
{
Lock();
if(!(m_bStop || m_bAbort) && m_packets.empty())
if(!(m_bStop || m_bAbort) && !omx_pkt && m_packets.empty())
pthread_cond_wait(&m_packet_cond, &m_lock);

if (m_bStop || m_bAbort)
Expand All @@ -290,29 +290,28 @@ void OMXPlayerAudio::Process()
break;
}

if(m_flush && omx_pkt)
if(m_flush)
{
OMXReader::FreePacket(omx_pkt);
omx_pkt = NULL;
if(omx_pkt)
{
OMXReader::FreePacket(omx_pkt);
omx_pkt = NULL;
}
m_flush = false;
}
else if(!omx_pkt && !m_packets.empty())

if(!omx_pkt && !m_packets.empty())
{
omx_pkt = m_packets.front();
m_cached_size -= omx_pkt->size;
m_packets.pop_front();
}

UnLock();

LockDecoder();
if(m_flush && omx_pkt)
{
OMXReader::FreePacket(omx_pkt);
omx_pkt = NULL;
m_flush = false;
}
else if(omx_pkt && Decode(omx_pkt))
if(omx_pkt && Decode(omx_pkt))
{
m_cached_size -= omx_pkt->size;
OMXReader::FreePacket(omx_pkt);
omx_pkt = NULL;
}
Expand Down Expand Up @@ -359,8 +358,10 @@ bool OMXPlayerAudio::AddPacket(OMXPacket *pkt)
if((m_cached_size + pkt->size) < m_config.queue_size * 1024 * 1024)
{
Lock();
LockDecoder();
m_cached_size += pkt->size;
m_packets.push_back(pkt);
UnLockDecoder();
UnLock();
ret = true;
pthread_cond_broadcast(&m_packet_cond);
Expand Down Expand Up @@ -492,36 +493,15 @@ double OMXPlayerAudio::GetCacheTotal()

void OMXPlayerAudio::SubmitEOS()
{
if(m_decoder)
m_decoder->SubmitEOS();
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();
}

void OMXPlayerAudio::WaitCompletion()
{
if(!m_decoder)
return;

unsigned int nTimeOut = m_config.fifo_size * 1000;
while(nTimeOut)
{
if(IsEOS())
{
CLog::Log(LOGDEBUG, "%s::%s - got eos\n", "OMXPlayerAudio", __func__);
break;
}

if(nTimeOut == 0)
{
CLog::Log(LOGERROR, "%s::%s - wait for eos timed out\n", "OMXPlayerAudio", __func__);
break;
}
OMXClock::OMXSleep(50);
nTimeOut -= 50;
}
}

1 change: 0 additions & 1 deletion OMXPlayerAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ class OMXPlayerAudio : public OMXThread
double GetCurrentPTS() { return m_iCurrentPts; };
void SubmitEOS();
bool IsEOS();
void WaitCompletion();
unsigned int GetCached() { return m_cached_size; };
unsigned int GetMaxCached() { return m_config.queue_size * 1024 * 1024; };
unsigned int GetLevel() { return m_config.queue_size ? 100.0f * m_cached_size / (m_config.queue_size * 1024.0f * 1024.0f) : 0; };
Expand Down
39 changes: 20 additions & 19 deletions OMXPlayerVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ bool OMXPlayerVideo::Decode(OMXPacket *pkt)
if(m_flush_requested) return true;
}

CLog::Log(LOGINFO, "CDVDPlayerVideo::Decode dts:%.0f pts:%.0f cur:%.0f, size:%d", pkt->dts, pkt->pts, m_iCurrentPts, pkt->size);
CLog::Log(LOGINFO, "OMXPlayerVideo::Decode dts:%.0f pts:%.0f cur:%.0f, size:%d", pkt->dts, pkt->pts, m_iCurrentPts, pkt->size);
m_decoder->Decode(pkt->data, pkt->size, dts, pts);
return true;
}
Expand All @@ -233,29 +233,27 @@ void OMXPlayerVideo::Process()
break;
}

if(m_flush && omx_pkt)
if(m_flush)
{
OMXReader::FreePacket(omx_pkt);
omx_pkt = NULL;
if(omx_pkt)
{
OMXReader::FreePacket(omx_pkt);
omx_pkt = NULL;
}
m_flush = false;
}
else if(!omx_pkt && !m_packets.empty())

if(!omx_pkt && !m_packets.empty())
{
omx_pkt = m_packets.front();
m_cached_size -= omx_pkt->size;
m_packets.pop_front();
}
UnLock();

UnLock();
LockDecoder();
if(m_flush && omx_pkt)
{
OMXReader::FreePacket(omx_pkt);
omx_pkt = NULL;
m_flush = false;
}
else if(omx_pkt && Decode(omx_pkt))
if(omx_pkt && Decode(omx_pkt))
{
m_cached_size -= omx_pkt->size;
OMXReader::FreePacket(omx_pkt);
omx_pkt = NULL;
}
Expand Down Expand Up @@ -300,8 +298,10 @@ bool OMXPlayerVideo::AddPacket(OMXPacket *pkt)
if((m_cached_size + pkt->size) < m_config.queue_size * 1024 * 1024)
{
Lock();
LockDecoder();
m_cached_size += pkt->size;
m_packets.push_back(pkt);
UnLockDecoder();
UnLock();
ret = true;
pthread_cond_broadcast(&m_packet_cond);
Expand Down Expand Up @@ -367,14 +367,15 @@ int OMXPlayerVideo::GetDecoderFreeSpace()

void OMXPlayerVideo::SubmitEOS()
{
if(m_decoder)
m_decoder->SubmitEOS();
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 401b015

Please sign in to comment.