summaryrefslogtreecommitdiff
path: root/Source/Core/AudioCommon/OpenALStream.cpp
diff options
context:
space:
mode:
authorLAGonauta <lagonauta@gmail.com>2017-06-16 18:54:19 -0300
committerlfsafady <lfsafady@outlook.com>2017-06-27 07:10:32 -0300
commit9eb209c214a3999547fc572a094e5cd300ed7ace (patch)
treea53d08c6d9004a5daa6db5dc38f5119515ae5e9e /Source/Core/AudioCommon/OpenALStream.cpp
parent75af792070d1158a94da76ee706d4563ca58e950 (diff)
Removed redundant conversion to float when playing back stereo.
Diffstat (limited to 'Source/Core/AudioCommon/OpenALStream.cpp')
-rw-r--r--Source/Core/AudioCommon/OpenALStream.cpp38
1 files changed, 2 insertions, 36 deletions
diff --git a/Source/Core/AudioCommon/OpenALStream.cpp b/Source/Core/AudioCommon/OpenALStream.cpp
index 8d9e9cc1c4..7693e5336f 100644
--- a/Source/Core/AudioCommon/OpenALStream.cpp
+++ b/Source/Core/AudioCommon/OpenALStream.cpp
@@ -259,7 +259,6 @@ void OpenALStream::SoundLoop()
// Should we make these larger just in case the mixer ever sends more samples
// than what we request?
m_realtime_buffer.resize(frames_per_buffer * STEREO_CHANNELS);
- m_sample_buffer.resize(frames_per_buffer * STEREO_CHANNELS);
m_source = 0;
// Clear error state before querying or else we get false positives.
@@ -381,44 +380,11 @@ void OpenALStream::SoundLoop()
{
u32 rendered_frames = m_mixer->Mix(m_realtime_buffer.data(), min_frames);
- // Convert the samples from short to float
- for (u32 i = 0; i < rendered_frames * STEREO_CHANNELS; ++i)
- m_sample_buffer[i] = static_cast<float>(m_realtime_buffer[i]) / (1 << 15);
-
if (!rendered_frames)
continue;
- if (float32_capable)
- {
- palBufferData(m_buffers[next_buffer], AL_FORMAT_STEREO_FLOAT32, m_sample_buffer.data(),
- rendered_frames * FRAME_STEREO_FLOAT, frequency);
-
- err = CheckALError("buffering float32 data");
- if (err == AL_INVALID_ENUM)
- {
- float32_capable = false;
- }
- }
- else if (fixed32_capable)
- {
- // Clamping is not necessary here, samples are always between (-1,1)
- int stereo_int32[OAL_MAX_FRAMES * STEREO_CHANNELS];
- for (u32 i = 0; i < rendered_frames * STEREO_CHANNELS; ++i)
- stereo_int32[i] = (int)((float)m_sample_buffer[i] * (INT64_C(1) << 31));
-
- palBufferData(m_buffers[next_buffer], AL_FORMAT_STEREO32, stereo_int32,
- rendered_frames * FRAME_STEREO_INT32, frequency);
- }
- else
- {
- // Convert the samples from float to short
- short stereo[OAL_MAX_FRAMES * STEREO_CHANNELS];
- for (u32 i = 0; i < rendered_frames * STEREO_CHANNELS; ++i)
- stereo[i] = (short)((float)m_sample_buffer[i] * (1 << 15));
-
- palBufferData(m_buffers[next_buffer], AL_FORMAT_STEREO16, stereo,
- rendered_frames * FRAME_STEREO_SHORT, frequency);
- }
+ palBufferData(m_buffers[next_buffer], AL_FORMAT_STEREO16, m_realtime_buffer.data(),
+ rendered_frames * FRAME_STEREO_SHORT, frequency);
}
palSourceQueueBuffers(m_source, 1, &m_buffers[next_buffer]);