Skip to content

Commit

Permalink
AE: fix passthrough for truehd
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta committed Nov 30, 2015
1 parent 02f0b62 commit adfa2b8
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 5 deletions.
5 changes: 4 additions & 1 deletion xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ void CEngineStats::AddSamples(int samples, std::list<CActiveAEStream*> &streams)
std::deque<CSampleBuffer*>::iterator itBuf;
for(itBuf=(*it)->m_processingSamples.begin(); itBuf!=(*it)->m_processingSamples.end(); ++itBuf)
{
delay += (float)(*itBuf)->pkt->nb_samples / (*itBuf)->pkt->config.sample_rate;
if (m_pcmOutput)
delay += (float)(*itBuf)->pkt->nb_samples / (*itBuf)->pkt->config.sample_rate;
else
delay += m_sinkFormat.m_streamInfo.GetDuration() / 1000;
}
delay += (*it)->m_resampleBuffers->GetDelay();
(*it)->m_bufferedTime = delay;
Expand Down
16 changes: 15 additions & 1 deletion xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,21 @@ unsigned int CActiveAESink::OutputSamples(CSampleBuffer* samples)

if (m_requestedFormat.m_dataFormat == AE_FMT_RAW && m_needIecPack && samples->pool)
{
m_packer->Pack(m_sinkFormat.m_streamInfo, buffer[0], frames);
if (m_sinkFormat.m_streamInfo.m_type == CAEStreamInfo::STREAM_TYPE_TRUEHD)
{
int offset;
int len;
m_packer->GetBuffer();
for (int i=0; i<24; i++)
{
offset = i*2560;
len = (*(buffer[0] + offset+2560-2) << 8) + *(buffer[0] + offset+2560-1);
m_packer->Pack(m_sinkFormat.m_streamInfo, buffer[0] + offset, len);
}
}
else
m_packer->Pack(m_sinkFormat.m_streamInfo, buffer[0], frames);

unsigned int size = m_packer->GetSize();
packBuffer = m_packer->GetBuffer();
buffer = &packBuffer;
Expand Down
30 changes: 27 additions & 3 deletions xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,37 @@ unsigned int CActiveAEStream::AddData(uint8_t* const *data, unsigned int offset,
}
copied += minFrames;

bool rawPktComplete = false;
{
CSingleLock lock(*m_statsLock);
m_currentBuffer->pkt->nb_samples += minFrames;
m_bufferedTime += (double)minFrames / m_currentBuffer->pkt->config.sample_rate;
if (m_format.m_dataFormat != AE_FMT_RAW)
{
m_currentBuffer->pkt->nb_samples += minFrames;
m_bufferedTime += (double)minFrames / m_currentBuffer->pkt->config.sample_rate;
}
else
{
if (m_format.m_streamInfo.m_type == CAEStreamInfo::STREAM_TYPE_TRUEHD)
{
m_currentBuffer->pkt->nb_samples += 2560;
uint8_t highByte = (minFrames >> 8) & 0xFF;
uint8_t lowByte = minFrames & 0xFF;
memcpy(m_currentBuffer->pkt->data[0]+m_currentBuffer->pkt->nb_samples-2, &highByte, 1);
memcpy(m_currentBuffer->pkt->data[0]+m_currentBuffer->pkt->nb_samples-1, &lowByte, 1);
m_bufferedTime += m_format.m_streamInfo.GetDuration() / 1000 / 24;
if (m_currentBuffer->pkt->nb_samples / 2560 == 24)
rawPktComplete = true;
}
else
{
m_bufferedTime += m_format.m_streamInfo.GetDuration() / 1000;
m_currentBuffer->pkt->nb_samples += minFrames;
rawPktComplete = true;
}
}
}

if (m_currentBuffer->pkt->nb_samples == m_currentBuffer->pkt->max_nb_samples || m_format.m_dataFormat == AE_FMT_RAW)
if (m_currentBuffer->pkt->nb_samples == m_currentBuffer->pkt->max_nb_samples || rawPktComplete)
{
MsgStreamSample msgData;
msgData.buffer = m_currentBuffer;
Expand Down
1 change: 1 addition & 0 deletions xbmc/cores/AudioEngine/Utils/AEBitstreamPacker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ unsigned int CAEBitstreamPacker::GetSize()
uint8_t* CAEBitstreamPacker::GetBuffer()
{
m_dataSize = 0;
m_trueHDPos = 0;
return m_packedBuffer;
}

Expand Down

0 comments on commit adfa2b8

Please sign in to comment.