diff --git a/app/deploy/steamlink/moonlight.sh b/app/deploy/steamlink/moonlight.sh index 03145ac3..b182c7f1 100644 --- a/app/deploy/steamlink/moonlight.sh +++ b/app/deploy/steamlink/moonlight.sh @@ -5,5 +5,9 @@ # pairing data will be lost each reboot. HOME=/usr/local/moonlight +# Renice PE_Single_CPU which seems to host A/V stuff +renice -10 -p $(pidof PE_Single_CPU) + +# Renice Moonlight itself to avoid preemption by background tasks # Write output to a logfile in /tmp -exec ./bin/moonlight > /tmp/moonlight.log +exec nice -n -10 ./bin/moonlight > /tmp/moonlight.log diff --git a/app/streaming/audio/audio.cpp b/app/streaming/audio/audio.cpp index 887d24c0..a304efee 100644 --- a/app/streaming/audio/audio.cpp +++ b/app/streaming/audio/audio.cpp @@ -111,8 +111,11 @@ void Session::arDecodeAndPlaySample(char* sampleData, int sampleLength) { int samplesDecoded; - // Set this thread to high priority to reduce - // the chance of missing our sample delivery time +#ifndef STEAM_LINK + // Set this thread to high priority to reduce the chance of missing + // our sample delivery time. On Steam Link, this causes starvation + // of other threads due to severely restricted CPU time available, + // so we will skip it on that platform. if (s_ActiveSession->m_AudioSampleCount == 0) { if (SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH) < 0) { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, @@ -120,6 +123,7 @@ void Session::arDecodeAndPlaySample(char* sampleData, int sampleLength) SDL_GetError()); } } +#endif // See if we need to drop this sample if (s_ActiveSession->m_DropAudioEndTime != 0) { diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index e6358903..0abcfc00 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -49,7 +49,12 @@ AUDIO_RENDERER_CALLBACKS Session::k_AudioCallbacks = { nullptr, Session::arCleanup, Session::arDecodeAndPlaySample, - CAPABILITY_DIRECT_SUBMIT + CAPABILITY_DIRECT_SUBMIT | +#ifdef STEAM_LINK + CAPABILITY_SLOW_OPUS_DECODER +#else + 0 +#endif }; Session* Session::s_ActiveSession;