Skip to content

Commit

Permalink
[mmalrenderer] Add locking around m_droppedPics
Browse files Browse the repository at this point in the history
  • Loading branch information
popcornmix committed Mar 31, 2015
1 parent f1342e7 commit 1631ea3
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions xbmc/cores/dvdplayer/DVDCodecs/Video/MMALCodec.cpp
Expand Up @@ -268,6 +268,9 @@ void CMMALVideo::dec_output_port_cb(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buf

if (m_drop_state)
{
pthread_mutex_lock(&m_output_mutex);
m_droppedPics++;
pthread_mutex_unlock(&m_output_mutex);
if (g_advancedSettings.CanLogComponent(LOGVIDEO))
CLog::Log(LOGDEBUG, "%s::%s - dropping %p (drop:%d)", CLASSNAME, __func__, buffer, m_drop_state);
}
Expand Down Expand Up @@ -757,6 +760,7 @@ void CMMALVideo::SetDropState(bool bDrop)
{
buffer = m_output_ready.front();
m_output_ready.pop();
m_droppedPics++;
}
pthread_mutex_unlock(&m_output_mutex);
if (buffer)
Expand Down Expand Up @@ -870,6 +874,7 @@ int CMMALVideo::Decode(uint8_t* pData, int iSize, double dts, double pts)

if (demuxer_bytes == 0)
{
pthread_mutex_lock(&m_output_mutex);
m_decode_frame_number++;
m_startframe = true;
if (m_drop_state)
Expand All @@ -879,11 +884,10 @@ int CMMALVideo::Decode(uint8_t* pData, int iSize, double dts, double pts)
else
{
// only push if we are successful with feeding mmal
pthread_mutex_lock(&m_output_mutex);
m_dts_queue.push(dts);
assert(m_dts_queue.size() < 5000);
pthread_mutex_unlock(&m_output_mutex);
}
pthread_mutex_unlock(&m_output_mutex);
if (m_changed_count_dec != m_changed_count)
{
if (g_advancedSettings.CanLogComponent(LOGVIDEO))
Expand Down Expand Up @@ -985,6 +989,7 @@ void CMMALVideo::Reset(void)
while (!m_demux_queue.empty())
m_demux_queue.pop();
m_demux_queue_length = 0;
m_droppedPics = 0;
pthread_mutex_unlock(&m_output_mutex);
if (!old_drop_state)
SetDropState(false);
Expand All @@ -994,7 +999,6 @@ void CMMALVideo::Reset(void)

m_startframe = false;
m_decoderPts = DVD_NOPTS_VALUE;
m_droppedPics = 0;
m_decode_frame_number = 1;
m_preroll = !m_hints.stills && (m_speed == DVD_PLAYSPEED_NORMAL || m_speed == DVD_PLAYSPEED_PAUSE);
m_codecControlFlags = 0;
Expand Down Expand Up @@ -1129,9 +1133,11 @@ bool CMMALVideo::ClearPicture(DVDVideoPicture* pDvdVideoPicture)

bool CMMALVideo::GetCodecStats(double &pts, int &droppedPics)
{
pthread_mutex_lock(&m_output_mutex);
pts = m_decoderPts;
droppedPics = m_droppedPics;
m_droppedPics = 0;
pthread_mutex_unlock(&m_output_mutex);
//if (g_advancedSettings.CanLogComponent(LOGVIDEO))
// CLog::Log(LOGDEBUG, "%s::%s - pts:%.0f droppedPics:%d", CLASSNAME, __func__, pts, droppedPics);
return true;
Expand Down

0 comments on commit 1631ea3

Please sign in to comment.