Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions src/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,15 +357,33 @@ float CChannel::GetPan ( const int iChanID )
}
}

void CChannel::ResetInfo()
{
QMutexLocker locker ( &Mutex );

bIsIdentified = false;
ChannelInfo = CChannelCoreInfo();
}

void CChannel::SetChanInfo ( const CChannelCoreInfo& NChanInf )
{
// apply value (if a new channel or different from previous one)
if ( !bIsIdentified || ChannelInfo != NChanInf )
bool bChanged = false;

{
bIsIdentified = true; // Indicate we have received channel info
QMutexLocker locker ( &Mutex );

ChannelInfo = NChanInf;
// apply value (if a new channel or different from previous one)
if ( !bIsIdentified || ChannelInfo != NChanInf )
{
bIsIdentified = true; // Indicate we have received channel info

ChannelInfo = NChanInf;
bChanged = true;
}
}

if ( bChanged )
{
// fire message that the channel info has changed
emit ChanInfoHasChanged();
}
Expand All @@ -380,6 +398,15 @@ QString CChannel::GetName()
return ChannelInfo.strName;
}

CChannelCoreInfo CChannel::GetChanInfo()
{
// make sure the struct is not written at the same time when it is
// read here -> use mutex to secure access
QMutexLocker locker ( &Mutex );

return ChannelInfo;
}

void CChannel::OnSendProtMessage ( CVector<uint8_t> vecMessage )
{
// only send messages if protocol is enabled, otherwise delete complete
Expand Down
14 changes: 5 additions & 9 deletions src/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,10 @@ class CChannel : public QObject
void SetAddress ( const CHostAddress& NAddr ) { InetAddr = NAddr; }
const CHostAddress& GetAddress() const { return InetAddr; }

void ResetInfo()
{
bIsIdentified = false;
ChannelInfo = CChannelCoreInfo();
} // reset does not emit a message
QString GetName();
void SetChanInfo ( const CChannelCoreInfo& NChanInf );
CChannelCoreInfo& GetChanInfo() { return ChannelInfo; }
void ResetInfo(); // reset does not emit a message
QString GetName();
void SetChanInfo ( const CChannelCoreInfo& NChanInf );
CChannelCoreInfo GetChanInfo();
Comment thread
softins marked this conversation as resolved.

void SetRemoteInfo ( const CChannelCoreInfo ChInfo ) { Protocol.CreateChanInfoMes ( ChInfo ); }

Expand Down Expand Up @@ -239,7 +235,7 @@ class CChannel : public QObject

std::atomic<bool> bIsEnabled;
bool bIsServer;
bool bIsIdentified;
std::atomic<bool> bIsIdentified;

int iNetwFrameSizeFact;
int iNetwFrameSize;
Expand Down
Loading