Skip to content

Commit

Permalink
beta 1.6.2.010801
Browse files Browse the repository at this point in the history
  • Loading branch information
thorwe committed Jan 8, 2015
1 parent f7ec956 commit f414f2b
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 11 deletions.
6 changes: 4 additions & 2 deletions CrossTalk.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down
44 changes: 44 additions & 0 deletions src/pipeserver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "pipeserver.h"

#include <QtNetwork>
#include <QSignalMapper>
#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();
}
32 changes: 32 additions & 0 deletions src/pipeserver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#ifndef PIPESERVER_H
#define PIPESERVER_H

#include <QObject>
#include <QLocalSocket>

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<QString, QLocalSocket*> m_Clients;
QSignalMapper *m_SignalMapper;
};

#endif // PIPESERVER_H
2 changes: 1 addition & 1 deletion src/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
3 changes: 3 additions & 0 deletions src/plugin_qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <QSettings>
#include "ts_logging_qt.h"
#include "ts_helpers_qt.h"
#include "pipeserver.h"

PluginQt* PluginQt::m_Instance = 0;

Expand Down Expand Up @@ -47,6 +48,8 @@ void PluginQt::Init()
}
#endif

m_PipeServer = new PipeServer(this, (QString(ts3plugin_author()).simplified().replace(" ","") + QString(ts3plugin_name())));

m_isInit = true;
}

Expand Down
4 changes: 4 additions & 0 deletions src/plugin_qt.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "ServerThreaded/ServerThreaded.h"
#endif

#include "pipeserver.h"

class PluginQt : public QObject
{
Q_OBJECT
Expand Down Expand Up @@ -62,6 +64,8 @@ class PluginQt : public QObject
ServerThreaded* m_WebSocketServer;
#endif

PipeServer* m_PipeServer;

signals:
// Sse-Server
void sseServerEnabledToggled(bool);
Expand Down
2 changes: 1 addition & 1 deletion src/positional_audio/groupbox_positional_audio.ui
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
</size>
</property>
<property name="suffix">
<string notr="true"> dB/m</string>
<string notr="true"> dB</string>
</property>
<property name="minimum">
<double>-200.000000000000000</double>
Expand Down
20 changes: 14 additions & 6 deletions src/positional_audio/mod_positionalaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "../talkers.h"
#include "../ts_helpers_qt.h"
#include "../ts_logging_qt.h"

#include "ts_serversinfo.h"

Expand All @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
}

Expand All @@ -172,6 +176,7 @@ void PositionalAudio::setRollOffMax(float val)
return;
m_rollOffMax = val;
m_rollOffMax_Lin = db2lin_alt2(m_rollOffMax);

emit rollOffMaxChanged(m_rollOffMax);
}

Expand Down Expand Up @@ -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;
}
}
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/positional_audio/mod_positionalaudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f414f2b

Please sign in to comment.