Skip to content

Commit

Permalink
ActiveAEStream: Avoid memcpy but take care for byte access
Browse files Browse the repository at this point in the history
  • Loading branch information
fritsch committed Dec 3, 2015
1 parent 097a209 commit e091f4e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp
Expand Up @@ -276,10 +276,12 @@ unsigned int CActiveAEStream::AddData(uint8_t* const *data, unsigned int offset,
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);
// Copies the high byte and the low byte
// Reason: We cannot assume that on every architecture an int is a byte array
// therefore we set those values per manual byte access. An alternative would be memcpy
// but this cannot be optimized that fine as the following code
*((uint8_t *) m_currentBuffer->pkt->data[0]+m_currentBuffer->pkt->nb_samples-2) = (uint8_t) ((minFrames >> 8) & 0xFF);
*((uint8_t *) m_currentBuffer->pkt->data[0]+m_currentBuffer->pkt->nb_samples-1) = (uint8_t) (minFrames & 0xFF);
m_bufferedTime += m_format.m_streamInfo.GetDuration() / 1000 / 24;
if (m_currentBuffer->pkt->nb_samples / 2560 == 24)
rawPktComplete = true;
Expand Down

0 comments on commit e091f4e

Please sign in to comment.