diff --git a/CrossTalk.pro b/CrossTalk.pro index 602059d..e2b599b 100644 --- a/CrossTalk.pro +++ b/CrossTalk.pro @@ -57,7 +57,8 @@ HEADERS += \ src/mod_agmu.h \ src/plugin_qt.h \ src/sse_server.h \ - src/groupbox_ducking.h + src/groupbox_ducking.h \ + src/pipeserver.h SOURCES += \ src/ts_settings_qt.cpp \ @@ -94,7 +95,8 @@ SOURCES += \ src/mod_agmu.cpp \ src/plugin_qt.cpp \ src/sse_server.cpp \ - src/groupbox_ducking.cpp + src/groupbox_ducking.cpp \ + src/pipeserver.cpp FORMS += \ src/config.ui \ diff --git a/src/pipeserver.cpp b/src/pipeserver.cpp new file mode 100644 index 0000000..2353b54 --- /dev/null +++ b/src/pipeserver.cpp @@ -0,0 +1,44 @@ +#include "pipeserver.h" + +#include +#include +#include "ts_logging_qt.h" + +PipeServer::PipeServer(QObject *parent, QString name) : + QObject(parent) +{ + m_SignalMapper = new QSignalMapper(this); + + m_PipeServer = new QLocalServer(this); + if (!m_PipeServer->listen(name)) { //QString(ts3plugin_author()) + QString(ts3plugin_name())) + TSLogging::Error(QString("Unable to start the server: %1.").arg(m_PipeServer->errorString())); + return; + } + connect(m_PipeServer, SIGNAL(newConnection()), this, SLOT(onNewConnection())); + connect(m_SignalMapper, SIGNAL(mapped(QString)), this, SLOT(onClientDisconnected(QString))); +} + +void PipeServer::Send(QString message) +{ + if (m_Clients.isEmpty()) + return; + + foreach (QLocalSocket* clientConnection, m_Clients) + clientConnection->write(message.toLocal8Bit().constData()); +} + +void PipeServer::onNewConnection() +{ + QLocalSocket *clientConnection = m_PipeServer->nextPendingConnection(); + qintptr desc = clientConnection->socketDescriptor(); + QString descStr = QString("%1").arg(desc); + m_Clients.insert(descStr, clientConnection); + connect(clientConnection, SIGNAL(disconnected()), m_SignalMapper, SLOT(map())); + m_SignalMapper->setMapping(clientConnection, descStr); +} + +void PipeServer::onClientDisconnected(QString descStr) +{ + QLocalSocket *clientConnection = m_Clients.take(descStr); + clientConnection->deleteLater(); +} diff --git a/src/pipeserver.h b/src/pipeserver.h new file mode 100644 index 0000000..e5a861b --- /dev/null +++ b/src/pipeserver.h @@ -0,0 +1,32 @@ +#ifndef PIPESERVER_H +#define PIPESERVER_H + +#include +#include + +class QLocalServer; +class QSignalMapper; + +class PipeServer : public QObject +{ + Q_OBJECT + +public: + explicit PipeServer(QObject *parent = 0, QString name = "ThorweCtPipeServer"); + +signals: + +public slots: + void Send(QString message); + +private slots: + void onNewConnection(); + void onClientDisconnected(QString descStr); + +private: + QLocalServer *m_PipeServer; + QMap m_Clients; + QSignalMapper *m_SignalMapper; +}; + +#endif // PIPESERVER_H diff --git a/src/plugin.cpp b/src/plugin.cpp index f0235ff..71140da 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -131,7 +131,7 @@ TSServersInfo* centralStation = TSServersInfo::instance(); const char* ts3plugin_name() { return "CrossTalk"; } /* Plugin version */ -const char* ts3plugin_version() { return "1.6.1.062401"; } +const char* ts3plugin_version() { return "1.6.2.010801"; } /* Plugin API version. Must be the same as the clients API major version, else the plugin fails to load. */ int ts3plugin_apiVersion() { return PLUGIN_API_VERSION; } diff --git a/src/plugin_qt.cpp b/src/plugin_qt.cpp index 0d148a1..6eca38b 100644 --- a/src/plugin_qt.cpp +++ b/src/plugin_qt.cpp @@ -2,6 +2,7 @@ #include #include "ts_logging_qt.h" #include "ts_helpers_qt.h" +#include "pipeserver.h" PluginQt* PluginQt::m_Instance = 0; @@ -47,6 +48,8 @@ void PluginQt::Init() } #endif + m_PipeServer = new PipeServer(this, (QString(ts3plugin_author()).simplified().replace(" ","") + QString(ts3plugin_name()))); + m_isInit = true; } diff --git a/src/plugin_qt.h b/src/plugin_qt.h index 0ab9c6b..1f0acfc 100644 --- a/src/plugin_qt.h +++ b/src/plugin_qt.h @@ -11,6 +11,8 @@ #include "ServerThreaded/ServerThreaded.h" #endif +#include "pipeserver.h" + class PluginQt : public QObject { Q_OBJECT @@ -62,6 +64,8 @@ class PluginQt : public QObject ServerThreaded* m_WebSocketServer; #endif + PipeServer* m_PipeServer; + signals: // Sse-Server void sseServerEnabledToggled(bool); diff --git a/src/positional_audio/groupbox_positional_audio.ui b/src/positional_audio/groupbox_positional_audio.ui index c1e51a9..564ad37 100644 --- a/src/positional_audio/groupbox_positional_audio.ui +++ b/src/positional_audio/groupbox_positional_audio.ui @@ -159,7 +159,7 @@ - dB/m + dB -200.000000000000000 diff --git a/src/positional_audio/mod_positionalaudio.cpp b/src/positional_audio/mod_positionalaudio.cpp index d856af4..b19d313 100644 --- a/src/positional_audio/mod_positionalaudio.cpp +++ b/src/positional_audio/mod_positionalaudio.cpp @@ -18,6 +18,7 @@ #include "../talkers.h" #include "../ts_helpers_qt.h" +#include "../ts_logging_qt.h" #include "ts_serversinfo.h" @@ -27,6 +28,8 @@ #define M_PI 3.14159265358979323846f #endif +double log2(double d) {return log(d)/log(2) ;} + #ifndef INCHTOM #define INCHTOM(b) (b*39.3701) #endif @@ -70,7 +73,7 @@ PositionalAudio::PositionalAudio(QObject *parent) : m_distanceMax(0), m_rollOff(0.0f), m_rollOffMax(0.0f), - m_rollOff_Lin(1.0f), + //m_rollOff_Lin(1.0f), m_rollOffMax_Lin(1.0f), m_IsSendAllOverride(true) { @@ -162,7 +165,8 @@ void PositionalAudio::setRollOff(float val) if (m_rollOff == val) return; m_rollOff = val; - m_rollOff_Lin = db2lin_alt2(m_rollOff); + //m_rollOff_Lin = db2lin_alt2(m_rollOff); + emit rollOffChanged(m_rollOff); } @@ -172,6 +176,7 @@ void PositionalAudio::setRollOffMax(float val) return; m_rollOffMax = val; m_rollOffMax_Lin = db2lin_alt2(m_rollOffMax); + emit rollOffMaxChanged(m_rollOffMax); } @@ -367,11 +372,13 @@ void PositionalAudio::onCustom3dRolloffCalculationClientEvent(uint64 serverConne else { distance = distance - m_distanceMin; - float rollOff = distance * m_rollOff_Lin; - if (rollOff < m_rollOffMax_Lin) - rollOff = m_rollOffMax_Lin; + if(distance <= 1) + *volume = 1.0f; + else + *volume = db2lin_alt2(log2(distance) * m_rollOff); - *volume = rollOff; + if (*volume < m_rollOffMax_Lin) + *volume = m_rollOffMax_Lin; } } } @@ -443,6 +450,7 @@ void PositionalAudio::onRunningStateChanged(bool value) connect(universe,SIGNAL(removed(QString)),this,SLOT(onUniverseRemoved(QString)),Qt::UniqueConnection); connect(meObj,SIGNAL(vrChanged(TsVrObj*,QString)),this,SLOT(onMyVrChanged(TsVrObj*,QString)),Qt::UniqueConnection); connect(meObj,SIGNAL(identityChanged(TsVrObj*,QString)),this,SLOT(onMyIdentityChanged(TsVrObj*,QString)),Qt::UniqueConnection); + connect(this,&PositionalAudio::BroadcastJSON, (PluginQt::instance()->m_PipeServer), &PipeServer::Send, Qt::UniqueConnection); #ifdef USE_WEBSOCKET connect(this, SIGNAL(BroadcastJSON(QString)),PluginQt::instance()->m_WebSocketServer,SIGNAL(broadcastMessage(QString)), Qt::UniqueConnection); #endif diff --git a/src/positional_audio/mod_positionalaudio.h b/src/positional_audio/mod_positionalaudio.h index fe473f7..38b7e2a 100644 --- a/src/positional_audio/mod_positionalaudio.h +++ b/src/positional_audio/mod_positionalaudio.h @@ -137,7 +137,7 @@ public slots: int m_distanceMax; float m_rollOff; float m_rollOffMax; - float m_rollOff_Lin; + //float m_rollOff_Lin; float m_rollOffMax_Lin; QString GetSendString(bool isAll);