mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-06-17 14:21:30 +00:00
Increase audio packet duration for low bandwidth connections
This commit is contained in:
@@ -39,10 +39,14 @@ extern int AudioPacketDuration;
|
|||||||
|
|
||||||
#define UDP_RECV_POLL_TIMEOUT_MS 100
|
#define UDP_RECV_POLL_TIMEOUT_MS 100
|
||||||
|
|
||||||
// At this value, we will request high quality audio unless CAPABILITY_SLOW_OPUS_DECODER
|
// At this value or above, we will request high quality audio unless CAPABILITY_SLOW_OPUS_DECODER
|
||||||
// is set on the audio renderer.
|
// is set on the audio renderer.
|
||||||
#define HIGH_AUDIO_BITRATE_THRESHOLD 15000
|
#define HIGH_AUDIO_BITRATE_THRESHOLD 15000
|
||||||
|
|
||||||
|
// Below this value, we will request 20 ms audio frames to reduce bandwidth if the audio
|
||||||
|
// renderer sets CAPABILITY_SUPPORTS_ARBITRARY_AUDIO_DURATION.
|
||||||
|
#define LOW_AUDIO_BITRATE_TRESHOLD 5000
|
||||||
|
|
||||||
int serviceEnetHost(ENetHost* client, ENetEvent* event, enet_uint32 timeoutMs);
|
int serviceEnetHost(ENetHost* client, ENetEvent* event, enet_uint32 timeoutMs);
|
||||||
int extractVersionQuadFromString(const char* string, int* quad);
|
int extractVersionQuadFromString(const char* string, int* quad);
|
||||||
int isReferenceFrameInvalidationEnabled(void);
|
int isReferenceFrameInvalidationEnabled(void);
|
||||||
|
|||||||
@@ -176,6 +176,12 @@ typedef struct _DECODE_UNIT {
|
|||||||
// used with video streams above 15 Mbps.
|
// used with video streams above 15 Mbps.
|
||||||
#define CAPABILITY_SLOW_OPUS_DECODER 0x8
|
#define CAPABILITY_SLOW_OPUS_DECODER 0x8
|
||||||
|
|
||||||
|
// If set in the audio renderer capabilities field, this indicates that audio packets
|
||||||
|
// may contain more or less than 5 ms of audio. This requires that audio renderers read the
|
||||||
|
// samplesPerFrame field in OPUS_MULTISTREAM_CONFIGURATION to calculate the correct decoded
|
||||||
|
// buffer size rather than just assuming it will always be 240.
|
||||||
|
#define CAPABILITY_SUPPORTS_ARBITRARY_AUDIO_DURATION 0x10
|
||||||
|
|
||||||
// If set in the video renderer capabilities field, this macro specifies that the renderer
|
// If set in the video renderer capabilities field, this macro specifies that the renderer
|
||||||
// supports slicing to increase decoding performance. The parameter specifies the desired
|
// supports slicing to increase decoding performance. The parameter specifies the desired
|
||||||
// number of slices per frame. This capability is only valid on video renderers.
|
// number of slices per frame. This capability is only valid on video renderers.
|
||||||
|
|||||||
+3
-1
@@ -377,7 +377,9 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) {
|
|||||||
err |= addAttributeString(&optionHead, "x-nv-audio.surround.AudioQuality", "0");
|
err |= addAttributeString(&optionHead, "x-nv-audio.surround.AudioQuality", "0");
|
||||||
HighQualitySurroundEnabled = 0;
|
HighQualitySurroundEnabled = 0;
|
||||||
|
|
||||||
if ((AudioCallbacks.capabilities & CAPABILITY_SLOW_OPUS_DECODER) == 0) {
|
if ((AudioCallbacks.capabilities & CAPABILITY_SLOW_OPUS_DECODER) != 0 ||
|
||||||
|
((AudioCallbacks.capabilities & CAPABILITY_SUPPORTS_ARBITRARY_AUDIO_DURATION) != 0 &&
|
||||||
|
OriginalVideoBitrate >= LOW_AUDIO_BITRATE_TRESHOLD)) {
|
||||||
// Use 5 ms packets by default for lowest latency
|
// Use 5 ms packets by default for lowest latency
|
||||||
AudioPacketDuration = 5;
|
AudioPacketDuration = 5;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user