mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-18 14:40:56 +00:00
Improve low bandwidth audio performance for SDL and SLAudio and fix RTSP issues with broken PMTUD
This commit is contained in:
@@ -21,6 +21,5 @@ public:
|
|||||||
private:
|
private:
|
||||||
SDL_AudioDeviceID m_AudioDevice;
|
SDL_AudioDeviceID m_AudioDevice;
|
||||||
void* m_AudioBuffer;
|
void* m_AudioBuffer;
|
||||||
int m_FrameDurationMs;
|
|
||||||
int m_FrameSize;
|
int m_FrameSize;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ bool SdlAudioRenderer::prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATION*
|
|||||||
want.samples = opusConfig->samplesPerFrame;
|
want.samples = opusConfig->samplesPerFrame;
|
||||||
|
|
||||||
m_FrameSize = opusConfig->samplesPerFrame * sizeof(short) * opusConfig->channelCount;
|
m_FrameSize = opusConfig->samplesPerFrame * sizeof(short) * opusConfig->channelCount;
|
||||||
m_FrameDurationMs = opusConfig->samplesPerFrame / 48;
|
|
||||||
|
|
||||||
m_AudioDevice = SDL_OpenAudioDevice(NULL, 0, &want, &have, 0);
|
m_AudioDevice = SDL_OpenAudioDevice(NULL, 0, &want, &have, 0);
|
||||||
if (m_AudioDevice == 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
|
// Don't queue if there's already more than 30 ms of audio data waiting
|
||||||
// in Moonlight's audio queue.
|
// in Moonlight's audio queue.
|
||||||
if (LiGetPendingAudioFrames() * m_FrameDurationMs > 30) {
|
if (LiGetPendingAudioDuration() > 30) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,6 +117,6 @@ bool SdlAudioRenderer::submitAudio(int bytesWritten)
|
|||||||
|
|
||||||
int SdlAudioRenderer::getCapabilities()
|
int SdlAudioRenderer::getCapabilities()
|
||||||
{
|
{
|
||||||
// Direct submit can't be used because we use LiGetPendingAudioFrames()
|
// Direct submit can't be used because we use LiGetPendingAudioDuration()
|
||||||
return 0;
|
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.
|
// it's hard to avoid since we get crushed by CPU limitations.
|
||||||
m_MaxQueuedAudioMs = 40 * opusConfig->channelCount / 2;
|
m_MaxQueuedAudioMs = 40 * opusConfig->channelCount / 2;
|
||||||
|
|
||||||
m_FrameDuration = opusConfig->samplesPerFrame / 48;
|
|
||||||
m_AudioBufferSize = opusConfig->samplesPerFrame * sizeof(short) * opusConfig->channelCount;
|
m_AudioBufferSize = opusConfig->samplesPerFrame * sizeof(short) * opusConfig->channelCount;
|
||||||
m_AudioStream = SLAudio_CreateStream(m_AudioContext,
|
m_AudioStream = SLAudio_CreateStream(m_AudioContext,
|
||||||
opusConfig->sampleRate,
|
opusConfig->sampleRate,
|
||||||
@@ -37,8 +36,8 @@ bool SLAudioRenderer::prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATION* o
|
|||||||
}
|
}
|
||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Using SLAudio renderer with %d ms frames",
|
"Using SLAudio renderer with %d samples per frame",
|
||||||
m_FrameDuration);
|
opusConfig->samplesPerFrame);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -100,7 +99,7 @@ bool SLAudioRenderer::submitAudio(int bytesWritten)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LiGetPendingAudioFrames() * m_FrameDuration < m_MaxQueuedAudioMs) {
|
if (LiGetPendingAudioDuration() < m_MaxQueuedAudioMs) {
|
||||||
SLAudio_SubmitFrame(m_AudioStream);
|
SLAudio_SubmitFrame(m_AudioStream);
|
||||||
m_AudioBuffer = nullptr;
|
m_AudioBuffer = nullptr;
|
||||||
}
|
}
|
||||||
@@ -115,7 +114,7 @@ bool SLAudioRenderer::submitAudio(int bytesWritten)
|
|||||||
|
|
||||||
int SLAudioRenderer::getCapabilities()
|
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)
|
void SLAudioRenderer::slLogCallback(void*, ESLAudioLog logLevel, const char *message)
|
||||||
|
|||||||
@@ -28,6 +28,5 @@ private:
|
|||||||
|
|
||||||
void* m_AudioBuffer;
|
void* m_AudioBuffer;
|
||||||
int m_AudioBufferSize;
|
int m_AudioBufferSize;
|
||||||
int m_FrameDuration;
|
|
||||||
int m_MaxQueuedAudioMs;
|
int m_MaxQueuedAudioMs;
|
||||||
};
|
};
|
||||||
|
|||||||
Submodule moonlight-common-c/moonlight-common-c updated: f4dad9ae8b...c1a26618d4
Reference in New Issue
Block a user