diff --git a/Source/Core/AudioCommon/OpenALStream.cpp b/Source/Core/AudioCommon/OpenALStream.cpp index cb1281a88e..4852495d23 100644 --- a/Source/Core/AudioCommon/OpenALStream.cpp +++ b/Source/Core/AudioCommon/OpenALStream.cpp @@ -246,12 +246,6 @@ void OpenALStream::SoundLoop() frames_per_buffer = OAL_MAX_FRAMES; } - // DPL2 needs a minimum number of samples to work (FWRDURATION) - if (use_surround && frames_per_buffer < 240) - { - frames_per_buffer = 240; - } - INFO_LOG(AUDIO, "Using %d buffers, each with %d audio frames for a total of %d.", OAL_BUFFERS, frames_per_buffer, frames_per_buffer * OAL_BUFFERS); @@ -312,15 +306,6 @@ void OpenALStream::SoundLoop() if (rendered_frames < min_frames) continue; - // zero-out the subwoofer channel - DPL2Decode generates a pretty - // good 5.0 but not a good 5.1 output. Sadly there is not a 5.0 - // AL_FORMAT_50CHN32 to make this super-explicit. - // DPL2Decode output: LEFTFRONT, RIGHTFRONT, CENTREFRONT, (sub), LEFTREAR, RIGHTREAR - for (u32 i = 0; i < rendered_frames; ++i) - { - dpl2[i * SURROUND_CHANNELS + 3 /*sub/lfe*/] = 0.0f; - } - if (float32_capable) { palBufferData(m_buffers[next_buffer], AL_FORMAT_51CHN32, dpl2.data(), @@ -332,14 +317,11 @@ void OpenALStream::SoundLoop() for (u32 i = 0; i < rendered_frames * SURROUND_CHANNELS; ++i) { - // For some reason the ffdshow's DPL2 decoder outputs samples bigger than 1. - // Most are close to 2.5 and some go up to 8. Hard clamping here, we need to - // fix the decoder or implement a limiter. - dpl2[i] = dpl2[i] * (INT64_C(1) << 31); - if (dpl2[i] > INT_MAX) - surround_int32[i] = INT_MAX; - else if (dpl2[i] < INT_MIN) - surround_int32[i] = INT_MIN; + dpl2[i] = dpl2[i] * std::numeric_limits::max(); + if (dpl2[i] > std::numeric_limits::max()) + surround_int32[i] = std::numeric_limits::max(); + else if (dpl2[i] < std::numeric_limits::min()) + surround_int32[i] = std::numeric_limits::min(); else surround_int32[i] = static_cast(dpl2[i]); } @@ -353,13 +335,13 @@ void OpenALStream::SoundLoop() for (u32 i = 0; i < rendered_frames * SURROUND_CHANNELS; ++i) { - dpl2[i] = dpl2[i] * (1 << 15); - if (dpl2[i] > SHRT_MAX) - surround_short[i] = SHRT_MAX; - else if (dpl2[i] < SHRT_MIN) - surround_short[i] = SHRT_MIN; + dpl2[i] = dpl2[i] * std::numeric_limits::max(); + if (dpl2[i] > std::numeric_limits::max()) + surround_short[i] = std::numeric_limits::max(); + else if (dpl2[i] < std::numeric_limits::min()) + surround_short[i] = std::numeric_limits::min(); else - surround_short[i] = static_cast(dpl2[i]); + surround_short[i] = static_cast(dpl2[i]); } palBufferData(m_buffers[next_buffer], AL_FORMAT_51CHN16, surround_short.data(),