Skip to content

Commit

Permalink
Merge pull request hrydgard#15009 from unknownbrackets/audio-cleanup
Browse files Browse the repository at this point in the history
Audio: Correct protection against time skew
  • Loading branch information
hrydgard authored Oct 11, 2021
2 parents e91b8af + b1e31d8 commit bb64c17
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Core/HW/StereoResampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ void StereoResampler::PushSamples(const s32 *samples, unsigned int numSamples) {
}

// Check if we need to roll over to the start of the buffer during the copy.
int indexW_left_samples = m_maxBufsize * 2 - (indexW & INDEX_MASK);
unsigned int indexW_left_samples = m_maxBufsize * 2 - (indexW & INDEX_MASK);
if (numSamples * 2 > indexW_left_samples) {
ClampBufferToS16WithVolume(&m_buffer[indexW & INDEX_MASK], samples, indexW_left_samples);
ClampBufferToS16WithVolume(&m_buffer[0], samples + indexW_left_samples, numSamples * 2 - indexW_left_samples);
Expand Down
2 changes: 1 addition & 1 deletion UI/BackgroundAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ int BackgroundAudio::Play() {

double now = time_now_d();
int sz = 44100 / 60;
if (lastPlaybackTime_ > 0.0 && lastPlaybackTime_ >= now) {
if (lastPlaybackTime_ > 0.0 && lastPlaybackTime_ <= now) {
sz = (int)((now - lastPlaybackTime_) * 44100);
}
sz = std::min(BUFSIZE / 2, sz);
Expand Down

0 comments on commit bb64c17

Please sign in to comment.