summaryrefslogtreecommitdiff
path: root/Source/Core/AudioCommon/Src/OpenALStream.cpp
diff options
context:
space:
mode:
authorskidau <skidau@gmail.com>2013-01-16 00:10:49 +1100
committerskidau <skidau@gmail.com>2013-01-16 00:10:49 +1100
commita9388ce2e2b7d235cc943f19e16bdccf99cb68b3 (patch)
treef56c74146bbbc945248fe7a080f1c2a50676196b /Source/Core/AudioCommon/Src/OpenALStream.cpp
parente75a7b4572967a60fd5130ac3409c28b79a62580 (diff)
Added backwards compatibility with old OpenAL drivers.
Diffstat (limited to 'Source/Core/AudioCommon/Src/OpenALStream.cpp')
-rw-r--r--Source/Core/AudioCommon/Src/OpenALStream.cpp40
1 files changed, 30 insertions, 10 deletions
diff --git a/Source/Core/AudioCommon/Src/OpenALStream.cpp b/Source/Core/AudioCommon/Src/OpenALStream.cpp
index 489954e351..25bece8e8d 100644
--- a/Source/Core/AudioCommon/Src/OpenALStream.cpp
+++ b/Source/Core/AudioCommon/Src/OpenALStream.cpp
@@ -184,6 +184,11 @@ void OpenALStream::SoundLoop()
soundTouch.setSetting(SETTING_OVERLAP_MS, 12);
bool surround_capable = Core::g_CoreStartupParameter.bDPL2Decoder;
+#if defined(__APPLE__)
+ bool float32_capable = false;
+#else
+ bool float32_capable = true;
+#endif
while (!threadData)
{
@@ -270,18 +275,33 @@ void OpenALStream::SoundLoop()
#endif
if (!surround_capable)
{
-#if defined(__APPLE__)
- // Convert the samples from float to short
- short stereo[OAL_MAX_SAMPLES * 2 * 2 * OAL_MAX_BUFFERS];
- for (u32 i = 0; i < nSamples; ++i)
+ if (float32_capable)
{
- stereo[i * 2 + 0] = (short)((float)sampleBuffer[i * 2 + 0] * (1 << 16));
- stereo[i * 2 + 1] = (short)((float)sampleBuffer[i * 2 + 1] * (1 << 16));
+ alBufferData(uiBufferTemp[iBuffersFilled], AL_FORMAT_STEREO_FLOAT32, sampleBuffer, nSamples * 4 * 2, ulFrequency);
+ ALenum err = alGetError();
+ if (err == AL_INVALID_ENUM)
+ {
+ float32_capable = false;
+ }
+ else if (err != 0)
+ {
+ ERROR_LOG(AUDIO, "Error occurred while buffering float32 data: %08x", err);
+ }
+
+ }
+
+ if (!float32_capable)
+ {
+ // Convert the samples from float to short
+ short stereo[OAL_MAX_SAMPLES * 2 * 2 * OAL_MAX_BUFFERS];
+ for (u32 i = 0; i < nSamples; ++i)
+ {
+ stereo[i * 2 + 0] = (short)((float)sampleBuffer[i * 2 + 0] * (1 << 16));
+ stereo[i * 2 + 1] = (short)((float)sampleBuffer[i * 2 + 1] * (1 << 16));
+ }
+ alBufferData(uiBufferTemp[iBuffersFilled], AL_FORMAT_STEREO16, stereo, nSamples * 2 * 2, ulFrequency);
+
}
- alBufferData(uiBufferTemp[iBuffersFilled], AL_FORMAT_STEREO16, stereo, nSamples * 2 * 2, ulFrequency);
-#else
- alBufferData(uiBufferTemp[iBuffersFilled], AL_FORMAT_STEREO_FLOAT32, sampleBuffer, nSamples * 4 * 2, ulFrequency);
-#endif
}
alSourceQueueBuffers(uiSource, 1, &uiBufferTemp[iBuffersFilled]);