mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-04-06 15:56:19 +00:00
Perform a graceful disconnection if the termination was locally initiated
This commit is contained in:
@@ -24,6 +24,7 @@ OPUS_MULTISTREAM_CONFIGURATION HighQualityOpusConfig;
|
||||
int OriginalVideoBitrate;
|
||||
int AudioPacketDuration;
|
||||
bool AudioEncryptionEnabled;
|
||||
bool UserRequestedTermination;
|
||||
|
||||
// Connection stages
|
||||
static const char* stageNames[STAGE_MAX] = {
|
||||
@@ -55,6 +56,12 @@ void LiInterruptConnection(void) {
|
||||
|
||||
// Stop the connection by undoing the step at the current stage and those before it
|
||||
void LiStopConnection(void) {
|
||||
// If this was a fully complete connection and we haven't started any termination
|
||||
// logic prior to this point, this termination is user requested.
|
||||
if (stage == STAGE_MAX - 1 && !alreadyTerminated) {
|
||||
UserRequestedTermination = true;
|
||||
}
|
||||
|
||||
// Disable termination callbacks now
|
||||
alreadyTerminated = true;
|
||||
|
||||
@@ -190,6 +197,10 @@ int LiStartConnection(PSERVER_INFORMATION serverInfo, PSTREAM_CONFIGURATION stre
|
||||
memcpy(&StreamConfig, streamConfig, sizeof(StreamConfig));
|
||||
OriginalVideoBitrate = streamConfig->bitrate;
|
||||
RemoteAddrString = strdup(serverInfo->address);
|
||||
|
||||
alreadyTerminated = false;
|
||||
ConnectionInterrupted = false;
|
||||
UserRequestedTermination = false;
|
||||
|
||||
// Validate the audio configuration
|
||||
if (MAGIC_BYTE_FROM_AUDIO_CONFIG(StreamConfig.audioConfiguration) != 0xCA ||
|
||||
@@ -245,9 +256,6 @@ int LiStartConnection(PSERVER_INFORMATION serverInfo, PSTREAM_CONFIGURATION stre
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
alreadyTerminated = false;
|
||||
ConnectionInterrupted = false;
|
||||
|
||||
Limelog("Initializing platform...");
|
||||
ListenerCallbacks.stageStarting(STAGE_PLATFORM_INIT);
|
||||
err = initializePlatform();
|
||||
|
||||
Reference in New Issue
Block a user