Improve low bandwidth audio performance for SDL and SLAudio and fix RTSP issues with broken PMTUD
This commit is contained in:
parent
7e5a3925b3
commit
5700272dc4
5 changed files with 8 additions and 12 deletions
|
|
@ -21,6 +21,5 @@ public:
|
|||
private:
|
||||
SDL_AudioDeviceID m_AudioDevice;
|
||||
void* m_AudioBuffer;
|
||||
int m_FrameDurationMs;
|
||||
int m_FrameSize;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ bool SdlAudioRenderer::prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATION*
|
|||
want.samples = opusConfig->samplesPerFrame;
|
||||
|
||||
m_FrameSize = opusConfig->samplesPerFrame * sizeof(short) * opusConfig->channelCount;
|
||||
m_FrameDurationMs = opusConfig->samplesPerFrame / 48;
|
||||
|
||||
m_AudioDevice = SDL_OpenAudioDevice(NULL, 0, &want, &have, 0);
|
||||
if (m_AudioDevice == 0) {
|
||||
|
|
@ -97,7 +96,7 @@ bool SdlAudioRenderer::submitAudio(int bytesWritten)
|
|||
|
||||
// Don't queue if there's already more than 30 ms of audio data waiting
|
||||
// in Moonlight's audio queue.
|
||||
if (LiGetPendingAudioFrames() * m_FrameDurationMs > 30) {
|
||||
if (LiGetPendingAudioDuration() > 30) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -118,6 +117,6 @@ bool SdlAudioRenderer::submitAudio(int bytesWritten)
|
|||
|
||||
int SdlAudioRenderer::getCapabilities()
|
||||
{
|
||||
// Direct submit can't be used because we use LiGetPendingAudioFrames()
|
||||
return 0;
|
||||
// Direct submit can't be used because we use LiGetPendingAudioDuration()
|
||||
return CAPABILITY_SUPPORTS_ARBITRARY_AUDIO_DURATION;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ bool SLAudioRenderer::prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATION* o
|
|||
// it's hard to avoid since we get crushed by CPU limitations.
|
||||
m_MaxQueuedAudioMs = 40 * opusConfig->channelCount / 2;
|
||||
|
||||
m_FrameDuration = opusConfig->samplesPerFrame / 48;
|
||||
m_AudioBufferSize = opusConfig->samplesPerFrame * sizeof(short) * opusConfig->channelCount;
|
||||
m_AudioStream = SLAudio_CreateStream(m_AudioContext,
|
||||
opusConfig->sampleRate,
|
||||
|
|
@ -37,8 +36,8 @@ bool SLAudioRenderer::prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATION* o
|
|||
}
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Using SLAudio renderer with %d ms frames",
|
||||
m_FrameDuration);
|
||||
"Using SLAudio renderer with %d samples per frame",
|
||||
opusConfig->samplesPerFrame);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -100,7 +99,7 @@ bool SLAudioRenderer::submitAudio(int bytesWritten)
|
|||
return true;
|
||||
}
|
||||
|
||||
if (LiGetPendingAudioFrames() * m_FrameDuration < m_MaxQueuedAudioMs) {
|
||||
if (LiGetPendingAudioDuration() < m_MaxQueuedAudioMs) {
|
||||
SLAudio_SubmitFrame(m_AudioStream);
|
||||
m_AudioBuffer = nullptr;
|
||||
}
|
||||
|
|
@ -115,7 +114,7 @@ bool SLAudioRenderer::submitAudio(int bytesWritten)
|
|||
|
||||
int SLAudioRenderer::getCapabilities()
|
||||
{
|
||||
return CAPABILITY_SLOW_OPUS_DECODER;
|
||||
return CAPABILITY_SLOW_OPUS_DECODER | CAPABILITY_SUPPORTS_ARBITRARY_AUDIO_DURATION;
|
||||
}
|
||||
|
||||
void SLAudioRenderer::slLogCallback(void*, ESLAudioLog logLevel, const char *message)
|
||||
|
|
|
|||
|
|
@ -28,6 +28,5 @@ private:
|
|||
|
||||
void* m_AudioBuffer;
|
||||
int m_AudioBufferSize;
|
||||
int m_FrameDuration;
|
||||
int m_MaxQueuedAudioMs;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit f4dad9ae8bca90aada76c9bb858e4eea0fff5b76
|
||||
Subproject commit c1a26618d48d436657e47bcd38c2487d318c9fa0
|
||||
Loading…
Add table
Add a link
Reference in a new issue