mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2024-12-14 05:12:27 +00:00
Avoid calling Pa_IsStreamStopped() on each audio frame
This commit is contained in:
parent
76387aacad
commit
1ad072236d
2 changed files with 6 additions and 2 deletions
|
@ -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];
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue