mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-18 01:15:46 +00:00
Fix high-quality surround sound breaking audio when streaming over the Internet or IPv6
This commit is contained in:
parent
c322ed9437
commit
a9780361a3
@ -319,11 +319,13 @@ int startAudioStream(void* audioContext, int arFlags) {
|
|||||||
int err;
|
int err;
|
||||||
OPUS_MULTISTREAM_CONFIGURATION chosenConfig;
|
OPUS_MULTISTREAM_CONFIGURATION chosenConfig;
|
||||||
|
|
||||||
|
// TODO: Get these from RTSP ANNOUNCE surround-params
|
||||||
if (StreamConfig.audioConfiguration == AUDIO_CONFIGURATION_STEREO) {
|
if (StreamConfig.audioConfiguration == AUDIO_CONFIGURATION_STEREO) {
|
||||||
chosenConfig = opusStereoConfig;
|
chosenConfig = opusStereoConfig;
|
||||||
}
|
}
|
||||||
else if (StreamConfig.audioConfiguration == AUDIO_CONFIGURATION_51_SURROUND) {
|
else if (StreamConfig.audioConfiguration == AUDIO_CONFIGURATION_51_SURROUND) {
|
||||||
if (HighQualitySurroundEnabled) {
|
if (HighQualitySurroundEnabled) {
|
||||||
|
LC_ASSERT(HighQualitySurroundSupported);
|
||||||
chosenConfig = opus51HighSurroundConfig;
|
chosenConfig = opus51HighSurroundConfig;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -18,6 +18,7 @@ DECODER_RENDERER_CALLBACKS VideoCallbacks;
|
|||||||
AUDIO_RENDERER_CALLBACKS AudioCallbacks;
|
AUDIO_RENDERER_CALLBACKS AudioCallbacks;
|
||||||
int NegotiatedVideoFormat;
|
int NegotiatedVideoFormat;
|
||||||
volatile int ConnectionInterrupted;
|
volatile int ConnectionInterrupted;
|
||||||
|
int HighQualitySurroundSupported;
|
||||||
int HighQualitySurroundEnabled;
|
int HighQualitySurroundEnabled;
|
||||||
int OriginalVideoBitrate;
|
int OriginalVideoBitrate;
|
||||||
int AudioPacketDuration;
|
int AudioPacketDuration;
|
||||||
|
@ -20,6 +20,7 @@ extern DECODER_RENDERER_CALLBACKS VideoCallbacks;
|
|||||||
extern AUDIO_RENDERER_CALLBACKS AudioCallbacks;
|
extern AUDIO_RENDERER_CALLBACKS AudioCallbacks;
|
||||||
extern int NegotiatedVideoFormat;
|
extern int NegotiatedVideoFormat;
|
||||||
extern volatile int ConnectionInterrupted;
|
extern volatile int ConnectionInterrupted;
|
||||||
|
extern int HighQualitySurroundSupported;
|
||||||
extern int HighQualitySurroundEnabled;
|
extern int HighQualitySurroundEnabled;
|
||||||
extern int OriginalVideoBitrate;
|
extern int OriginalVideoBitrate;
|
||||||
extern int AudioPacketDuration;
|
extern int AudioPacketDuration;
|
||||||
|
@ -566,6 +566,15 @@ int performRtspHandshake(void) {
|
|||||||
NegotiatedVideoFormat = VIDEO_FORMAT_H264;
|
NegotiatedVideoFormat = VIDEO_FORMAT_H264;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if high bitrate surround sound is available before attempting to request it.
|
||||||
|
// TODO: Parse these surround-params so we can get rid of our hardcoded Opus mappings
|
||||||
|
if (strstr(response.payload, "surround-params=660")) {
|
||||||
|
HighQualitySurroundSupported = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
HighQualitySurroundSupported = 0;
|
||||||
|
}
|
||||||
|
|
||||||
freeMessage(&response);
|
freeMessage(&response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,7 +362,7 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) {
|
|||||||
if (AppVersionQuad[0] >= 7) {
|
if (AppVersionQuad[0] >= 7) {
|
||||||
// Decide to use HQ audio based on the original video bitrate, not the HEVC-adjusted value
|
// Decide to use HQ audio based on the original video bitrate, not the HEVC-adjusted value
|
||||||
if (OriginalVideoBitrate >= HIGH_AUDIO_BITRATE_THRESHOLD && audioChannelCount > 2 &&
|
if (OriginalVideoBitrate >= HIGH_AUDIO_BITRATE_THRESHOLD && audioChannelCount > 2 &&
|
||||||
(AudioCallbacks.capabilities & CAPABILITY_SLOW_OPUS_DECODER) == 0) {
|
HighQualitySurroundSupported && (AudioCallbacks.capabilities & CAPABILITY_SLOW_OPUS_DECODER) == 0) {
|
||||||
// Enable high quality mode for surround sound
|
// Enable high quality mode for surround sound
|
||||||
err |= addAttributeString(&optionHead, "x-nv-audio.surround.AudioQuality", "1");
|
err |= addAttributeString(&optionHead, "x-nv-audio.surround.AudioQuality", "1");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user