mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-04-03 06:16:12 +00:00
Avoid calling Pa_IsStreamStopped() on each audio frame
This commit is contained in:
@@ -8,7 +8,8 @@ PortAudioRenderer::PortAudioRenderer()
|
||||
: m_Stream(nullptr),
|
||||
m_ChannelCount(0),
|
||||
m_WriteIndex(0),
|
||||
m_ReadIndex(0)
|
||||
m_ReadIndex(0),
|
||||
m_Started(false)
|
||||
{
|
||||
PaError error = Pa_Initialize();
|
||||
if (error != paNoError) {
|
||||
@@ -95,7 +96,7 @@ void PortAudioRenderer::submitAudio(short* audioBuffer, int audioSize)
|
||||
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) {
|
||||
if (!m_Started) {
|
||||
PaError error = Pa_StartStream(m_Stream);
|
||||
if (error != paNoError) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
@@ -103,6 +104,8 @@ void PortAudioRenderer::submitAudio(short* audioBuffer, int audioSize)
|
||||
Pa_GetErrorText(error));
|
||||
return;
|
||||
}
|
||||
|
||||
m_Started = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ private:
|
||||
int m_ChannelCount;
|
||||
int m_WriteIndex;
|
||||
int m_ReadIndex;
|
||||
bool m_Started;
|
||||
short m_AudioBuffer[CIRCULAR_BUFFER_SIZE * CIRCULAR_BUFFER_STRIDE];
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user