Merge pull request #4619 from fritsch/aefixes
[vuplus_xbmc] / xbmc / cores / AudioEngine / Engines / ActiveAE / ActiveAEStream.cpp
index a7cc97f..0287e73 100644 (file)
@@ -58,6 +58,7 @@ CActiveAEStream::CActiveAEStream(AEAudioFormat *format)
   m_forceResampler = false;
   m_remapper = NULL;
   m_remapBuffer = NULL;
+  m_streamResampleRatio = 1.0;
 }
 
 CActiveAEStream::~CActiveAEStream()
@@ -118,7 +119,7 @@ void CActiveAEStream::InitRemapper()
       for(unsigned int j=0; j<m_format.m_channelLayout.Count(); j++)
       {
         idx = m_remapper->GetAVChannelIndex(m_format.m_channelLayout[j], avLayout);
-        if (idx == i)
+        if (idx == (int)i)
         {
           ffmpegLayout += m_format.m_channelLayout[j];
           break;
@@ -134,7 +135,7 @@ void CActiveAEStream::InitRemapper()
       for(unsigned int j=0; j<m_format.m_channelLayout.Count(); j++)
       {
         idx = m_remapper->GetAVChannelIndex(m_format.m_channelLayout[j], avLayout);
-        if (idx == i)
+        if (idx == (int)i)
         {
           remapLayout += ffmpegLayout[j];
           break;
@@ -199,7 +200,7 @@ unsigned int CActiveAEStream::AddData(void *data, unsigned int size)
 
   while(copied < size)
   {
-    buf = (uint8_t*)data;
+    buf = ((uint8_t*)data) + copied;
     bytesToCopy = size - copied;
 
     if (m_currentBuffer)
@@ -208,9 +209,8 @@ unsigned int CActiveAEStream::AddData(void *data, unsigned int size)
       if (m_leftoverBytes && bytesToCopy >= (m_format.m_frameSize - m_leftoverBytes))
       {
         int fillbytes = m_format.m_frameSize - m_leftoverBytes;
-        memcpy(m_leftoverBuffer+m_leftoverBytes, (uint8_t*)data, fillbytes);
-        data = (uint8_t*)data + fillbytes;
-        size -= fillbytes;
+        memcpy(m_leftoverBuffer+m_leftoverBytes, buf, fillbytes);
+        copied += fillbytes;
         // leftover buffer will be copied on next cycle
         buf = m_leftoverBuffer;
         bytesToCopy = m_format.m_frameSize;
@@ -228,7 +228,7 @@ unsigned int CActiveAEStream::AddData(void *data, unsigned int size)
       // if we don't have a full frame, copy to leftover buffer
       if (!availableSamples && bytesToCopy)
       {
-        memcpy(m_leftoverBuffer+m_leftoverBytes, buf+copied, bytesToCopy);
+        memcpy(m_leftoverBuffer+m_leftoverBytes, buf, bytesToCopy);
         m_leftoverBytes = bytesToCopy;
         copied += bytesToCopy;
       }
@@ -238,9 +238,9 @@ unsigned int CActiveAEStream::AddData(void *data, unsigned int size)
 
       //TODO: handle planar formats
       if (m_convertFn)
-        m_convertFn(buf+copied, samples*m_currentBuffer->pkt->config.channels, (float*)(m_currentBuffer->pkt->data[0] + start));
+        m_convertFn(buf, samples*m_currentBuffer->pkt->config.channels, (float*)(m_currentBuffer->pkt->data[0] + start));
       else
-        memcpy(m_currentBuffer->pkt->data[0] + start, buf+copied, bytes);
+        memcpy(m_currentBuffer->pkt->data[0] + start, buf, bytes);
       {
         CSingleLock lock(*m_statsLock);
         m_currentBuffer->pkt->nb_samples += samples;
@@ -353,7 +353,6 @@ void CActiveAEStream::Drain(bool wait)
         MsgStreamSample msgData;
         msgData.stream = this;
         msgData.buffer = *((CSampleBuffer**)msg->data);
-        RemapBuffer();
         msg->Reply(CActiveAEDataProtocol::STREAMSAMPLE, &msgData, sizeof(MsgStreamSample));
         DecFreeBuffers();
         continue;