@@ -508,23 +508,28 @@ void CChannel::Disconnect()
508508 // we only have to disconnect the channel if it is actually connected
509509 if ( IsConnected () )
510510 {
511- // for a Client, block further audio data and disable the channel as soon as Disconnect() is called
512- // TODO: Add reasoning from #2550
513-
514- bDisconnectAndDisable = !bIsServer;
515-
516511 // set time out counter to a small value > 0 so that the next time a
517512 // received audio block is queried, the disconnection is performed
518513 // (assuming that no audio packet is received in the meantime)
519514 iConTimeOut = 1 ; // a small number > 0
520515 }
521- else if ( !bIsServer )
516+
517+ if ( !bIsServer )
522518 {
523- // For clients (?) set defaults
519+ if ( IsConnected () )
520+ {
521+ // for a Client, block further audio data and disable the channel as soon as Disconnect() is called
522+ // TODO: Add reasoning from #2550
523+ bDisconnectAndDisable = true ;
524+ }
525+ else
526+ {
527+ // For disconnected clients set defaults
524528
525- bDisconnectAndDisable = false ;
526- bIsEnabled = false ;
527- iConTimeOut = 0 ;
529+ bDisconnectAndDisable = false ;
530+ bIsEnabled = false ;
531+ iConTimeOut = 0 ;
532+ }
528533 }
529534}
530535
@@ -547,9 +552,9 @@ EPutDataStat CChannel::PutAudioData ( const CVector<uint8_t>& vecbyData, const i
547552 EPutDataStat eRet = PS_GEN_ERROR;
548553
549554 // Only process audio data if:
550- // - for client only: the packet comes from the server we want to talk to
555+ // - for client only: the packet comes from the server we want to talk to and we aren't disconnecting
551556 // - the channel is enabled
552- if ( ( bIsServer || ( GetAddress () == RecHostAddr ) ) && IsEnabled () && !bDisconnectAndDisable )
557+ if ( ( bIsServer || ( !bIsServer && GetAddress () == RecHostAddr && !bDisconnectAndDisable ) ) && IsEnabled () )
553558 {
554559 MutexSocketBuf.lock ();
555560 {
@@ -637,7 +642,7 @@ EGetDataStat CChannel::GetData ( CVector<uint8_t>& vecbyData, const int iNumByte
637642 eGetStatus = GS_CHAN_NOW_DISCONNECTED;
638643 iConTimeOut = 0 ; // make sure we do not have negative values
639644
640- if ( bDisconnectAndDisable )
645+ if ( bDisconnectAndDisable && !bIsServer )
641646 {
642647 bDisconnectAndDisable = false ;
643648 bIsEnabled = false ;
@@ -664,7 +669,7 @@ EGetDataStat CChannel::GetData ( CVector<uint8_t>& vecbyData, const int iNumByte
664669 // channel is disconnected
665670 eGetStatus = GS_CHAN_NOT_CONNECTED;
666671
667- if ( bDisconnectAndDisable )
672+ if ( bDisconnectAndDisable && !bIsServer )
668673 {
669674 bDisconnectAndDisable = false ;
670675 bIsEnabled = false ;
0 commit comments