File tree Expand file tree Collapse file tree
app/streaming/audio/renderers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,5 +21,6 @@ class SdlAudioRenderer : public IAudioRenderer
2121private:
2222 SDL_AudioDeviceID m_AudioDevice;
2323 void * m_AudioBuffer;
24- int m_FrameSize;
24+ Uint32 m_FrameSize;
25+ Uint32 m_FrameDurationMs;
2526};
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ bool SdlAudioRenderer::prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATION*
3232 // The buffering helps avoid audio underruns due to network jitter.
3333 want.samples = SDL_max (480 , opusConfig->samplesPerFrame * 3 );
3434
35+ m_FrameDurationMs = opusConfig->samplesPerFrame / (opusConfig->sampleRate / 1000 );
3536 m_FrameSize = opusConfig->samplesPerFrame *
3637 opusConfig->channelCount *
3738 getAudioBufferSampleSize ();
@@ -115,8 +116,8 @@ bool SdlAudioRenderer::submitAudio(int bytesWritten)
115116 return false ;
116117 }
117118
118- // Only queue more samples where there are 10 frames or less in SDL's queue
119- if (SDL_GetQueuedAudioSize (m_AudioDevice) / m_FrameSize <= 10 ) {
119+ // Only queue more samples where there is 50 ms or less in SDL's queue
120+ if (SDL_GetQueuedAudioSize (m_AudioDevice) / m_FrameSize * m_FrameDurationMs <= 50 ) {
120121 break ;
121122 }
122123
You can’t perform that action at this time.
0 commit comments