mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-18 14:40:56 +00:00
Migrate to the new audio configuration macros
This commit is contained in:
+4
-26
@@ -145,30 +145,6 @@ NvHTTP::getServerInfo(NvLogLevel logLevel, bool fastFail)
|
|||||||
return serverInfo;
|
return serverInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString
|
|
||||||
getSurroundAudioInfoString(int audioConfig)
|
|
||||||
{
|
|
||||||
int channelMask;
|
|
||||||
int channelCount;
|
|
||||||
|
|
||||||
switch (audioConfig)
|
|
||||||
{
|
|
||||||
case AUDIO_CONFIGURATION_STEREO:
|
|
||||||
channelCount = 2;
|
|
||||||
channelMask = 0x3;
|
|
||||||
break;
|
|
||||||
case AUDIO_CONFIGURATION_51_SURROUND:
|
|
||||||
channelCount = 6;
|
|
||||||
channelMask = 0xFC;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Q_ASSERT(false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return QString::number(channelMask << 16 | channelCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NvHTTP::launchApp(int appId,
|
NvHTTP::launchApp(int appId,
|
||||||
PSTREAM_CONFIGURATION streamConfig,
|
PSTREAM_CONFIGURATION streamConfig,
|
||||||
@@ -198,7 +174,8 @@ NvHTTP::launchApp(int appId,
|
|||||||
"&hdrMode=1&clientHdrCapVersion=0&clientHdrCapSupportedFlagsInUint32=0&clientHdrCapMetaDataId=NV_STATIC_METADATA_TYPE_1&clientHdrCapDisplayData=0x0x0x0x0x0x0x0x0x0x0" :
|
"&hdrMode=1&clientHdrCapVersion=0&clientHdrCapSupportedFlagsInUint32=0&clientHdrCapMetaDataId=NV_STATIC_METADATA_TYPE_1&clientHdrCapDisplayData=0x0x0x0x0x0x0x0x0x0x0" :
|
||||||
"")+
|
"")+
|
||||||
"&localAudioPlayMode="+QString::number(localAudio ? 1 : 0)+
|
"&localAudioPlayMode="+QString::number(localAudio ? 1 : 0)+
|
||||||
"&surroundAudioInfo="+getSurroundAudioInfoString(streamConfig->audioConfiguration)+
|
"&surroundAudioInfo="+QString::number(CHANNEL_MASK_FROM_AUDIO_CONFIGURATION(streamConfig->audioConfiguration) << 16 |
|
||||||
|
CHANNEL_COUNT_FROM_AUDIO_CONFIGURATION(streamConfig->audioConfiguration))+
|
||||||
"&remoteControllersBitmap="+QString::number(gamepadMask)+
|
"&remoteControllersBitmap="+QString::number(gamepadMask)+
|
||||||
"&gcmap="+QString::number(gamepadMask),
|
"&gcmap="+QString::number(gamepadMask),
|
||||||
LAUNCH_TIMEOUT_MS);
|
LAUNCH_TIMEOUT_MS);
|
||||||
@@ -220,7 +197,8 @@ NvHTTP::resumeApp(PSTREAM_CONFIGURATION streamConfig)
|
|||||||
"resume",
|
"resume",
|
||||||
"rikey="+QString(QByteArray(streamConfig->remoteInputAesKey, sizeof(streamConfig->remoteInputAesKey)).toHex())+
|
"rikey="+QString(QByteArray(streamConfig->remoteInputAesKey, sizeof(streamConfig->remoteInputAesKey)).toHex())+
|
||||||
"&rikeyid="+QString::number(riKeyId)+
|
"&rikeyid="+QString::number(riKeyId)+
|
||||||
"&surroundAudioInfo="+getSurroundAudioInfoString(streamConfig->audioConfiguration),
|
"&surroundAudioInfo="+QString::number(CHANNEL_MASK_FROM_AUDIO_CONFIGURATION(streamConfig->audioConfiguration) << 16 |
|
||||||
|
CHANNEL_COUNT_FROM_AUDIO_CONFIGURATION(streamConfig->audioConfiguration)),
|
||||||
RESUME_TIMEOUT_MS);
|
RESUME_TIMEOUT_MS);
|
||||||
|
|
||||||
// Throws if the request failed
|
// Throws if the request failed
|
||||||
|
|||||||
@@ -80,19 +80,7 @@ int Session::getAudioRendererCapabilities(int audioConfiguration)
|
|||||||
OPUS_MULTISTREAM_CONFIGURATION opusConfig = {};
|
OPUS_MULTISTREAM_CONFIGURATION opusConfig = {};
|
||||||
opusConfig.sampleRate = 48000;
|
opusConfig.sampleRate = 48000;
|
||||||
opusConfig.samplesPerFrame = 240;
|
opusConfig.samplesPerFrame = 240;
|
||||||
|
opusConfig.channelCount = CHANNEL_COUNT_FROM_AUDIO_CONFIGURATION(audioConfiguration);
|
||||||
switch (audioConfiguration)
|
|
||||||
{
|
|
||||||
case AUDIO_CONFIGURATION_STEREO:
|
|
||||||
opusConfig.channelCount = 2;
|
|
||||||
break;
|
|
||||||
case AUDIO_CONFIGURATION_51_SURROUND:
|
|
||||||
opusConfig.channelCount = 6;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
SDL_assert(false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
IAudioRenderer* audioRenderer = createAudioRenderer(&opusConfig);
|
IAudioRenderer* audioRenderer = createAudioRenderer(&opusConfig);
|
||||||
if (audioRenderer == nullptr) {
|
if (audioRenderer == nullptr) {
|
||||||
@@ -113,19 +101,7 @@ bool Session::testAudio(int audioConfiguration)
|
|||||||
OPUS_MULTISTREAM_CONFIGURATION opusConfig = {};
|
OPUS_MULTISTREAM_CONFIGURATION opusConfig = {};
|
||||||
opusConfig.sampleRate = 48000;
|
opusConfig.sampleRate = 48000;
|
||||||
opusConfig.samplesPerFrame = 240;
|
opusConfig.samplesPerFrame = 240;
|
||||||
|
opusConfig.channelCount = CHANNEL_COUNT_FROM_AUDIO_CONFIGURATION(audioConfiguration);
|
||||||
switch (audioConfiguration)
|
|
||||||
{
|
|
||||||
case AUDIO_CONFIGURATION_STEREO:
|
|
||||||
opusConfig.channelCount = 2;
|
|
||||||
break;
|
|
||||||
case AUDIO_CONFIGURATION_51_SURROUND:
|
|
||||||
opusConfig.channelCount = 6;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
SDL_assert(false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
IAudioRenderer* audioRenderer = createAudioRenderer(&opusConfig);
|
IAudioRenderer* audioRenderer = createAudioRenderer(&opusConfig);
|
||||||
if (audioRenderer == nullptr) {
|
if (audioRenderer == nullptr) {
|
||||||
|
|||||||
@@ -389,10 +389,10 @@ bool Session::initialize()
|
|||||||
switch (m_Preferences->audioConfig)
|
switch (m_Preferences->audioConfig)
|
||||||
{
|
{
|
||||||
case StreamingPreferences::AC_STEREO:
|
case StreamingPreferences::AC_STEREO:
|
||||||
m_StreamConfig.audioConfiguration = AUDIO_CONFIGURATION_STEREO;
|
m_StreamConfig.audioConfiguration = MAKE_AUDIO_CONFIGURATION(2, 0x3);
|
||||||
break;
|
break;
|
||||||
case StreamingPreferences::AC_51_SURROUND:
|
case StreamingPreferences::AC_51_SURROUND:
|
||||||
m_StreamConfig.audioConfiguration = AUDIO_CONFIGURATION_51_SURROUND;
|
m_StreamConfig.audioConfiguration = MAKE_AUDIO_CONFIGURATION(6, 0xFC);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -605,12 +605,14 @@ bool Session::validateLaunch(SDL_Window* testWindow)
|
|||||||
// Test if audio works at the specified audio configuration
|
// Test if audio works at the specified audio configuration
|
||||||
bool audioTestPassed = testAudio(m_StreamConfig.audioConfiguration);
|
bool audioTestPassed = testAudio(m_StreamConfig.audioConfiguration);
|
||||||
|
|
||||||
// Gracefully degrade to stereo if 5.1 doesn't work
|
// Gracefully degrade to stereo if surround sound doesn't work
|
||||||
if (!audioTestPassed && m_StreamConfig.audioConfiguration == AUDIO_CONFIGURATION_51_SURROUND) {
|
if (!audioTestPassed && CHANNEL_COUNT_FROM_AUDIO_CONFIGURATION(m_StreamConfig.audioConfiguration) > 2) {
|
||||||
audioTestPassed = testAudio(AUDIO_CONFIGURATION_STEREO);
|
int fallbackAudioConfig = MAKE_AUDIO_CONFIGURATION(2, 0x3);
|
||||||
|
|
||||||
|
audioTestPassed = testAudio(fallbackAudioConfig);
|
||||||
if (audioTestPassed) {
|
if (audioTestPassed) {
|
||||||
m_StreamConfig.audioConfiguration = AUDIO_CONFIGURATION_STEREO;
|
m_StreamConfig.audioConfiguration = fallbackAudioConfig;
|
||||||
emitLaunchWarning("5.1 surround sound is not supported by the current audio device.");
|
emitLaunchWarning("Your selected surround sound setting is not supported by the current audio device.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Submodule moonlight-common-c/moonlight-common-c updated: f489c9d725...607aaca93f
Reference in New Issue
Block a user