Skip to content

Commit

Permalink
OMXAudio: Handle changes in decoded audio size correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
popcornmix committed Jan 26, 2016
1 parent 6522775 commit f4d0af0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions xbmc/cores/omxplayer/OMXAudioCodecOMX.cpp
Expand Up @@ -104,10 +104,6 @@ bool COMXAudioCodecOMX::Open(CDVDStreamInfo &hints)
if (m_pCodecContext->request_channel_layout)
CLog::Log(LOGNOTICE,"COMXAudioCodecOMX::Open() Requesting channel layout of %x", (unsigned)m_pCodecContext->request_channel_layout);

// vorbis and wma2v2 have variable sized planar output, so skip concatenation
if (hints.codec == AV_CODEC_ID_VORBIS || hints.codec == AV_CODEC_ID_WMAV2)
m_bNoConcatenate = true;

if(m_pCodecContext->bits_per_coded_sample == 0)
m_pCodecContext->bits_per_coded_sample = 16;

Expand Down Expand Up @@ -207,12 +203,19 @@ int COMXAudioCodecOMX::GetData(BYTE** dst, double &dts, double &pts)
/* output audio will be packed */
int outputSize = av_samples_get_buffer_size(&outLineSize, m_pCodecContext->channels, m_pFrame1->nb_samples, m_desiredSampleFormat, 1);

if (!m_bNoConcatenate && m_iBufferOutputUsed && (int)m_frameSize != outputSize)
{
CLog::Log(LOGERROR, "COMXAudioCodecOMX::GetData Unexpected change of size (%d->%d)", m_frameSize, outputSize);
m_bNoConcatenate = true;
}

// if this buffer won't fit then flush out what we have
int desired_size = AUDIO_DECODE_OUTPUT_BUFFER * (m_pCodecContext->channels * GetBitsPerSample()) >> (rounded_up_channels_shift[m_pCodecContext->channels] + 4);
if (m_iBufferOutputUsed && (m_iBufferOutputUsed + outputSize > desired_size || m_bNoConcatenate))
{
int ret = m_iBufferOutputUsed;
m_iBufferOutputUsed = 0;
m_bNoConcatenate = false;
dts = m_dts;
pts = m_pts;
*dst = m_pBufferOutput;
Expand Down Expand Up @@ -279,9 +282,6 @@ int COMXAudioCodecOMX::GetData(BYTE** dst, double &dts, double &pts)
m_bFirstFrame = false;
}
m_iBufferOutputUsed += outputSize;

if (!m_bNoConcatenate && m_pCodecContext->sample_fmt == AV_SAMPLE_FMT_FLTP && m_frameSize && (int)m_frameSize != outputSize)
CLog::Log(LOGERROR, "COMXAudioCodecOMX::GetData Unexpected change of size (%d->%d)", m_frameSize, outputSize);
return 0;
}

Expand Down

0 comments on commit f4d0af0

Please sign in to comment.