2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-01 23:15:59 +00:00

up to 64 realtime combinated interfaces

This commit is contained in:
John Preston
2016-01-25 18:18:07 +03:00
parent c8d7d23ee6
commit a677f784f5
5 changed files with 216 additions and 70 deletions

View File

@@ -34,6 +34,39 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
#include "audio.h"
#include "localstorage.h"
class InterfacesMetadatasMap : public QMap<uint64, InterfacesMetadata*> {
public:
~InterfacesMetadatasMap() {
for (const_iterator i = cbegin(), e = cend(); i != e; ++i) {
delete i.value();
}
}
};
const InterfacesMetadata *GetInterfacesMetadata(uint64 mask) {
typedef QMap<uint64, InterfacesMetadata*> InterfacesMetadatasMap;
static InterfacesMetadatasMap InterfacesMetadatas;
static QMutex InterfacesMetadatasMutex;
QMutexLocker lock(&InterfacesMetadatasMutex);
InterfacesMetadatasMap::const_iterator i = InterfacesMetadatas.constFind(mask);
if (i == InterfacesMetadatas.cend()) {
InterfacesMetadata *meta = new InterfacesMetadata(mask);
if (!meta) { // terminate if we can't allocate memory
throw "Can't allocate memory!";
}
i = InterfacesMetadatas.insert(mask, meta);
}
return i.value();
}
InterfaceWrapStruct InterfaceWraps[64] = {
{ 0, 0, 0 }
};
QAtomicInt InterfaceIndexLast(0);
namespace {
int32 peerColorIndex(const PeerId &peer) {
int32 myId(MTP::authedId()), peerId(peerToBareInt(peer));