Permalink
Browse files

Merge pull request #2375 from fritsch/ae-fix-resample

AE: Fix resample of e.g. 192 khz to 48 khz audio by scaling refillbuffer and waterlevel
  • Loading branch information...
2 parents 91fbd97 + 8717c16 commit 55b7b93a320fdbe834188cf1b172b567f06fd7f6 @davilla davilla committed Mar 6, 2013
Showing with 7 additions and 0 deletions.
  1. +7 −0 xbmc/cores/AudioEngine/Engines/SoftAE/SoftAEStream.cpp
View
7 xbmc/cores/AudioEngine/Engines/SoftAE/SoftAEStream.cpp
@@ -196,6 +196,13 @@ void CSoftAEStream::Initialize()
m_ssrcData.data_out = (float*)_aligned_malloc(m_format.m_frameSamples * (int)std::ceil(m_ssrcData.src_ratio) * sizeof(float), 16);
m_ssrcData.output_frames = m_format.m_frames * (long)std::ceil(m_ssrcData.src_ratio);
m_ssrcData.end_of_input = 0;
+ // we must buffer the same amount as before but taking the source sample rate into account
+ // there is no reason to decrease the buffer for upsampling
+ if (m_internalRatio < 1)
+ {
+ m_waterLevel *= (1.0 / m_internalRatio);
+ m_refillBuffer = m_waterLevel;
+ }
}
m_limiter.SetSamplerate(AE.GetSampleRate());

0 comments on commit 55b7b93

Please sign in to comment.