Performance tweaks to PortAudio renderer

This commit is contained in:
Cameron Gutman
2018-09-22 21:00:44 -07:00
parent 896b247bc0
commit f2e40889b2
2 changed files with 12 additions and 9 deletions

View File

@@ -70,14 +70,6 @@ bool PortAudioRenderer::prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATION*
return false;
}
error = Pa_StartStream(m_Stream);
if (error != paNoError) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"Pa_StartStream() failed: %s",
Pa_GetErrorText(error));
return false;
}
return true;
}
@@ -101,6 +93,17 @@ void PortAudioRenderer::submitAudio(short* audioBuffer, int audioSize)
// race since we'll either read the original value of m_WriteIndex (which is safe,
// we just won't consider this sample) or the new value of m_WriteIndex
m_WriteIndex = (m_WriteIndex + 1) % CIRCULAR_BUFFER_SIZE;
// Start the stream after we've written the first sample to it
if (Pa_IsStreamStopped(m_Stream) == 1) {
PaError error = Pa_StartStream(m_Stream);
if (error != paNoError) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"Pa_StartStream() failed: %s",
Pa_GetErrorText(error));
return;
}
}
}
bool PortAudioRenderer::testAudio(int audioConfiguration)

View File

@@ -4,7 +4,7 @@
#include "renderer.h"
#define CIRCULAR_BUFFER_SIZE 32
#define CIRCULAR_BUFFER_SIZE 16
#define MAX_CHANNEL_COUNT 6
#define CIRCULAR_BUFFER_STRIDE (MAX_CHANNEL_COUNT * SAMPLES_PER_FRAME)