mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-01 23:35:55 +00:00
Allow audio renderers to specify capabilities
This commit is contained in:
parent
212ed33b21
commit
01254f67f0
@ -28,6 +28,22 @@ IAudioRenderer* Session::createAudioRenderer()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Session::getAudioRendererCapabilities()
|
||||||
|
{
|
||||||
|
IAudioRenderer* audioRenderer;
|
||||||
|
|
||||||
|
audioRenderer = createAudioRenderer();
|
||||||
|
if (audioRenderer == nullptr) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int caps = audioRenderer->getCapabilities();
|
||||||
|
|
||||||
|
delete audioRenderer;
|
||||||
|
|
||||||
|
return caps;
|
||||||
|
}
|
||||||
|
|
||||||
bool Session::testAudio(int audioConfiguration)
|
bool Session::testAudio(int audioConfiguration)
|
||||||
{
|
{
|
||||||
IAudioRenderer* audioRenderer;
|
IAudioRenderer* audioRenderer;
|
||||||
|
@ -13,4 +13,6 @@ public:
|
|||||||
|
|
||||||
// Return false if an unrecoverable error has occurred and the renderer must be reinitialized
|
// Return false if an unrecoverable error has occurred and the renderer must be reinitialized
|
||||||
virtual bool submitAudio(int bytesWritten) = 0;
|
virtual bool submitAudio(int bytesWritten) = 0;
|
||||||
|
|
||||||
|
virtual int getCapabilities() = 0;
|
||||||
};
|
};
|
||||||
|
@ -16,6 +16,8 @@ public:
|
|||||||
|
|
||||||
virtual bool submitAudio(int bytesWritten);
|
virtual bool submitAudio(int bytesWritten);
|
||||||
|
|
||||||
|
virtual int getCapabilities();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SDL_AudioDeviceID m_AudioDevice;
|
SDL_AudioDeviceID m_AudioDevice;
|
||||||
void* m_AudioBuffer;
|
void* m_AudioBuffer;
|
||||||
|
@ -100,3 +100,8 @@ bool SdlAudioRenderer::submitAudio(int bytesWritten)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SdlAudioRenderer::getCapabilities()
|
||||||
|
{
|
||||||
|
return CAPABILITY_DIRECT_SUBMIT;
|
||||||
|
}
|
||||||
|
@ -90,6 +90,11 @@ bool SLAudioRenderer::submitAudio(int bytesWritten)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SLAudioRenderer::getCapabilities()
|
||||||
|
{
|
||||||
|
return CAPABILITY_SLOW_OPUS_DECODER;
|
||||||
|
}
|
||||||
|
|
||||||
void SLAudioRenderer::slLogCallback(void*, ESLAudioLog logLevel, const char *message)
|
void SLAudioRenderer::slLogCallback(void*, ESLAudioLog logLevel, const char *message)
|
||||||
{
|
{
|
||||||
SDL_LogPriority priority;
|
SDL_LogPriority priority;
|
||||||
|
@ -16,6 +16,8 @@ public:
|
|||||||
|
|
||||||
virtual bool submitAudio(int bytesWritten);
|
virtual bool submitAudio(int bytesWritten);
|
||||||
|
|
||||||
|
virtual int getCapabilities();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void slLogCallback(void* context, ESLAudioLog logLevel, const char* message);
|
static void slLogCallback(void* context, ESLAudioLog logLevel, const char* message);
|
||||||
|
|
||||||
|
@ -317,6 +317,11 @@ bool SoundIoAudioRenderer::submitAudio(int bytesWritten)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SoundIoAudioRenderer::getCapabilities()
|
||||||
|
{
|
||||||
|
return CAPABILITY_DIRECT_SUBMIT;
|
||||||
|
}
|
||||||
|
|
||||||
void SoundIoAudioRenderer::sioErrorCallback(SoundIoOutStream* stream, int err)
|
void SoundIoAudioRenderer::sioErrorCallback(SoundIoOutStream* stream, int err)
|
||||||
{
|
{
|
||||||
auto me = reinterpret_cast<SoundIoAudioRenderer*>(stream->userdata);
|
auto me = reinterpret_cast<SoundIoAudioRenderer*>(stream->userdata);
|
||||||
|
@ -17,6 +17,8 @@ public:
|
|||||||
|
|
||||||
virtual bool submitAudio(int bytesWritten);
|
virtual bool submitAudio(int bytesWritten);
|
||||||
|
|
||||||
|
virtual int getCapabilities();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int scoreChannelLayout(const struct SoundIoChannelLayout* layout, const OPUS_MULTISTREAM_CONFIGURATION* opusConfig);
|
int scoreChannelLayout(const struct SoundIoChannelLayout* layout, const OPUS_MULTISTREAM_CONFIGURATION* opusConfig);
|
||||||
|
|
||||||
|
@ -43,22 +43,6 @@ CONNECTION_LISTENER_CALLBACKS Session::k_ConnCallbacks = {
|
|||||||
Session::clConnectionStatusUpdate
|
Session::clConnectionStatusUpdate
|
||||||
};
|
};
|
||||||
|
|
||||||
AUDIO_RENDERER_CALLBACKS Session::k_AudioCallbacks = {
|
|
||||||
Session::arInit,
|
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
Session::arCleanup,
|
|
||||||
Session::arDecodeAndPlaySample,
|
|
||||||
#ifndef STEAM_LINK
|
|
||||||
CAPABILITY_DIRECT_SUBMIT
|
|
||||||
#else
|
|
||||||
// We cannot use direct submit for Steam Link because the
|
|
||||||
// SLAudio renderer needs to look at the audio backlog to
|
|
||||||
// cap latency since playback is a blocking operation.
|
|
||||||
CAPABILITY_SLOW_OPUS_DECODER
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
Session* Session::s_ActiveSession;
|
Session* Session::s_ActiveSession;
|
||||||
QSemaphore Session::s_ActiveSessionSemaphore(1);
|
QSemaphore Session::s_ActiveSessionSemaphore(1);
|
||||||
|
|
||||||
@ -365,6 +349,12 @@ bool Session::initialize()
|
|||||||
"Encoder configured for %d slices per frame",
|
"Encoder configured for %d slices per frame",
|
||||||
slices);
|
slices);
|
||||||
|
|
||||||
|
LiInitializeAudioCallbacks(&m_AudioCallbacks);
|
||||||
|
m_AudioCallbacks.init = arInit;
|
||||||
|
m_AudioCallbacks.cleanup = arCleanup;
|
||||||
|
m_AudioCallbacks.decodeAndPlaySample = arDecodeAndPlaySample;
|
||||||
|
m_AudioCallbacks.capabilities = getAudioRendererCapabilities();
|
||||||
|
|
||||||
LiInitializeStreamConfiguration(&m_StreamConfig);
|
LiInitializeStreamConfiguration(&m_StreamConfig);
|
||||||
m_StreamConfig.width = m_Preferences->width;
|
m_StreamConfig.width = m_Preferences->width;
|
||||||
m_StreamConfig.height = m_Preferences->height;
|
m_StreamConfig.height = m_Preferences->height;
|
||||||
@ -948,7 +938,7 @@ void Session::exec(int displayOriginX, int displayOriginY)
|
|||||||
|
|
||||||
int err = LiStartConnection(&hostInfo, &m_StreamConfig, &k_ConnCallbacks,
|
int err = LiStartConnection(&hostInfo, &m_StreamConfig, &k_ConnCallbacks,
|
||||||
&m_VideoCallbacks,
|
&m_VideoCallbacks,
|
||||||
m_AudioDisabled ? nullptr : &k_AudioCallbacks,
|
m_AudioDisabled ? nullptr : &m_AudioCallbacks,
|
||||||
NULL, 0, NULL, 0);
|
NULL, 0, NULL, 0);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
// We already displayed an error dialog in the stage failure
|
// We already displayed an error dialog in the stage failure
|
||||||
|
@ -72,6 +72,8 @@ private:
|
|||||||
|
|
||||||
bool testAudio(int audioConfiguration);
|
bool testAudio(int audioConfiguration);
|
||||||
|
|
||||||
|
int getAudioRendererCapabilities();
|
||||||
|
|
||||||
void getWindowDimensions(int& x, int& y,
|
void getWindowDimensions(int& x, int& y,
|
||||||
int& width, int& height);
|
int& width, int& height);
|
||||||
|
|
||||||
@ -129,6 +131,7 @@ private:
|
|||||||
StreamingPreferences* m_Preferences;
|
StreamingPreferences* m_Preferences;
|
||||||
STREAM_CONFIGURATION m_StreamConfig;
|
STREAM_CONFIGURATION m_StreamConfig;
|
||||||
DECODER_RENDERER_CALLBACKS m_VideoCallbacks;
|
DECODER_RENDERER_CALLBACKS m_VideoCallbacks;
|
||||||
|
AUDIO_RENDERER_CALLBACKS m_AudioCallbacks;
|
||||||
NvComputer* m_Computer;
|
NvComputer* m_Computer;
|
||||||
NvApp m_App;
|
NvApp m_App;
|
||||||
SDL_Window* m_Window;
|
SDL_Window* m_Window;
|
||||||
@ -158,7 +161,6 @@ private:
|
|||||||
|
|
||||||
Overlay::OverlayManager m_OverlayManager;
|
Overlay::OverlayManager m_OverlayManager;
|
||||||
|
|
||||||
static AUDIO_RENDERER_CALLBACKS k_AudioCallbacks;
|
|
||||||
static CONNECTION_LISTENER_CALLBACKS k_ConnCallbacks;
|
static CONNECTION_LISTENER_CALLBACKS k_ConnCallbacks;
|
||||||
static Session* s_ActiveSession;
|
static Session* s_ActiveSession;
|
||||||
static QSemaphore s_ActiveSessionSemaphore;
|
static QSemaphore s_ActiveSessionSemaphore;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user