Skip to content

Commit adfa2b8

Browse files
committed
AE: fix passthrough for truehd
1 parent 02f0b62 commit adfa2b8

File tree

4 files changed

+47
-5
lines changed

4 files changed

+47
-5
lines changed

xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ void CEngineStats::AddSamples(int samples, std::list<CActiveAEStream*> &streams)
7474
std::deque<CSampleBuffer*>::iterator itBuf;
7575
for(itBuf=(*it)->m_processingSamples.begin(); itBuf!=(*it)->m_processingSamples.end(); ++itBuf)
7676
{
77-
delay += (float)(*itBuf)->pkt->nb_samples / (*itBuf)->pkt->config.sample_rate;
77+
if (m_pcmOutput)
78+
delay += (float)(*itBuf)->pkt->nb_samples / (*itBuf)->pkt->config.sample_rate;
79+
else
80+
delay += m_sinkFormat.m_streamInfo.GetDuration() / 1000;
7881
}
7982
delay += (*it)->m_resampleBuffers->GetDelay();
8083
(*it)->m_bufferedTime = delay;

xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,21 @@ unsigned int CActiveAESink::OutputSamples(CSampleBuffer* samples)
895895

896896
if (m_requestedFormat.m_dataFormat == AE_FMT_RAW && m_needIecPack && samples->pool)
897897
{
898-
m_packer->Pack(m_sinkFormat.m_streamInfo, buffer[0], frames);
898+
if (m_sinkFormat.m_streamInfo.m_type == CAEStreamInfo::STREAM_TYPE_TRUEHD)
899+
{
900+
int offset;
901+
int len;
902+
m_packer->GetBuffer();
903+
for (int i=0; i<24; i++)
904+
{
905+
offset = i*2560;
906+
len = (*(buffer[0] + offset+2560-2) << 8) + *(buffer[0] + offset+2560-1);
907+
m_packer->Pack(m_sinkFormat.m_streamInfo, buffer[0] + offset, len);
908+
}
909+
}
910+
else
911+
m_packer->Pack(m_sinkFormat.m_streamInfo, buffer[0], frames);
912+
899913
unsigned int size = m_packer->GetSize();
900914
packBuffer = m_packer->GetBuffer();
901915
buffer = &packBuffer;

xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,37 @@ unsigned int CActiveAEStream::AddData(uint8_t* const *data, unsigned int offset,
263263
}
264264
copied += minFrames;
265265

266+
bool rawPktComplete = false;
266267
{
267268
CSingleLock lock(*m_statsLock);
268-
m_currentBuffer->pkt->nb_samples += minFrames;
269-
m_bufferedTime += (double)minFrames / m_currentBuffer->pkt->config.sample_rate;
269+
if (m_format.m_dataFormat != AE_FMT_RAW)
270+
{
271+
m_currentBuffer->pkt->nb_samples += minFrames;
272+
m_bufferedTime += (double)minFrames / m_currentBuffer->pkt->config.sample_rate;
273+
}
274+
else
275+
{
276+
if (m_format.m_streamInfo.m_type == CAEStreamInfo::STREAM_TYPE_TRUEHD)
277+
{
278+
m_currentBuffer->pkt->nb_samples += 2560;
279+
uint8_t highByte = (minFrames >> 8) & 0xFF;
280+
uint8_t lowByte = minFrames & 0xFF;
281+
memcpy(m_currentBuffer->pkt->data[0]+m_currentBuffer->pkt->nb_samples-2, &highByte, 1);
282+
memcpy(m_currentBuffer->pkt->data[0]+m_currentBuffer->pkt->nb_samples-1, &lowByte, 1);
283+
m_bufferedTime += m_format.m_streamInfo.GetDuration() / 1000 / 24;
284+
if (m_currentBuffer->pkt->nb_samples / 2560 == 24)
285+
rawPktComplete = true;
286+
}
287+
else
288+
{
289+
m_bufferedTime += m_format.m_streamInfo.GetDuration() / 1000;
290+
m_currentBuffer->pkt->nb_samples += minFrames;
291+
rawPktComplete = true;
292+
}
293+
}
270294
}
271295

272-
if (m_currentBuffer->pkt->nb_samples == m_currentBuffer->pkt->max_nb_samples || m_format.m_dataFormat == AE_FMT_RAW)
296+
if (m_currentBuffer->pkt->nb_samples == m_currentBuffer->pkt->max_nb_samples || rawPktComplete)
273297
{
274298
MsgStreamSample msgData;
275299
msgData.buffer = m_currentBuffer;

xbmc/cores/AudioEngine/Utils/AEBitstreamPacker.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ unsigned int CAEBitstreamPacker::GetSize()
9898
uint8_t* CAEBitstreamPacker::GetBuffer()
9999
{
100100
m_dataSize = 0;
101+
m_trueHDPos = 0;
101102
return m_packedBuffer;
102103
}
103104

0 commit comments

Comments
 (0)