mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
Removed the synchronisation between the CPU thread and the audio thread.
Added code to detect and resume from buffer underruns. Disabled the ability to change the DPL2 option after the game has started. Fixed a memory leak that occurred in the DPL2 decoder. Fixed the OSX build.
This commit is contained in:
parent
ed5a68a504
commit
3632ce6df5
@ -79,7 +79,6 @@ void OpenALStream::Stop()
|
|||||||
threadData = 1;
|
threadData = 1;
|
||||||
// kick the thread if it's waiting
|
// kick the thread if it's waiting
|
||||||
soundSyncEvent.Set();
|
soundSyncEvent.Set();
|
||||||
mainSyncEvent.Set();
|
|
||||||
|
|
||||||
soundTouch.clear();
|
soundTouch.clear();
|
||||||
|
|
||||||
@ -112,7 +111,6 @@ void OpenALStream::SetVolume(int volume)
|
|||||||
void OpenALStream::Update()
|
void OpenALStream::Update()
|
||||||
{
|
{
|
||||||
soundSyncEvent.Set();
|
soundSyncEvent.Set();
|
||||||
mainSyncEvent.Wait();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenALStream::Clear(bool mute)
|
void OpenALStream::Clear(bool mute)
|
||||||
@ -149,10 +147,12 @@ void OpenALStream::SoundLoop()
|
|||||||
memset(realtimeBuffer, 0, OAL_MAX_SAMPLES * 4);
|
memset(realtimeBuffer, 0, OAL_MAX_SAMPLES * 4);
|
||||||
for (int i = 0; i < OAL_NUM_BUFFERS; i++)
|
for (int i = 0; i < OAL_NUM_BUFFERS; i++)
|
||||||
{
|
{
|
||||||
|
#if !defined(__APPLE__)
|
||||||
if (Core::g_CoreStartupParameter.bDPL2Decoder)
|
if (Core::g_CoreStartupParameter.bDPL2Decoder)
|
||||||
alBufferData(uiBuffers[i], AL_FORMAT_51CHN32, sampleBuffer, OAL_MAX_SAMPLES * SIZE_FLOAT * SURROUND_CHANNELS * OAL_NUM_BUFFERS, ulFrequency);
|
alBufferData(uiBuffers[i], AL_FORMAT_51CHN32, sampleBuffer, 4 * SIZE_FLOAT * SURROUND_CHANNELS, ulFrequency);
|
||||||
else
|
else
|
||||||
alBufferData(uiBuffers[i], AL_FORMAT_STEREO16, realtimeBuffer, OAL_MAX_SAMPLES * 4, ulFrequency);
|
#endif
|
||||||
|
alBufferData(uiBuffers[i], AL_FORMAT_STEREO16, realtimeBuffer, 4 * 2 * 2, ulFrequency);
|
||||||
}
|
}
|
||||||
alSourceQueueBuffers(uiSource, OAL_NUM_BUFFERS, uiBuffers);
|
alSourceQueueBuffers(uiSource, OAL_NUM_BUFFERS, uiBuffers);
|
||||||
alSourcePlay(uiSource);
|
alSourcePlay(uiSource);
|
||||||
@ -165,6 +165,7 @@ void OpenALStream::SoundLoop()
|
|||||||
|
|
||||||
ALint iBuffersFilled = 0;
|
ALint iBuffersFilled = 0;
|
||||||
ALint iBuffersProcessed = 0;
|
ALint iBuffersProcessed = 0;
|
||||||
|
ALint iState = 0;
|
||||||
ALuint uiBufferTemp[OAL_NUM_BUFFERS] = {0};
|
ALuint uiBufferTemp[OAL_NUM_BUFFERS] = {0};
|
||||||
|
|
||||||
soundTouch.setChannels(2);
|
soundTouch.setChannels(2);
|
||||||
@ -232,7 +233,7 @@ void OpenALStream::SoundLoop()
|
|||||||
if (surround_capable)
|
if (surround_capable)
|
||||||
{
|
{
|
||||||
// Convert the samples from short to float for the dpl2 decoder
|
// Convert the samples from short to float for the dpl2 decoder
|
||||||
float dest[OAL_MAX_SAMPLES * 2 * OAL_NUM_BUFFERS];
|
float dest[OAL_MAX_SAMPLES * 2 * 2 * OAL_NUM_BUFFERS];
|
||||||
for (u32 i = 0; i < nSamples; ++i)
|
for (u32 i = 0; i < nSamples; ++i)
|
||||||
{
|
{
|
||||||
dest[i * 2 + 0] = (float)sampleBuffer[i * 2 + 0] / (1<<16);
|
dest[i * 2 + 0] = (float)sampleBuffer[i * 2 + 0] / (1<<16);
|
||||||
@ -247,7 +248,7 @@ void OpenALStream::SoundLoop()
|
|||||||
if (err == AL_INVALID_ENUM)
|
if (err == AL_INVALID_ENUM)
|
||||||
{
|
{
|
||||||
// 5.1 is not supported by the host, fallback to stereo
|
// 5.1 is not supported by the host, fallback to stereo
|
||||||
WARN_LOG(AUDIO, "Unable set 5.1 surround mode. Updating OpenAL Soft might fix this issue.");
|
WARN_LOG(AUDIO, "Unable to set 5.1 surround mode. Updating OpenAL Soft might fix this issue.");
|
||||||
surround_capable = false;
|
surround_capable = false;
|
||||||
}
|
}
|
||||||
else if (err != 0)
|
else if (err != 0)
|
||||||
@ -278,13 +279,24 @@ void OpenALStream::SoundLoop()
|
|||||||
ERROR_LOG(AUDIO, "Error occurred during playback: %08x", err);
|
ERROR_LOG(AUDIO, "Error occurred during playback: %08x", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
alGetSourcei(uiSource, AL_SOURCE_STATE, &iState);
|
||||||
|
if (iState != AL_PLAYING)
|
||||||
|
{
|
||||||
|
// Buffer underrun occurred, resume playback
|
||||||
|
alSourcePlay(uiSource);
|
||||||
|
ALenum err = alGetError();
|
||||||
|
if (err != 0)
|
||||||
|
{
|
||||||
|
ERROR_LOG(AUDIO, "Error occurred resuming playback: %08x", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
soundSyncEvent.Wait();
|
soundSyncEvent.Wait();
|
||||||
}
|
}
|
||||||
mainSyncEvent.Set();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,6 +638,7 @@ void CConfigMain::CreateGUIControls()
|
|||||||
{
|
{
|
||||||
FrequencySelection->Disable();
|
FrequencySelection->Disable();
|
||||||
BackendSelection->Disable();
|
BackendSelection->Disable();
|
||||||
|
DPL2Decoder->Disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create sizer and add items to dialog
|
// Create sizer and add items to dialog
|
||||||
|
Loading…
Reference in New Issue
Block a user