mirror of
https://github.com/mumble-voip/mumble.git
synced 2025-10-26 11:19:16 +00:00
REFAC: Fix tons of warnings and non-portable code
In various places we relied on compiler extensions such as variable-length arrays on the stack or using non-standard escape sequences. In order to make our code as portable as possible, these parts of the code have been refactored to only use standard C++. Furthermore, the new warning settings triggered a bunch of new warnings all over the place that have been addressed by this commit.
This commit is contained in:
parent
ded91ed2c8
commit
b5a67c05fb
@ -17,11 +17,11 @@
|
|||||||
# include "Database.h"
|
# include "Database.h"
|
||||||
# include "ServerHandler.h"
|
# include "ServerHandler.h"
|
||||||
|
|
||||||
QHash< int, Channel * > Channel::c_qhChannels;
|
QHash< unsigned int, Channel * > Channel::c_qhChannels;
|
||||||
QReadWriteLock Channel::c_qrwlChannels;
|
QReadWriteLock Channel::c_qrwlChannels;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Channel::Channel(int id, const QString &name, QObject *p) : QObject(p) {
|
Channel::Channel(unsigned int id, const QString &name, QObject *p) : QObject(p) {
|
||||||
iId = id;
|
iId = id;
|
||||||
iPosition = 0;
|
iPosition = 0;
|
||||||
qsName = name;
|
qsName = name;
|
||||||
@ -59,12 +59,12 @@ Channel::~Channel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MUMBLE
|
#ifdef MUMBLE
|
||||||
Channel *Channel::get(int id) {
|
Channel *Channel::get(unsigned int id) {
|
||||||
QReadLocker lock(&c_qrwlChannels);
|
QReadLocker lock(&c_qrwlChannels);
|
||||||
return c_qhChannels.value(id);
|
return c_qhChannels.value(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel *Channel::add(int id, const QString &name) {
|
Channel *Channel::add(unsigned int id, const QString &name) {
|
||||||
QWriteLocker lock(&c_qrwlChannels);
|
QWriteLocker lock(&c_qrwlChannels);
|
||||||
|
|
||||||
if (c_qhChannels.contains(id))
|
if (c_qhChannels.contains(id))
|
||||||
@ -272,7 +272,7 @@ void Channel::removeUser(User *p) {
|
|||||||
|
|
||||||
Channel::operator QString() const {
|
Channel::operator QString() const {
|
||||||
return QString::fromLatin1("%1[%2:%3%4]")
|
return QString::fromLatin1("%1[%2:%3%4]")
|
||||||
.arg(qsName, QString::number(iId), QString::number(cParent ? cParent->iId : -1),
|
.arg(qsName, QString::number(iId), QString::number(cParent ? static_cast< int >(cParent->iId) : -1),
|
||||||
bTemporary ? QLatin1String("*") : QLatin1String(""));
|
bTemporary ? QLatin1String("*") : QLatin1String(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
static constexpr int ROOT_ID = 0;
|
static constexpr int ROOT_ID = 0;
|
||||||
|
|
||||||
int iId;
|
unsigned int iId;
|
||||||
int iPosition;
|
int iPosition;
|
||||||
bool bTemporary;
|
bool bTemporary;
|
||||||
Channel *cParent;
|
Channel *cParent;
|
||||||
@ -67,7 +67,7 @@ public:
|
|||||||
/// setting.
|
/// setting.
|
||||||
unsigned int uiMaxUsers;
|
unsigned int uiMaxUsers;
|
||||||
|
|
||||||
Channel(int id, const QString &name, QObject *p = nullptr);
|
Channel(unsigned int id, const QString &name, QObject *p = nullptr);
|
||||||
~Channel();
|
~Channel();
|
||||||
|
|
||||||
#ifdef MUMBLE
|
#ifdef MUMBLE
|
||||||
@ -79,11 +79,11 @@ public:
|
|||||||
void clearFilterMode();
|
void clearFilterMode();
|
||||||
bool isFiltered() const;
|
bool isFiltered() const;
|
||||||
|
|
||||||
static QHash< int, Channel * > c_qhChannels;
|
static QHash< unsigned int, Channel * > c_qhChannels;
|
||||||
static QReadWriteLock c_qrwlChannels;
|
static QReadWriteLock c_qrwlChannels;
|
||||||
|
|
||||||
static Channel *get(int);
|
static Channel *get(unsigned int);
|
||||||
static Channel *add(int, const QString &);
|
static Channel *add(unsigned int, const QString &);
|
||||||
static void remove(Channel *);
|
static void remove(Channel *);
|
||||||
|
|
||||||
void addClientUser(ClientUser *p);
|
void addClientUser(ClientUser *p);
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
std::size_t qHash(const ChannelListener &listener) {
|
std::size_t qHash(const ChannelListener &listener) {
|
||||||
return std::hash< ChannelListener >()(listener);
|
return std::hash< ChannelListener >()(listener);
|
||||||
};
|
}
|
||||||
|
|
||||||
bool operator==(const ChannelListener &lhs, const ChannelListener &rhs) {
|
bool operator==(const ChannelListener &lhs, const ChannelListener &rhs) {
|
||||||
return lhs.channelID == rhs.channelID && lhs.userSession == rhs.userSession;
|
return lhs.channelID == rhs.channelID && lhs.userSession == rhs.userSession;
|
||||||
@ -23,21 +23,21 @@ ChannelListenerManager::ChannelListenerManager()
|
|||||||
m_listenerVolumeAdjustments() {
|
m_listenerVolumeAdjustments() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelListenerManager::addListener(unsigned int userSession, int channelID) {
|
void ChannelListenerManager::addListener(unsigned int userSession, unsigned int channelID) {
|
||||||
QWriteLocker lock(&m_listenerLock);
|
QWriteLocker lock(&m_listenerLock);
|
||||||
|
|
||||||
m_listeningUsers[userSession] << channelID;
|
m_listeningUsers[userSession] << channelID;
|
||||||
m_listenedChannels[channelID] << userSession;
|
m_listenedChannels[channelID] << userSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelListenerManager::removeListener(unsigned int userSession, int channelID) {
|
void ChannelListenerManager::removeListener(unsigned int userSession, unsigned int channelID) {
|
||||||
QWriteLocker lock(&m_listenerLock);
|
QWriteLocker lock(&m_listenerLock);
|
||||||
|
|
||||||
m_listeningUsers[userSession].remove(channelID);
|
m_listeningUsers[userSession].remove(channelID);
|
||||||
m_listenedChannels[channelID].remove(userSession);
|
m_listenedChannels[channelID].remove(userSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChannelListenerManager::isListening(unsigned int userSession, int channelID) const {
|
bool ChannelListenerManager::isListening(unsigned int userSession, unsigned int channelID) const {
|
||||||
QReadLocker lock(&m_listenerLock);
|
QReadLocker lock(&m_listenerLock);
|
||||||
|
|
||||||
return m_listenedChannels[channelID].contains(userSession);
|
return m_listenedChannels[channelID].contains(userSession);
|
||||||
@ -49,25 +49,25 @@ bool ChannelListenerManager::isListeningToAny(unsigned int userSession) const {
|
|||||||
return !m_listeningUsers[userSession].isEmpty();
|
return !m_listeningUsers[userSession].isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChannelListenerManager::isListenedByAny(int channelID) const {
|
bool ChannelListenerManager::isListenedByAny(unsigned int channelID) const {
|
||||||
QReadLocker lock(&m_listenerLock);
|
QReadLocker lock(&m_listenerLock);
|
||||||
|
|
||||||
return !m_listenedChannels[channelID].isEmpty();
|
return !m_listenedChannels[channelID].isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QSet< unsigned int > ChannelListenerManager::getListenersForChannel(int channelID) const {
|
const QSet< unsigned int > ChannelListenerManager::getListenersForChannel(unsigned int channelID) const {
|
||||||
QReadLocker lock(&m_listenerLock);
|
QReadLocker lock(&m_listenerLock);
|
||||||
|
|
||||||
return m_listenedChannels[channelID];
|
return m_listenedChannels[channelID];
|
||||||
}
|
}
|
||||||
|
|
||||||
const QSet< int > ChannelListenerManager::getListenedChannelsForUser(unsigned int userSession) const {
|
const QSet< unsigned int > ChannelListenerManager::getListenedChannelsForUser(unsigned int userSession) const {
|
||||||
QReadLocker lock(&m_listenerLock);
|
QReadLocker lock(&m_listenerLock);
|
||||||
|
|
||||||
return m_listeningUsers[userSession];
|
return m_listeningUsers[userSession];
|
||||||
}
|
}
|
||||||
|
|
||||||
int ChannelListenerManager::getListenerCountForChannel(int channelID) const {
|
int ChannelListenerManager::getListenerCountForChannel(unsigned int channelID) const {
|
||||||
QReadLocker lock(&m_listenerLock);
|
QReadLocker lock(&m_listenerLock);
|
||||||
|
|
||||||
return m_listenedChannels[channelID].size();
|
return m_listenedChannels[channelID].size();
|
||||||
@ -79,7 +79,7 @@ int ChannelListenerManager::getListenedChannelCountForUser(unsigned int userSess
|
|||||||
return m_listeningUsers[userSession].size();
|
return m_listeningUsers[userSession].size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelListenerManager::setListenerVolumeAdjustment(unsigned int userSession, int channelID,
|
void ChannelListenerManager::setListenerVolumeAdjustment(unsigned int userSession, unsigned int channelID,
|
||||||
const VolumeAdjustment &volumeAdjustment) {
|
const VolumeAdjustment &volumeAdjustment) {
|
||||||
float oldValue = 1.0f;
|
float oldValue = 1.0f;
|
||||||
{
|
{
|
||||||
@ -103,7 +103,7 @@ void ChannelListenerManager::setListenerVolumeAdjustment(unsigned int userSessio
|
|||||||
}
|
}
|
||||||
|
|
||||||
const VolumeAdjustment &ChannelListenerManager::getListenerVolumeAdjustment(unsigned int userSession,
|
const VolumeAdjustment &ChannelListenerManager::getListenerVolumeAdjustment(unsigned int userSession,
|
||||||
int channelID) const {
|
unsigned int channelID) const {
|
||||||
static VolumeAdjustment fallbackObj = VolumeAdjustment::fromFactor(1.0f);
|
static VolumeAdjustment fallbackObj = VolumeAdjustment::fromFactor(1.0f);
|
||||||
|
|
||||||
QReadLocker lock(&m_volumeLock);
|
QReadLocker lock(&m_volumeLock);
|
||||||
@ -121,14 +121,14 @@ const VolumeAdjustment &ChannelListenerManager::getListenerVolumeAdjustment(unsi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_map< int, VolumeAdjustment >
|
std::unordered_map< unsigned int, VolumeAdjustment >
|
||||||
ChannelListenerManager::getAllListenerVolumeAdjustments(unsigned int userSession) const {
|
ChannelListenerManager::getAllListenerVolumeAdjustments(unsigned int userSession) const {
|
||||||
QReadLocker lock1(&m_volumeLock);
|
QReadLocker lock1(&m_volumeLock);
|
||||||
QReadLocker lock2(&m_listenerLock);
|
QReadLocker lock2(&m_listenerLock);
|
||||||
|
|
||||||
std::unordered_map< int, VolumeAdjustment > adjustments;
|
std::unordered_map< unsigned int, VolumeAdjustment > adjustments;
|
||||||
|
|
||||||
for (int channelID : m_listeningUsers.value(userSession)) {
|
for (unsigned int channelID : m_listeningUsers.value(userSession)) {
|
||||||
ChannelListener listener = {};
|
ChannelListener listener = {};
|
||||||
listener.channelID = channelID;
|
listener.channelID = channelID;
|
||||||
listener.userSession = userSession;
|
listener.userSession = userSession;
|
||||||
|
|||||||
@ -22,13 +22,13 @@ struct ChannelListener {
|
|||||||
/// The session ID of the owning user
|
/// The session ID of the owning user
|
||||||
unsigned int userSession;
|
unsigned int userSession;
|
||||||
/// The ID of the channel this listener is placed in
|
/// The ID of the channel this listener is placed in
|
||||||
int channelID;
|
unsigned int channelID;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Make ChannelListener hashable and comparable
|
// Make ChannelListener hashable and comparable
|
||||||
template<> struct std::hash< ChannelListener > {
|
template<> struct std::hash< ChannelListener > {
|
||||||
std::size_t operator()(const ChannelListener &val) const {
|
std::size_t operator()(const ChannelListener &val) const {
|
||||||
return std::hash< unsigned int >()(val.userSession) ^ (std::hash< int >()(val.channelID) << 2);
|
return std::hash< unsigned int >()(val.userSession) ^ (std::hash< unsigned int >()(val.channelID) << 2);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
std::size_t qHash(const ChannelListener &listener);
|
std::size_t qHash(const ChannelListener &listener);
|
||||||
@ -47,9 +47,9 @@ protected:
|
|||||||
/// A lock for guarding m_listeningUsers as well as m_listenedChannels
|
/// A lock for guarding m_listeningUsers as well as m_listenedChannels
|
||||||
mutable QReadWriteLock m_listenerLock;
|
mutable QReadWriteLock m_listenerLock;
|
||||||
/// A map between a user's session and a list of IDs of all channels the user is listening to
|
/// A map between a user's session and a list of IDs of all channels the user is listening to
|
||||||
QHash< unsigned int, QSet< int > > m_listeningUsers;
|
QHash< unsigned int, QSet< unsigned int > > m_listeningUsers;
|
||||||
/// A map between a channel's ID and a list of all user-sessions of users listening to that channel
|
/// A map between a channel's ID and a list of all user-sessions of users listening to that channel
|
||||||
QHash< int, QSet< unsigned int > > m_listenedChannels;
|
QHash< unsigned int, QSet< unsigned int > > m_listenedChannels;
|
||||||
/// A lock for guarding m_listenerVolumeAdjustments
|
/// A lock for guarding m_listenerVolumeAdjustments
|
||||||
mutable QReadWriteLock m_volumeLock;
|
mutable QReadWriteLock m_volumeLock;
|
||||||
/// A map between channel IDs and local volume adjustments to be made for ChannelListeners
|
/// A map between channel IDs and local volume adjustments to be made for ChannelListeners
|
||||||
@ -64,18 +64,18 @@ public:
|
|||||||
///
|
///
|
||||||
/// @param userSession The session ID of the user
|
/// @param userSession The session ID of the user
|
||||||
/// @param channelID The ID of the channel
|
/// @param channelID The ID of the channel
|
||||||
void addListener(unsigned int userSession, int channelID);
|
void addListener(unsigned int userSession, unsigned int channelID);
|
||||||
|
|
||||||
/// Removes a listener from the channel.
|
/// Removes a listener from the channel.
|
||||||
///
|
///
|
||||||
/// @param userSession The session ID of the user
|
/// @param userSession The session ID of the user
|
||||||
/// @param channelID The ID of the channel
|
/// @param channelID The ID of the channel
|
||||||
void removeListener(unsigned int userSession, int channelID);
|
void removeListener(unsigned int userSession, unsigned int channelID);
|
||||||
|
|
||||||
/// @param userSession The session ID of the user
|
/// @param userSession The session ID of the user
|
||||||
/// @param channelID The ID of the channel
|
/// @param channelID The ID of the channel
|
||||||
/// @returns Whether the given user is listening to the given channel
|
/// @returns Whether the given user is listening to the given channel
|
||||||
bool isListening(unsigned int userSession, int channelID) const;
|
bool isListening(unsigned int userSession, unsigned int channelID) const;
|
||||||
|
|
||||||
/// @param userSession The session ID of the user
|
/// @param userSession The session ID of the user
|
||||||
/// @returns Whether this user is listening to any channel via the ChannelListener feature
|
/// @returns Whether this user is listening to any channel via the ChannelListener feature
|
||||||
@ -83,19 +83,19 @@ public:
|
|||||||
|
|
||||||
/// @param channelID The ID of the channel
|
/// @param channelID The ID of the channel
|
||||||
/// @returns Whether any user listens to this channel via the ChannelListener feature
|
/// @returns Whether any user listens to this channel via the ChannelListener feature
|
||||||
bool isListenedByAny(int channelID) const;
|
bool isListenedByAny(unsigned int channelID) const;
|
||||||
|
|
||||||
/// @param channelID The ID of the channel
|
/// @param channelID The ID of the channel
|
||||||
/// @returns A set of user sessions of users listening to the given channel
|
/// @returns A set of user sessions of users listening to the given channel
|
||||||
const QSet< unsigned int > getListenersForChannel(int channelID) const;
|
const QSet< unsigned int > getListenersForChannel(unsigned int channelID) const;
|
||||||
|
|
||||||
/// @param userSession The session ID of the user
|
/// @param userSession The session ID of the user
|
||||||
/// @returns A set of channel IDs of channels the given user is listening to
|
/// @returns A set of channel IDs of channels the given user is listening to
|
||||||
const QSet< int > getListenedChannelsForUser(unsigned int userSession) const;
|
const QSet< unsigned int > getListenedChannelsForUser(unsigned int userSession) const;
|
||||||
|
|
||||||
/// @param channelID The ID of the channel
|
/// @param channelID The ID of the channel
|
||||||
/// @returns The amount of users that are listening to the given channel
|
/// @returns The amount of users that are listening to the given channel
|
||||||
int getListenerCountForChannel(int channelID) const;
|
int getListenerCountForChannel(unsigned int channelID) const;
|
||||||
|
|
||||||
/// @param userSession The session ID of the user
|
/// @param userSession The session ID of the user
|
||||||
/// @returns The amount of channels the given user is listening to
|
/// @returns The amount of channels the given user is listening to
|
||||||
@ -106,21 +106,23 @@ public:
|
|||||||
/// @param userSession The session ID of the user
|
/// @param userSession The session ID of the user
|
||||||
/// @param channelID The ID of the channel
|
/// @param channelID The ID of the channel
|
||||||
/// @param volumeAdjustment The volume adjustment to apply
|
/// @param volumeAdjustment The volume adjustment to apply
|
||||||
void setListenerVolumeAdjustment(unsigned int userSession, int channelID, const VolumeAdjustment &volumeAdjustment);
|
void setListenerVolumeAdjustment(unsigned int userSession, unsigned int channelID,
|
||||||
|
const VolumeAdjustment &volumeAdjustment);
|
||||||
|
|
||||||
/// @param userSession The session ID of the user
|
/// @param userSession The session ID of the user
|
||||||
/// @param channelID The ID of the channel
|
/// @param channelID The ID of the channel
|
||||||
/// @returns The volume adjustment for the listener of the given user in the given channel.
|
/// @returns The volume adjustment for the listener of the given user in the given channel.
|
||||||
const VolumeAdjustment &getListenerVolumeAdjustment(unsigned int userSession, int channelID) const;
|
const VolumeAdjustment &getListenerVolumeAdjustment(unsigned int userSession, unsigned int channelID) const;
|
||||||
|
|
||||||
/// @param userSession The session ID of the user whose listener's volume adjustments to obtain
|
/// @param userSession The session ID of the user whose listener's volume adjustments to obtain
|
||||||
/// @returns A map between channel IDs and the currently set volume adjustment
|
/// @returns A map between channel IDs and the currently set volume adjustment
|
||||||
std::unordered_map< int, VolumeAdjustment > getAllListenerVolumeAdjustments(unsigned int userSession) const;
|
std::unordered_map< unsigned int, VolumeAdjustment >
|
||||||
|
getAllListenerVolumeAdjustments(unsigned int userSession) const;
|
||||||
|
|
||||||
/// Clears all ChannelListeners and volume adjustments
|
/// Clears all ChannelListeners and volume adjustments
|
||||||
void clear();
|
void clear();
|
||||||
signals:
|
signals:
|
||||||
void localVolumeAdjustmentsChanged(int channelID, float newAdjustment, float oldAdjustment);
|
void localVolumeAdjustmentsChanged(unsigned int channelID, float newAdjustment, float oldAdjustment);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MUMBLE_CHANNELLISTENERMANAGER_H_
|
#endif // MUMBLE_CHANNELLISTENERMANAGER_H_
|
||||||
|
|||||||
@ -121,7 +121,7 @@ void Connection::socketRead() {
|
|||||||
|
|
||||||
qtsSocket->read(reinterpret_cast< char * >(a_ucBuffer), 6);
|
qtsSocket->read(reinterpret_cast< char * >(a_ucBuffer), 6);
|
||||||
m_type = static_cast< Mumble::Protocol::TCPMessageType >(qFromBigEndian< quint16 >(&a_ucBuffer[0]));
|
m_type = static_cast< Mumble::Protocol::TCPMessageType >(qFromBigEndian< quint16 >(&a_ucBuffer[0]));
|
||||||
iPacketLength = qFromBigEndian< quint32 >(&a_ucBuffer[2]);
|
iPacketLength = qFromBigEndian< int >(&a_ucBuffer[2]);
|
||||||
iAvailable -= 6;
|
iAvailable -= 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,19 +161,19 @@ void Connection::socketDisconnected() {
|
|||||||
void Connection::messageToNetwork(const ::google::protobuf::Message &msg, Mumble::Protocol::TCPMessageType msgType,
|
void Connection::messageToNetwork(const ::google::protobuf::Message &msg, Mumble::Protocol::TCPMessageType msgType,
|
||||||
QByteArray &cache) {
|
QByteArray &cache) {
|
||||||
#if GOOGLE_PROTOBUF_VERSION >= 3004000
|
#if GOOGLE_PROTOBUF_VERSION >= 3004000
|
||||||
int len = msg.ByteSizeLong();
|
std::size_t len = msg.ByteSizeLong();
|
||||||
#else
|
#else
|
||||||
// ByteSize() has been deprecated as of protobuf v3.4
|
// ByteSize() has been deprecated as of protobuf v3.4
|
||||||
int len = msg.ByteSize();
|
std::size_t len = msg.ByteSize();
|
||||||
#endif
|
#endif
|
||||||
if (len > 0x7fffff)
|
if (len > 0x7fffff)
|
||||||
return;
|
return;
|
||||||
cache.resize(len + 6);
|
cache.resize(static_cast< int >(len + 6));
|
||||||
unsigned char *uc = reinterpret_cast< unsigned char * >(cache.data());
|
unsigned char *uc = reinterpret_cast< unsigned char * >(cache.data());
|
||||||
qToBigEndian< quint16 >(static_cast< quint16 >(msgType), &uc[0]);
|
qToBigEndian< quint16 >(static_cast< quint16 >(msgType), &uc[0]);
|
||||||
qToBigEndian< quint32 >(len, &uc[2]);
|
qToBigEndian< quint32 >(static_cast< unsigned int >(len), &uc[2]);
|
||||||
|
|
||||||
msg.SerializeToArray(uc + 6, len);
|
msg.SerializeToArray(uc + 6, static_cast< int >(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::sendMessage(const ::google::protobuf::Message &msg, Mumble::Protocol::TCPMessageType msgType,
|
void Connection::sendMessage(const ::google::protobuf::Message &msg, Mumble::Protocol::TCPMessageType msgType,
|
||||||
|
|||||||
@ -61,4 +61,4 @@ bool waylandIsUsed() {
|
|||||||
return getenv(QStringLiteral("WAYLAND_DISPLAY")) != "";
|
return getenv(QStringLiteral("WAYLAND_DISPLAY")) != "";
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // namespace EnvUtils
|
} // namespace EnvUtils
|
||||||
|
|||||||
@ -24,6 +24,6 @@ bool setenv(QString name, QString value);
|
|||||||
|
|
||||||
bool waylandIsUsed();
|
bool waylandIsUsed();
|
||||||
|
|
||||||
}; // namespace EnvUtils
|
} // namespace EnvUtils
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -5,8 +5,9 @@
|
|||||||
|
|
||||||
#include "LogEmitter.h"
|
#include "LogEmitter.h"
|
||||||
|
|
||||||
LogEmitter::LogEmitter(QObject *p) : QObject(p){};
|
LogEmitter::LogEmitter(QObject *p) : QObject(p) {
|
||||||
|
}
|
||||||
|
|
||||||
void LogEmitter::addLogEntry(const QString &msg) {
|
void LogEmitter::addLogEntry(const QString &msg) {
|
||||||
emit newLogEntry(msg);
|
emit newLogEntry(msg);
|
||||||
};
|
}
|
||||||
|
|||||||
@ -13,8 +13,8 @@ namespace Plugins {
|
|||||||
constexpr int MAX_DATA_LENGTH = 1000;
|
constexpr int MAX_DATA_LENGTH = 1000;
|
||||||
constexpr int MAX_DATA_ID_LENGTH = 100;
|
constexpr int MAX_DATA_ID_LENGTH = 100;
|
||||||
|
|
||||||
}; // namespace PluginMessage
|
} // namespace PluginMessage
|
||||||
}; // namespace Plugins
|
} // namespace Plugins
|
||||||
}; // namespace Mumble
|
} // namespace Mumble
|
||||||
|
|
||||||
#endif // MUMBLE_MUMBLECONSTANTS_H_
|
#endif // MUMBLE_MUMBLECONSTANTS_H_
|
||||||
|
|||||||
@ -39,7 +39,7 @@ namespace Protocol {
|
|||||||
if (!useCachedSize) {
|
if (!useCachedSize) {
|
||||||
serializedSize = getProtobufSize(message);
|
serializedSize = getProtobufSize(message);
|
||||||
} else {
|
} else {
|
||||||
serializedSize = message.GetCachedSize();
|
serializedSize = static_cast< std::size_t >(message.GetCachedSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(serializedSize + offset <= maxAllowedSize);
|
assert(serializedSize + offset <= maxAllowedSize);
|
||||||
@ -54,7 +54,7 @@ namespace Protocol {
|
|||||||
|
|
||||||
buffer.resize(serializedSize + offset);
|
buffer.resize(serializedSize + offset);
|
||||||
|
|
||||||
message.SerializePartialToArray(buffer.data() + offset, serializedSize);
|
message.SerializePartialToArray(buffer.data() + offset, static_cast< int >(serializedSize));
|
||||||
|
|
||||||
return serializedSize;
|
return serializedSize;
|
||||||
}
|
}
|
||||||
@ -135,11 +135,11 @@ namespace Protocol {
|
|||||||
}
|
}
|
||||||
// The audio format (aka: package type) has to be written to the 3 most significant bits of the header byte
|
// The audio format (aka: package type) has to be written to the 3 most significant bits of the header byte
|
||||||
assert(type < (1 << 3));
|
assert(type < (1 << 3));
|
||||||
type = type << 5;
|
type = static_cast< decltype(type) >(type << 5);
|
||||||
|
|
||||||
m_byteBuffer[0] = type;
|
m_byteBuffer[0] = type;
|
||||||
|
|
||||||
PacketDataStream stream(m_byteBuffer.data() + 1, m_byteBuffer.size() - 1);
|
PacketDataStream stream(m_byteBuffer.data() + 1, static_cast< unsigned int >(m_byteBuffer.size() - 1));
|
||||||
|
|
||||||
if (this->getRole() == Role::Server) {
|
if (this->getRole() == Role::Server) {
|
||||||
stream << data.senderSession;
|
stream << data.senderSession;
|
||||||
@ -155,14 +155,16 @@ namespace Protocol {
|
|||||||
stream << static_cast< int >(data.isLastFrame ? data.payload.size() | (1 << 13) : data.payload.size());
|
stream << static_cast< int >(data.isLastFrame ? data.payload.size() | (1 << 13) : data.payload.size());
|
||||||
|
|
||||||
// After the size has been encoded, we write the actual Opus frame to the message
|
// After the size has been encoded, we write the actual Opus frame to the message
|
||||||
stream.append(reinterpret_cast< const char * >(data.payload.data()), data.payload.size());
|
stream.append(reinterpret_cast< const char * >(data.payload.data()),
|
||||||
|
static_cast< unsigned int >(data.payload.size()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AudioCodec::CELT_Alpha:
|
case AudioCodec::CELT_Alpha:
|
||||||
case AudioCodec::CELT_Beta:
|
case AudioCodec::CELT_Beta:
|
||||||
case AudioCodec::Speex: {
|
case AudioCodec::Speex: {
|
||||||
// Simply append the provided payload
|
// Simply append the provided payload
|
||||||
stream.append(reinterpret_cast< const char * >(data.payload.data()), data.payload.size());
|
stream.append(reinterpret_cast< const char * >(data.payload.data()),
|
||||||
|
static_cast< unsigned int >(data.payload.size()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,7 +201,9 @@ namespace Protocol {
|
|||||||
|
|
||||||
template< Role role > void UDPAudioEncoder< role >::addPositionalData_legacy(const AudioData &data) {
|
template< Role role > void UDPAudioEncoder< role >::addPositionalData_legacy(const AudioData &data) {
|
||||||
if (data.containsPositionalData) {
|
if (data.containsPositionalData) {
|
||||||
PacketDataStream stream(m_byteBuffer.data() + m_staticPartSize, m_byteBuffer.size() - m_staticPartSize);
|
assert(m_byteBuffer.size() >= m_staticPartSize);
|
||||||
|
PacketDataStream stream(m_byteBuffer.data() + m_staticPartSize,
|
||||||
|
static_cast< unsigned int >(m_byteBuffer.size() - m_staticPartSize));
|
||||||
|
|
||||||
// Positional data simply gets attached to the stream after the audio payload
|
// Positional data simply gets attached to the stream after the audio payload
|
||||||
assert(data.position.size() == 3);
|
assert(data.position.size() == 3);
|
||||||
@ -295,7 +299,7 @@ namespace Protocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gsl::span< const byte > buffer = getPreEncodedContext(data.targetOrContext);
|
gsl::span< const byte > buffer = getPreEncodedContext(static_cast< byte >(data.targetOrContext));
|
||||||
if (!buffer.empty()) {
|
if (!buffer.empty()) {
|
||||||
// Use pre-encoded snippet
|
// Use pre-encoded snippet
|
||||||
offset += writeSnippet(buffer, m_byteBuffer, offset, MAX_UDP_PACKET_SIZE);
|
offset += writeSnippet(buffer, m_byteBuffer, offset, MAX_UDP_PACKET_SIZE);
|
||||||
@ -320,7 +324,7 @@ namespace Protocol {
|
|||||||
if (data.containsPositionalData) {
|
if (data.containsPositionalData) {
|
||||||
m_audioMessage.Clear();
|
m_audioMessage.Clear();
|
||||||
|
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (unsigned int i = 0; i < 3; ++i) {
|
||||||
m_audioMessage.add_positional_data(data.position[i]);
|
m_audioMessage.add_positional_data(data.position[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,9 +367,10 @@ namespace Protocol {
|
|||||||
// Store the pre-encoded packet
|
// Store the pre-encoded packet
|
||||||
// The max-size is the size of the used field (float) plus 1 byte overhead for encoding the field type and
|
// The max-size is the size of the used field (float) plus 1 byte overhead for encoding the field type and
|
||||||
// number
|
// number
|
||||||
bool successful =
|
bool successful = encodeProtobuf(
|
||||||
encodeProtobuf(m_audioMessage, m_preEncodedVolumeAdjustment[dbAdjustment - preEncodedDBAdjustmentBegin],
|
m_audioMessage,
|
||||||
0, sizeof(float) + 1, false);
|
m_preEncodedVolumeAdjustment[static_cast< std::size_t >(dbAdjustment - preEncodedDBAdjustmentBegin)], 0,
|
||||||
|
sizeof(float) + 1, false);
|
||||||
(void) successful;
|
(void) successful;
|
||||||
assert(successful);
|
assert(successful);
|
||||||
}
|
}
|
||||||
@ -385,7 +390,7 @@ namespace Protocol {
|
|||||||
template< Role role >
|
template< Role role >
|
||||||
gsl::span< const byte >
|
gsl::span< const byte >
|
||||||
UDPAudioEncoder< role >::getPreEncodedVolumeAdjustment(const VolumeAdjustment &adjustment) const {
|
UDPAudioEncoder< role >::getPreEncodedVolumeAdjustment(const VolumeAdjustment &adjustment) const {
|
||||||
int index = (adjustment.dbAdjustment - preEncodedDBAdjustmentBegin);
|
int index = static_cast< int >(adjustment.dbAdjustment - preEncodedDBAdjustmentBegin);
|
||||||
|
|
||||||
if (adjustment.dbAdjustment == VolumeAdjustment::INVALID_DB_ADJUSTMENT || index < 0
|
if (adjustment.dbAdjustment == VolumeAdjustment::INVALID_DB_ADJUSTMENT || index < 0
|
||||||
|| static_cast< std::size_t >(index) >= m_preEncodedVolumeAdjustment.size()) {
|
|| static_cast< std::size_t >(index) >= m_preEncodedVolumeAdjustment.size()) {
|
||||||
@ -393,7 +398,7 @@ namespace Protocol {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector< byte > &data = m_preEncodedVolumeAdjustment[index];
|
const std::vector< byte > &data = m_preEncodedVolumeAdjustment[static_cast< std::size_t >(index)];
|
||||||
|
|
||||||
return gsl::span< const byte >(data.data(), data.size());
|
return gsl::span< const byte >(data.data(), data.size());
|
||||||
}
|
}
|
||||||
@ -605,7 +610,7 @@ namespace Protocol {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketDataStream stream(data.data(), data.size());
|
PacketDataStream stream(data.data(), static_cast< unsigned int >(data.size()));
|
||||||
|
|
||||||
if (data.size() <= sizeof(std::uint64_t) + 1) {
|
if (data.size() <= sizeof(std::uint64_t) + 1) {
|
||||||
// Regular connectivity ping (contains a single varint which may be up to a full 64bit number plus
|
// Regular connectivity ping (contains a single varint which may be up to a full 64bit number plus
|
||||||
@ -677,7 +682,7 @@ namespace Protocol {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_pingMessage.ParseFromArray(data.data(), data.size())) {
|
if (!m_pingMessage.ParseFromArray(data.data(), static_cast< int >(data.size()))) {
|
||||||
// Invalid format
|
// Invalid format
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -715,7 +720,7 @@ namespace Protocol {
|
|||||||
m_audioData.targetOrContext = data[0] & 0x1f;
|
m_audioData.targetOrContext = data[0] & 0x1f;
|
||||||
m_audioData.usedCodec = codec;
|
m_audioData.usedCodec = codec;
|
||||||
|
|
||||||
PacketDataStream stream(data.data() + 1, data.size() - 1);
|
PacketDataStream stream(data.data() + 1, static_cast< unsigned int >(data.size() - 1));
|
||||||
|
|
||||||
if (this->getRole() == Role::Client) {
|
if (this->getRole() == Role::Client) {
|
||||||
// When the client receives audio packets from the server, there will be an extra field containing the
|
// When the client receives audio packets from the server, there will be an extra field containing the
|
||||||
@ -767,7 +772,7 @@ namespace Protocol {
|
|||||||
// We don't include the size/header-field in the actual payload
|
// We don't include the size/header-field in the actual payload
|
||||||
payloadBegin = stream.dataPtr();
|
payloadBegin = stream.dataPtr();
|
||||||
|
|
||||||
stream.skip(payloadSize);
|
stream.skip(static_cast< unsigned int >(payloadSize));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -782,7 +787,7 @@ namespace Protocol {
|
|||||||
// If there are further bytes after the audio payload, this means that there is positional data attached to
|
// If there are further bytes after the audio payload, this means that there is positional data attached to
|
||||||
// the packet.
|
// the packet.
|
||||||
m_audioData.containsPositionalData = true;
|
m_audioData.containsPositionalData = true;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (unsigned int i = 0; i < 3; ++i) {
|
||||||
stream >> m_audioData.position[i];
|
stream >> m_audioData.position[i];
|
||||||
}
|
}
|
||||||
} else if (stream.left() > 0) {
|
} else if (stream.left() > 0) {
|
||||||
@ -799,7 +804,7 @@ namespace Protocol {
|
|||||||
m_messageType = UDPMessageType::Audio;
|
m_messageType = UDPMessageType::Audio;
|
||||||
m_audioData = {};
|
m_audioData = {};
|
||||||
|
|
||||||
if (!m_audioMessage.ParseFromArray(data.data(), data.size())) {
|
if (!m_audioMessage.ParseFromArray(data.data(), static_cast< int >(data.size()))) {
|
||||||
// Invalid format
|
// Invalid format
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -825,8 +830,8 @@ namespace Protocol {
|
|||||||
// We always expect a 3D position, if positional data is present
|
// We always expect a 3D position, if positional data is present
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (unsigned int i = 0; i < 3; ++i) {
|
||||||
m_audioData.position[i] = m_audioMessage.positional_data(i);
|
m_audioData.position[i] = m_audioMessage.positional_data(static_cast< int >(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_audioData.containsPositionalData = true;
|
m_audioData.containsPositionalData = true;
|
||||||
@ -883,4 +888,4 @@ namespace Protocol {
|
|||||||
#undef PROCESS_CLASS
|
#undef PROCESS_CLASS
|
||||||
|
|
||||||
} // namespace Protocol
|
} // namespace Protocol
|
||||||
}; // namespace Mumble
|
} // namespace Mumble
|
||||||
|
|||||||
@ -91,7 +91,7 @@ namespace Protocol {
|
|||||||
namespace ReservedTargetIDs {
|
namespace ReservedTargetIDs {
|
||||||
constexpr unsigned int REGULAR_SPEECH = 0;
|
constexpr unsigned int REGULAR_SPEECH = 0;
|
||||||
constexpr unsigned int SERVER_LOOPBACK = 31;
|
constexpr unsigned int SERVER_LOOPBACK = 31;
|
||||||
}; // namespace ReservedTargetIDs
|
} // namespace ReservedTargetIDs
|
||||||
|
|
||||||
using audio_context_t = byte;
|
using audio_context_t = byte;
|
||||||
namespace AudioContext {
|
namespace AudioContext {
|
||||||
@ -103,7 +103,7 @@ namespace Protocol {
|
|||||||
|
|
||||||
constexpr audio_context_t BEGIN = NORMAL;
|
constexpr audio_context_t BEGIN = NORMAL;
|
||||||
constexpr audio_context_t END = LISTEN + 1;
|
constexpr audio_context_t END = LISTEN + 1;
|
||||||
}; // namespace AudioContext
|
} // namespace AudioContext
|
||||||
|
|
||||||
enum class Role { Server, Client };
|
enum class Role { Server, Client };
|
||||||
|
|
||||||
@ -273,8 +273,8 @@ namespace Protocol {
|
|||||||
bool decodeAudio_protobuf(const gsl::span< const byte > data);
|
bool decodeAudio_protobuf(const gsl::span< const byte > data);
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // namespace Protocol
|
} // namespace Protocol
|
||||||
}; // namespace Mumble
|
} // namespace Mumble
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is merely a dummy-function (never used) that is required as a scope for dummy-switch statements on our message
|
* This is merely a dummy-function (never used) that is required as a scope for dummy-switch statements on our message
|
||||||
|
|||||||
175
src/OSInfo.cpp
175
src/OSInfo.cpp
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
# include "win.h"
|
# include "win.h"
|
||||||
|
# include "versionhelpers.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "OSInfo.h"
|
#include "OSInfo.h"
|
||||||
@ -130,7 +131,7 @@ QString OSInfo::getArchitecture(const bool build) {
|
|||||||
|
|
||||||
QString OSInfo::getMacHash(const QList< QHostAddress > &qlBind) {
|
QString OSInfo::getMacHash(const QList< QHostAddress > &qlBind) {
|
||||||
QString first, second, third;
|
QString first, second, third;
|
||||||
foreach (const QNetworkInterface &qni, QNetworkInterface::allInterfaces()) {
|
for (const QNetworkInterface &qni : QNetworkInterface::allInterfaces()) {
|
||||||
if (!qni.isValid())
|
if (!qni.isValid())
|
||||||
continue;
|
continue;
|
||||||
if (qni.flags() & QNetworkInterface::IsLoopBack)
|
if (qni.flags() & QNetworkInterface::IsLoopBack)
|
||||||
@ -150,7 +151,7 @@ QString OSInfo::getMacHash(const QList< QHostAddress > &qlBind) {
|
|||||||
if (second.isEmpty() || second > hash)
|
if (second.isEmpty() || second > hash)
|
||||||
second = hash;
|
second = hash;
|
||||||
|
|
||||||
foreach (const QNetworkAddressEntry &qnae, qni.addressEntries()) {
|
for (const QNetworkAddressEntry &qnae : qni.addressEntries()) {
|
||||||
const QHostAddress &qha = qnae.ip();
|
const QHostAddress &qha = qnae.ip();
|
||||||
if (qlBind.isEmpty() || qlBind.contains(qha)) {
|
if (qlBind.isEmpty() || qlBind.contains(qha)) {
|
||||||
if (first.isEmpty() || first > hash)
|
if (first.isEmpty() || first > hash)
|
||||||
@ -193,135 +194,46 @@ QString OSInfo::getOSDisplayableVersion(const bool appendArch) {
|
|||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
QString os = win10DisplayableVersion();
|
QString os = win10DisplayableVersion();
|
||||||
if (os.isEmpty()) {
|
if (os.isEmpty()) {
|
||||||
OSVERSIONINFOEXW ovi;
|
if (IsWindows10OrGreater()) {
|
||||||
memset(&ovi, 0, sizeof(ovi));
|
if (!IsWindowsServer()) {
|
||||||
ovi.dwOSVersionInfoSize = sizeof(ovi);
|
|
||||||
if (!GetVersionEx(reinterpret_cast< OSVERSIONINFOW * >(&ovi))) {
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ovi.dwMajorVersion == 10) {
|
|
||||||
if (ovi.wProductType == VER_NT_WORKSTATION) {
|
|
||||||
os = QLatin1String("Windows 10");
|
os = QLatin1String("Windows 10");
|
||||||
} else {
|
} else {
|
||||||
os = QLatin1String("Windows 10 Server");
|
os = QLatin1String("Windows 10 Server");
|
||||||
}
|
}
|
||||||
} else if (ovi.dwMajorVersion == 6) {
|
} else if (IsWindows8Point1OrGreater()) {
|
||||||
if (ovi.dwMinorVersion == 0) {
|
if (!IsWindowsServer()) {
|
||||||
if (ovi.wProductType == VER_NT_WORKSTATION) {
|
os = QLatin1String("Windows 8.1");
|
||||||
os = QLatin1String("Windows Vista");
|
} else {
|
||||||
} else {
|
os = QLatin1String("Windows 8.1 Server");
|
||||||
os = QLatin1String("Windows Server 2008");
|
|
||||||
}
|
|
||||||
} else if (ovi.dwMinorVersion == 1) {
|
|
||||||
if (ovi.wProductType == VER_NT_WORKSTATION) {
|
|
||||||
os = QLatin1String("Windows 7");
|
|
||||||
} else {
|
|
||||||
os = QLatin1String("Windows Server 2008 R2");
|
|
||||||
}
|
|
||||||
} else if (ovi.dwMinorVersion == 2) {
|
|
||||||
if (ovi.wProductType == VER_NT_WORKSTATION) {
|
|
||||||
os = QLatin1String("Windows 8");
|
|
||||||
} else {
|
|
||||||
os = QLatin1String("Windows Server 2012");
|
|
||||||
}
|
|
||||||
} else if (ovi.dwMinorVersion == 3) {
|
|
||||||
if (ovi.wProductType == VER_NT_WORKSTATION) {
|
|
||||||
os = QLatin1String("Windows 8.1");
|
|
||||||
} else {
|
|
||||||
os = QLatin1String("Windows Server 2012 R2");
|
|
||||||
}
|
|
||||||
} else if (ovi.dwMinorVersion == 4) {
|
|
||||||
if (ovi.wProductType == VER_NT_WORKSTATION) {
|
|
||||||
os = QLatin1String("Windows 10");
|
|
||||||
} else {
|
|
||||||
os = QLatin1String("Windows 10 Server");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else if (IsWindows8OrGreater()) {
|
||||||
|
if (!IsWindowsServer()) {
|
||||||
|
os = QLatin1String("Windows 8");
|
||||||
|
} else {
|
||||||
|
os = QLatin1String("Windows 8 Server");
|
||||||
|
}
|
||||||
|
} else if (IsWindows7OrGreater()) {
|
||||||
|
if (!IsWindowsServer()) {
|
||||||
|
os = QLatin1String("Windows 7");
|
||||||
|
} else {
|
||||||
|
os = QLatin1String("Windows 7 Server");
|
||||||
|
}
|
||||||
|
} else if (IsWindowsVistaOrGreater()) {
|
||||||
|
if (!IsWindowsServer()) {
|
||||||
|
os = QLatin1String("Windows Vista");
|
||||||
|
} else {
|
||||||
|
os = QLatin1String("Windows Vista Server");
|
||||||
|
}
|
||||||
|
} else if (IsWindowsXPOrGreater()) {
|
||||||
|
if (!IsWindowsServer()) {
|
||||||
|
os = QLatin1String("Windows XP");
|
||||||
|
} else {
|
||||||
|
os = QLatin1String("Windows XP Server");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
os = QLatin1String("Ancient Windows version");
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef BOOL(WINAPI * PGPI)(DWORD, DWORD, DWORD, DWORD, PDWORD);
|
|
||||||
PGPI pGetProductInfo = (PGPI) GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetProductInfo");
|
|
||||||
if (!pGetProductInfo) {
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD dwType = 0;
|
|
||||||
if (!pGetProductInfo(ovi.dwMajorVersion, ovi.dwMinorVersion, 0, 0, &dwType)) {
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (dwType) {
|
|
||||||
case PRODUCT_ULTIMATE:
|
|
||||||
os.append(QLatin1String(" Ultimate Edition"));
|
|
||||||
break;
|
|
||||||
case PRODUCT_PROFESSIONAL:
|
|
||||||
os.append(QLatin1String(" Professional"));
|
|
||||||
break;
|
|
||||||
case PRODUCT_HOME_PREMIUM:
|
|
||||||
os.append(QLatin1String(" Home Premium Edition"));
|
|
||||||
break;
|
|
||||||
case PRODUCT_HOME_BASIC:
|
|
||||||
os.append(QLatin1String(" Home Basic Edition"));
|
|
||||||
break;
|
|
||||||
case PRODUCT_ENTERPRISE:
|
|
||||||
os.append(QLatin1String(" Enterprise Edition"));
|
|
||||||
break;
|
|
||||||
case PRODUCT_BUSINESS:
|
|
||||||
os.append(QLatin1String(" Business Edition"));
|
|
||||||
break;
|
|
||||||
case PRODUCT_STARTER:
|
|
||||||
os.append(QLatin1String(" Starter Edition"));
|
|
||||||
break;
|
|
||||||
case PRODUCT_CLUSTER_SERVER:
|
|
||||||
os.append(QLatin1String(" Cluster Server Edition"));
|
|
||||||
break;
|
|
||||||
case PRODUCT_DATACENTER_SERVER:
|
|
||||||
os.append(QLatin1String(" Datacenter Edition"));
|
|
||||||
break;
|
|
||||||
case PRODUCT_DATACENTER_SERVER_CORE:
|
|
||||||
os.append(QLatin1String(" Datacenter Edition (core installation)"));
|
|
||||||
break;
|
|
||||||
case PRODUCT_ENTERPRISE_SERVER:
|
|
||||||
os.append(QLatin1String(" Enterprise Edition"));
|
|
||||||
break;
|
|
||||||
case PRODUCT_ENTERPRISE_SERVER_CORE:
|
|
||||||
os.append(QLatin1String(" Enterprise Edition (core installation)"));
|
|
||||||
break;
|
|
||||||
case PRODUCT_ENTERPRISE_SERVER_IA64:
|
|
||||||
os.append(QLatin1String(" Enterprise Edition for Itanium-based Systems"));
|
|
||||||
break;
|
|
||||||
case PRODUCT_SMALLBUSINESS_SERVER:
|
|
||||||
os.append(QLatin1String(" Small Business Server"));
|
|
||||||
break;
|
|
||||||
case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM:
|
|
||||||
os.append(QLatin1String(" Small Business Server Premium Edition"));
|
|
||||||
break;
|
|
||||||
case PRODUCT_STANDARD_SERVER:
|
|
||||||
os.append(QLatin1String(" Standard Edition"));
|
|
||||||
break;
|
|
||||||
case PRODUCT_STANDARD_SERVER_CORE:
|
|
||||||
os.append(QLatin1String(" Standard Edition (core installation)"));
|
|
||||||
break;
|
|
||||||
case PRODUCT_WEB_SERVER:
|
|
||||||
os.append(QLatin1String(" Web Server Edition"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Service Packs (may be empty)
|
|
||||||
static_assert(sizeof(TCHAR) == sizeof(wchar_t), "Expected Unicode TCHAR.");
|
|
||||||
auto tmp = QString::fromWCharArray(ovi.szCSDVersion);
|
|
||||||
if (!tmp.isEmpty()) {
|
|
||||||
os.append(QLatin1String(" "));
|
|
||||||
os.append(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
tmp = QString::asprintf(" - %lu.%lu.%lu", static_cast< unsigned long >(ovi.dwMajorVersion),
|
|
||||||
static_cast< unsigned long >(ovi.dwMinorVersion),
|
|
||||||
static_cast< unsigned long >(ovi.dwBuildNumber));
|
|
||||||
|
|
||||||
os.append(tmp);
|
|
||||||
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
#elif defined(Q_OS_MACOS)
|
#elif defined(Q_OS_MACOS)
|
||||||
@ -337,20 +249,7 @@ QString OSInfo::getOSDisplayableVersion(const bool appendArch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString OSInfo::getOSVersion() {
|
QString OSInfo::getOSVersion() {
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_MACOS)
|
||||||
OSVERSIONINFOEXW ovi;
|
|
||||||
memset(&ovi, 0, sizeof(ovi));
|
|
||||||
|
|
||||||
ovi.dwOSVersionInfoSize = sizeof(ovi);
|
|
||||||
if (!GetVersionEx(reinterpret_cast< OSVERSIONINFOW * >(&ovi))) {
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
return QString::asprintf("%lu.%lu.%lu.%lu", static_cast< unsigned long >(ovi.dwMajorVersion),
|
|
||||||
static_cast< unsigned long >(ovi.dwMinorVersion),
|
|
||||||
static_cast< unsigned long >(ovi.dwBuildNumber),
|
|
||||||
(ovi.wProductType == VER_NT_WORKSTATION) ? 1UL : 0UL);
|
|
||||||
#elif defined(Q_OS_MACOS)
|
|
||||||
SInt32 major, minor, bugfix;
|
SInt32 major, minor, bugfix;
|
||||||
OSErr err = Gestalt(gestaltSystemVersionMajor, &major);
|
OSErr err = Gestalt(gestaltSystemVersionMajor, &major);
|
||||||
if (err == noErr)
|
if (err == noErr)
|
||||||
|
|||||||
@ -54,7 +54,7 @@ public:
|
|||||||
memcpy(&data[offset], d, len);
|
memcpy(&data[offset], d, len);
|
||||||
offset += len;
|
offset += len;
|
||||||
} else {
|
} else {
|
||||||
int l = left();
|
unsigned int l = left();
|
||||||
memset(&data[offset], 0, l);
|
memset(&data[offset], 0, l);
|
||||||
offset += l;
|
offset += l;
|
||||||
overshoot += len - l;
|
overshoot += len - l;
|
||||||
@ -99,7 +99,7 @@ public:
|
|||||||
|
|
||||||
QByteArray dataBlock(quint32 len) {
|
QByteArray dataBlock(quint32 len) {
|
||||||
if (len <= left()) {
|
if (len <= left()) {
|
||||||
QByteArray a(charPtr(), len);
|
QByteArray a(charPtr(), static_cast< int >(len));
|
||||||
offset += len;
|
offset += len;
|
||||||
return a;
|
return a;
|
||||||
} else {
|
} else {
|
||||||
@ -109,7 +109,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setup(unsigned char *d, int msize) {
|
void setup(unsigned char *d, unsigned int msize) {
|
||||||
data = d;
|
data = d;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
overshoot = 0;
|
overshoot = 0;
|
||||||
@ -118,23 +118,24 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PacketDataStream(const unsigned char *d, int msize) { setup(const_cast< unsigned char * >(d), msize); };
|
PacketDataStream(const unsigned char *d, unsigned int msize) { setup(const_cast< unsigned char * >(d), msize); };
|
||||||
|
|
||||||
PacketDataStream(const char *d, int msize) {
|
PacketDataStream(const char *d, unsigned int msize) {
|
||||||
setup(const_cast< unsigned char * >(reinterpret_cast< const unsigned char * >(d)), msize);
|
setup(const_cast< unsigned char * >(reinterpret_cast< const unsigned char * >(d)), msize);
|
||||||
};
|
};
|
||||||
|
|
||||||
PacketDataStream(char *d, int msize) { setup(reinterpret_cast< unsigned char * >(d), msize); };
|
PacketDataStream(char *d, unsigned int msize) { setup(reinterpret_cast< unsigned char * >(d), msize); };
|
||||||
|
|
||||||
PacketDataStream(unsigned char *d, int msize) { setup(d, msize); };
|
PacketDataStream(unsigned char *d, unsigned int msize) { setup(d, msize); };
|
||||||
|
|
||||||
PacketDataStream(const QByteArray &qba) {
|
PacketDataStream(const QByteArray &qba) {
|
||||||
setup(const_cast< unsigned char * >(reinterpret_cast< const unsigned char * >(qba.constData())), qba.size());
|
setup(const_cast< unsigned char * >(reinterpret_cast< const unsigned char * >(qba.constData())),
|
||||||
|
static_cast< unsigned int >(qba.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketDataStream(QByteArray &qba) {
|
PacketDataStream(QByteArray &qba) {
|
||||||
unsigned char *ptr = reinterpret_cast< unsigned char * >(qba.data());
|
unsigned char *ptr = reinterpret_cast< unsigned char * >(qba.data());
|
||||||
setup(ptr, qba.capacity());
|
setup(ptr, static_cast< unsigned int >(qba.capacity()));
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketDataStream &operator<<(const quint64 value) {
|
PacketDataStream &operator<<(const quint64 value) {
|
||||||
@ -236,7 +237,7 @@ public:
|
|||||||
|
|
||||||
PacketDataStream &operator<<(const QByteArray &a) {
|
PacketDataStream &operator<<(const QByteArray &a) {
|
||||||
*this << a.size();
|
*this << a.size();
|
||||||
append(a.constData(), a.size());
|
append(a.constData(), static_cast< unsigned int >(a.size()));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,7 +248,7 @@ public:
|
|||||||
len = left();
|
len = left();
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
a = QByteArray(reinterpret_cast< const char * >(&data[offset]), len);
|
a = QByteArray(reinterpret_cast< const char * >(&data[offset]), static_cast< int >(len));
|
||||||
offset += len;
|
offset += len;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -262,7 +263,7 @@ public:
|
|||||||
len = left();
|
len = left();
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
s = QString::fromUtf8(reinterpret_cast< const char * >(&data[offset]), len);
|
s = QString::fromUtf8(reinterpret_cast< const char * >(&data[offset]), static_cast< int >(len));
|
||||||
offset += len;
|
offset += len;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -181,13 +181,13 @@ void ProcessResolver::doResolve() {
|
|||||||
|
|
||||||
void ProcessResolver::doResolve() {
|
void ProcessResolver::doResolve() {
|
||||||
pid_t pids[2048];
|
pid_t pids[2048];
|
||||||
int bytes = proc_listpids(PROC_ALL_PIDS, 0, pids, sizeof(pids));
|
unsigned int bytes = static_cast< unsigned int >(proc_listpids(PROC_ALL_PIDS, 0, pids, sizeof(pids)));
|
||||||
int n_proc = bytes / sizeof(pids[0]);
|
unsigned int n_proc = static_cast< unsigned int >(bytes / sizeof(pids[0]));
|
||||||
for (int i = 0; i < n_proc; i++) {
|
for (unsigned int i = 0; i < n_proc; i++) {
|
||||||
struct proc_bsdinfo proc;
|
struct proc_bsdinfo proc;
|
||||||
int st = proc_pidinfo(pids[i], PROC_PIDTBSDINFO, 0, &proc, PROC_PIDTBSDINFO_SIZE);
|
int st = proc_pidinfo(pids[i], PROC_PIDTBSDINFO, 0, &proc, PROC_PIDTBSDINFO_SIZE);
|
||||||
if (st == PROC_PIDTBSDINFO_SIZE) {
|
if (st == PROC_PIDTBSDINFO_SIZE) {
|
||||||
addEntry(pids[i], proc.pbi_name, m_processMap);
|
addEntry(static_cast< std::uint64_t >(pids[i]), proc.pbi_name, m_processMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -208,7 +208,7 @@ void ProcessResolver::doResolve() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < n_procs; ++i) {
|
for (int i = 0; i < n_procs; ++i) {
|
||||||
addEntry(procs_info[i].ki_pid, procs_info[i].ki_comm, m_processMap);
|
addEntry(static_cast< uint64_t >(procs_info[i].ki_pid), procs_info[i].ki_comm, m_processMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(procs_info);
|
free(procs_info);
|
||||||
|
|||||||
@ -37,4 +37,4 @@ void setSuggestedVersion(MumbleProto::SuggestConfig &msg, const ::Version::full_
|
|||||||
msg.set_version_v1(::Version::toLegacyVersion(version));
|
msg.set_version_v1(::Version::toLegacyVersion(version));
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // namespace MumbleProto
|
} // namespace MumbleProto
|
||||||
|
|||||||
@ -17,6 +17,6 @@ void setVersion(MumbleProto::Version &msg, const ::Version::full_t version);
|
|||||||
::Version::full_t getSuggestedVersion(const MumbleProto::SuggestConfig &msg);
|
::Version::full_t getSuggestedVersion(const MumbleProto::SuggestConfig &msg);
|
||||||
void setSuggestedVersion(MumbleProto::SuggestConfig &msg, const ::Version::full_t version);
|
void setSuggestedVersion(MumbleProto::SuggestConfig &msg, const ::Version::full_t version);
|
||||||
|
|
||||||
}; // namespace MumbleProto
|
} // namespace MumbleProto
|
||||||
|
|
||||||
#endif // MUMBLE_PROTOUTILS_H_
|
#endif // MUMBLE_PROTOUTILS_H_
|
||||||
|
|||||||
@ -24,5 +24,5 @@ namespace QtUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}; // namespace QtUtils
|
} // namespace QtUtils
|
||||||
}; // namespace Mumble
|
} // namespace Mumble
|
||||||
|
|||||||
@ -34,8 +34,8 @@ namespace QtUtils {
|
|||||||
*/
|
*/
|
||||||
QString decode_first_utf8_qssl_string(const QStringList &list);
|
QString decode_first_utf8_qssl_string(const QStringList &list);
|
||||||
|
|
||||||
}; // namespace QtUtils
|
} // namespace QtUtils
|
||||||
}; // namespace Mumble
|
} // namespace Mumble
|
||||||
|
|
||||||
template< typename T > using qt_unique_ptr = std::unique_ptr< T, decltype(&Mumble::QtUtils::deleteQObject) >;
|
template< typename T > using qt_unique_ptr = std::unique_ptr< T, decltype(&Mumble::QtUtils::deleteQObject) >;
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ inline QString u8(const ::std::wstring &str) {
|
|||||||
|
|
||||||
inline ::std::string u8(const QString &str) {
|
inline ::std::string u8(const QString &str) {
|
||||||
const QByteArray &qba = str.toUtf8();
|
const QByteArray &qba = str.toUtf8();
|
||||||
return ::std::string(qba.constData(), qba.length());
|
return ::std::string(qba.constData(), static_cast< std::size_t >(qba.length()));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QByteArray blob(const ::std::string &str) {
|
inline QByteArray blob(const ::std::string &str) {
|
||||||
@ -65,7 +65,7 @@ inline QByteArray blob(const ::std::string &str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline ::std::string blob(const QByteArray &str) {
|
inline ::std::string blob(const QByteArray &str) {
|
||||||
return ::std::string(str.constData(), str.length());
|
return ::std::string(str.constData(), static_cast< std::size_t >(str.length()));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QByteArray sha1(const QByteArray &blob) {
|
inline QByteArray sha1(const QByteArray &blob) {
|
||||||
|
|||||||
@ -47,9 +47,9 @@ unsigned long id_callback() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SSLLocks::initialize() {
|
void SSLLocks::initialize() {
|
||||||
int nlocks = CRYPTO_num_locks();
|
unsigned int nlocks = CRYPTO_num_locks();
|
||||||
|
|
||||||
locks = reinterpret_cast< QMutex ** >(calloc(nlocks, sizeof(QMutex *)));
|
locks = reinterpret_cast< QMutex ** >(calloc(nlocks, sizeof(void *)));
|
||||||
if (!locks) {
|
if (!locks) {
|
||||||
qFatal("SSLLocks: unable to allocate locks array");
|
qFatal("SSLLocks: unable to allocate locks array");
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ void SSLLocks::initialize() {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < nlocks; i++) {
|
for (unsigned int i = 0; i < nlocks; i++) {
|
||||||
locks[i] = new QMutex;
|
locks[i] = new QMutex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,18 +11,13 @@
|
|||||||
|
|
||||||
#include <QtCore/QtGlobal>
|
#include <QtCore/QtGlobal>
|
||||||
|
|
||||||
#define iroundf(x) (static_cast< int >(x))
|
#ifndef Q_OS_WIN
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
# define STACKVAR(type, varname, count) type *varname = reinterpret_cast< type * >(_alloca(sizeof(type) * (count)))
|
|
||||||
#else
|
|
||||||
# ifdef WId
|
# ifdef WId
|
||||||
typedef WId HWND;
|
typedef WId HWND;
|
||||||
# endif
|
# endif
|
||||||
# define __cdecl
|
# define __cdecl
|
||||||
# define INVALID_SOCKET -1
|
# define INVALID_SOCKET -1
|
||||||
# define SOCKET_ERROR -1
|
# define SOCKET_ERROR -1
|
||||||
# define STACKVAR(type, varname, count) type varname[count]
|
|
||||||
# define CopyMemory(dst, ptr, len) memcpy(dst, ptr, len)
|
# define CopyMemory(dst, ptr, len) memcpy(dst, ptr, len)
|
||||||
# define ZeroMemory(ptr, len) memset(ptr, 0, len)
|
# define ZeroMemory(ptr, len) memset(ptr, 0, len)
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -72,13 +72,13 @@ bool getComponents(Version::component_t &major, Version::component_t &minor, Ver
|
|||||||
QRegExp rx(QLatin1String("(\\d+)\\.(\\d+)\\.(\\d+)(?:\\.(\\d+))?"));
|
QRegExp rx(QLatin1String("(\\d+)\\.(\\d+)\\.(\\d+)(?:\\.(\\d+))?"));
|
||||||
|
|
||||||
if (rx.exactMatch(version)) {
|
if (rx.exactMatch(version)) {
|
||||||
major = rx.cap(1).toInt();
|
major = static_cast< Version::component_t >(rx.cap(1).toInt());
|
||||||
minor = rx.cap(2).toInt();
|
minor = static_cast< Version::component_t >(rx.cap(2).toInt());
|
||||||
patch = rx.cap(3).toInt();
|
patch = static_cast< Version::component_t >(rx.cap(3).toInt());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // namespace Version
|
} // namespace Version
|
||||||
|
|||||||
@ -92,7 +92,9 @@ constexpr void getComponents(Version::component_t &major, Version::component_t &
|
|||||||
//
|
//
|
||||||
|
|
||||||
constexpr Version::full_t fromLegacyVersion(std::uint32_t version) {
|
constexpr Version::full_t fromLegacyVersion(std::uint32_t version) {
|
||||||
return fromComponents((version & 0xFFFF0000) >> 16, (version & 0xFF00) >> 8, version & 0xFF);
|
return fromComponents(static_cast< component_t >((version & 0xFFFF0000) >> 16),
|
||||||
|
static_cast< component_t >((version & 0xFF00) >> 8),
|
||||||
|
static_cast< component_t >(version & 0xFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr std::uint32_t toLegacyVersion(Version::full_t version) {
|
constexpr std::uint32_t toLegacyVersion(Version::full_t version) {
|
||||||
@ -108,6 +110,6 @@ constexpr std::uint32_t toLegacyVersion(Version::full_t version) {
|
|||||||
static_cast< std::uint32_t >(std::numeric_limits< std::uint8_t >::max())));
|
static_cast< std::uint32_t >(std::numeric_limits< std::uint8_t >::max())));
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // namespace Version
|
} // namespace Version
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
constexpr float DB_THRESHOLD = 0.1;
|
constexpr float DB_THRESHOLD = 0.1f;
|
||||||
|
|
||||||
VolumeAdjustment::VolumeAdjustment(float factor, int dbAdjustment) : factor(factor), dbAdjustment(dbAdjustment) {
|
VolumeAdjustment::VolumeAdjustment(float factor, int dbAdjustment) : factor(factor), dbAdjustment(dbAdjustment) {
|
||||||
assert(dbAdjustment == INVALID_DB_ADJUSTMENT
|
assert(dbAdjustment == INVALID_DB_ADJUSTMENT
|
||||||
@ -20,7 +20,7 @@ VolumeAdjustment::VolumeAdjustment(float factor, int dbAdjustment) : factor(fact
|
|||||||
// If dB is the dB-representation of a loudness change factor f, we have
|
// If dB is the dB-representation of a loudness change factor f, we have
|
||||||
// dB = log2(f) * 6 <=> f = 2^{dB/6}
|
// dB = log2(f) * 6 <=> f = 2^{dB/6}
|
||||||
// (+6dB equals a doubling in loudness)
|
// (+6dB equals a doubling in loudness)
|
||||||
|| DB_THRESHOLD >= std::abs(dbAdjustment - VolumeAdjustment::toDBAdjustment(factor)));
|
|| DB_THRESHOLD >= std::abs(static_cast< float >(dbAdjustment) - VolumeAdjustment::toDBAdjustment(factor)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decibel formula: +6db = *2
|
// Decibel formula: +6db = *2
|
||||||
@ -40,9 +40,9 @@ VolumeAdjustment VolumeAdjustment::fromFactor(float factor) {
|
|||||||
if (factor > 0) {
|
if (factor > 0) {
|
||||||
float dB = VolumeAdjustment::toDBAdjustment(factor);
|
float dB = VolumeAdjustment::toDBAdjustment(factor);
|
||||||
|
|
||||||
if (std::abs(dB - static_cast< int >(dB)) < DB_THRESHOLD) {
|
if (std::abs(dB - static_cast< float >(static_cast< int >(dB))) < DB_THRESHOLD) {
|
||||||
// Close-enough
|
// Close-enough
|
||||||
return VolumeAdjustment(factor, std::round(dB));
|
return VolumeAdjustment(factor, static_cast< int >(std::round(dB)));
|
||||||
} else {
|
} else {
|
||||||
return VolumeAdjustment(factor, INVALID_DB_ADJUSTMENT);
|
return VolumeAdjustment(factor, INVALID_DB_ADJUSTMENT);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -209,8 +209,18 @@ bool CryptStateOCB2::decrypt(const unsigned char *source, unsigned char *dst, un
|
|||||||
memcpy(decrypt_iv, saveiv, AES_BLOCK_SIZE);
|
memcpy(decrypt_iv, saveiv, AES_BLOCK_SIZE);
|
||||||
|
|
||||||
uiGood++;
|
uiGood++;
|
||||||
uiLate += late;
|
// uiLate += late, but we have to make sure we don't cause wrap-arounds on the unsigned lhs
|
||||||
uiLost += lost;
|
if (late > 0) {
|
||||||
|
uiLate += static_cast< unsigned int >(late);
|
||||||
|
} else if (static_cast< int >(uiLate) > std::abs(late)) {
|
||||||
|
uiLate -= static_cast< unsigned int >(std::abs(late));
|
||||||
|
}
|
||||||
|
// uiLost += lost, but we have to make sure we don't cause wrap-arounds on the unsigned lhs
|
||||||
|
if (lost > 0) {
|
||||||
|
uiLost += static_cast< unsigned int >(lost);
|
||||||
|
} else if (static_cast< int >(uiLost) > std::abs(lost)) {
|
||||||
|
uiLost -= static_cast< unsigned int >(std::abs(lost));
|
||||||
|
}
|
||||||
|
|
||||||
tLastGood.restart();
|
tLastGood.restart();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -78,7 +78,7 @@ void CryptographicHashPrivate::addData(const QByteArray &buf) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int err = EVP_DigestUpdate(m_mdctx, buf.constData(), buf.size());
|
int err = EVP_DigestUpdate(m_mdctx, buf.constData(), static_cast< std::size_t >(buf.size()));
|
||||||
if (err != 1) {
|
if (err != 1) {
|
||||||
cleanupMdctx();
|
cleanupMdctx();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,10 @@ uint32_t CryptographicRandom::uint32() {
|
|||||||
unsigned char buf[4];
|
unsigned char buf[4];
|
||||||
CryptographicRandom::fillBuffer(buf, sizeof(buf));
|
CryptographicRandom::fillBuffer(buf, sizeof(buf));
|
||||||
|
|
||||||
ret = (buf[0]) | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24);
|
ret = buf[0];
|
||||||
|
ret |= static_cast< decltype(ret) >(buf[1] << 8);
|
||||||
|
ret |= static_cast< decltype(ret) >(buf[2] << 16);
|
||||||
|
ret |= static_cast< decltype(ret) >(buf[3] << 24);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,11 +22,13 @@
|
|||||||
|
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
ACLGroup::ACLGroup(const QString &name) : Group(nullptr, name) {
|
ACLGroup::ACLGroup(const QString &name) : Group(nullptr, name) {
|
||||||
bInherited = false;
|
bInherited = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ACLEditor::ACLEditor(int channelparentid, QWidget *p) : QDialog(p) {
|
ACLEditor::ACLEditor(unsigned int channelparentid, QWidget *p) : QDialog(p) {
|
||||||
// Simple constructor for add channel menu
|
// Simple constructor for add channel menu
|
||||||
bAddChannelMode = true;
|
bAddChannelMode = true;
|
||||||
iChannel = channelparentid;
|
iChannel = channelparentid;
|
||||||
@ -76,7 +78,7 @@ ACLEditor::ACLEditor(int channelparentid, QWidget *p) : QDialog(p) {
|
|||||||
adjustSize();
|
adjustSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
ACLEditor::ACLEditor(int channelid, const MumbleProto::ACL &mea, QWidget *p) : QDialog(p) {
|
ACLEditor::ACLEditor(unsigned int channelid, const MumbleProto::ACL &mea, QWidget *p) : QDialog(p) {
|
||||||
QLabel *l;
|
QLabel *l;
|
||||||
|
|
||||||
bAddChannelMode = false;
|
bAddChannelMode = false;
|
||||||
@ -111,8 +113,8 @@ ACLEditor::ACLEditor(int channelid, const MumbleProto::ACL &mea, QWidget *p) : Q
|
|||||||
|
|
||||||
qcbChannelTemporary->hide();
|
qcbChannelTemporary->hide();
|
||||||
|
|
||||||
iId = mea.channel_id();
|
iId = static_cast< int >(mea.channel_id());
|
||||||
setWindowTitle(tr("Mumble - Edit %1").arg(Channel::get(iId)->qsName));
|
setWindowTitle(tr("Mumble - Edit %1").arg(Channel::get(static_cast< unsigned int >(iId))->qsName));
|
||||||
|
|
||||||
qlChannelID->setText(tr("ID: %1").arg(iId));
|
qlChannelID->setText(tr("ID: %1").arg(iId));
|
||||||
|
|
||||||
@ -127,7 +129,7 @@ ACLEditor::ACLEditor(int channelid, const MumbleProto::ACL &mea, QWidget *p) : Q
|
|||||||
|
|
||||||
if (Global::get().sh->m_version >= Version::fromComponents(1, 3, 0)) {
|
if (Global::get().sh->m_version >= Version::fromComponents(1, 3, 0)) {
|
||||||
qsbChannelMaxUsers->setRange(0, INT_MAX);
|
qsbChannelMaxUsers->setRange(0, INT_MAX);
|
||||||
qsbChannelMaxUsers->setValue(pChannel->uiMaxUsers);
|
qsbChannelMaxUsers->setValue(static_cast< int >(pChannel->uiMaxUsers));
|
||||||
qsbChannelMaxUsers->setSpecialValueText(tr("Default server value"));
|
qsbChannelMaxUsers->setSpecialValueText(tr("Default server value"));
|
||||||
} else {
|
} else {
|
||||||
qlChannelMaxUsers->hide();
|
qlChannelMaxUsers->hide();
|
||||||
@ -219,7 +221,7 @@ ACLEditor::ACLEditor(int channelid, const MumbleProto::ACL &mea, QWidget *p) : Q
|
|||||||
acl->bInherited = as.inherited();
|
acl->bInherited = as.inherited();
|
||||||
acl->iUserId = -1;
|
acl->iUserId = -1;
|
||||||
if (as.has_user_id())
|
if (as.has_user_id())
|
||||||
acl->iUserId = as.user_id();
|
acl->iUserId = static_cast< int >(as.user_id());
|
||||||
else
|
else
|
||||||
acl->qsGroup = u8(as.group());
|
acl->qsGroup = u8(as.group());
|
||||||
acl->pAllow = static_cast< ChanACL::Permissions >(as.grant());
|
acl->pAllow = static_cast< ChanACL::Permissions >(as.grant());
|
||||||
@ -236,11 +238,11 @@ ACLEditor::ACLEditor(int channelid, const MumbleProto::ACL &mea, QWidget *p) : Q
|
|||||||
gp->bInherited = gs.inherited();
|
gp->bInherited = gs.inherited();
|
||||||
gp->bInheritable = gs.inheritable();
|
gp->bInheritable = gs.inheritable();
|
||||||
for (int j = 0; j < gs.add_size(); ++j)
|
for (int j = 0; j < gs.add_size(); ++j)
|
||||||
gp->qsAdd.insert(gs.add(j));
|
gp->qsAdd.insert(static_cast< int >(gs.add(j)));
|
||||||
for (int j = 0; j < gs.remove_size(); ++j)
|
for (int j = 0; j < gs.remove_size(); ++j)
|
||||||
gp->qsRemove.insert(gs.remove(j));
|
gp->qsRemove.insert(static_cast< int >(gs.remove(j)));
|
||||||
for (int j = 0; j < gs.inherited_members_size(); ++j)
|
for (int j = 0; j < gs.inherited_members_size(); ++j)
|
||||||
gp->qsTemporary.insert(gs.inherited_members(j));
|
gp->qsTemporary.insert(static_cast< int >(gs.inherited_members(j)));
|
||||||
|
|
||||||
qlGroups << gp;
|
qlGroups << gp;
|
||||||
}
|
}
|
||||||
@ -301,8 +303,9 @@ void ACLEditor::accept() {
|
|||||||
// Update channel state
|
// Update channel state
|
||||||
if (bAddChannelMode) {
|
if (bAddChannelMode) {
|
||||||
Global::get().sh->createChannel(iChannel, qleChannelName->text(), rteChannelDescription->text(),
|
Global::get().sh->createChannel(iChannel, qleChannelName->text(), rteChannelDescription->text(),
|
||||||
qsbChannelPosition->value(), qcbChannelTemporary->isChecked(),
|
static_cast< unsigned int >(qsbChannelPosition->value()),
|
||||||
qsbChannelMaxUsers->value());
|
qcbChannelTemporary->isChecked(),
|
||||||
|
static_cast< unsigned int >(qsbChannelMaxUsers->value()));
|
||||||
} else {
|
} else {
|
||||||
bool needs_update = false;
|
bool needs_update = false;
|
||||||
|
|
||||||
@ -325,7 +328,8 @@ void ACLEditor::accept() {
|
|||||||
needs_update = true;
|
needs_update = true;
|
||||||
}
|
}
|
||||||
if (pChannel->uiMaxUsers != static_cast< unsigned int >(qsbChannelMaxUsers->value())) {
|
if (pChannel->uiMaxUsers != static_cast< unsigned int >(qsbChannelMaxUsers->value())) {
|
||||||
mpcs.set_max_users(qsbChannelMaxUsers->value());
|
assert(qsbChannelMaxUsers->value() >= 0);
|
||||||
|
mpcs.set_max_users(static_cast< unsigned int >(qsbChannelMaxUsers->value()));
|
||||||
needs_update = true;
|
needs_update = true;
|
||||||
}
|
}
|
||||||
if (needs_update)
|
if (needs_update)
|
||||||
@ -342,8 +346,8 @@ void ACLEditor::accept() {
|
|||||||
MumbleProto::ACL_ChanACL *mpa = msg.add_acls();
|
MumbleProto::ACL_ChanACL *mpa = msg.add_acls();
|
||||||
mpa->set_apply_here(acl->bApplyHere);
|
mpa->set_apply_here(acl->bApplyHere);
|
||||||
mpa->set_apply_subs(acl->bApplySubs);
|
mpa->set_apply_subs(acl->bApplySubs);
|
||||||
if (acl->iUserId != -1)
|
if (acl->iUserId >= 0)
|
||||||
mpa->set_user_id(acl->iUserId);
|
mpa->set_user_id(static_cast< unsigned int >(acl->iUserId));
|
||||||
else
|
else
|
||||||
mpa->set_group(u8(acl->qsGroup));
|
mpa->set_group(u8(acl->qsGroup));
|
||||||
mpa->set_grant(acl->pAllow);
|
mpa->set_grant(acl->pAllow);
|
||||||
@ -360,10 +364,10 @@ void ACLEditor::accept() {
|
|||||||
mpg->set_inheritable(gp->bInheritable);
|
mpg->set_inheritable(gp->bInheritable);
|
||||||
foreach (int pid, gp->qsAdd)
|
foreach (int pid, gp->qsAdd)
|
||||||
if (pid >= 0)
|
if (pid >= 0)
|
||||||
mpg->add_add(pid);
|
mpg->add_add(static_cast< unsigned int >(pid));
|
||||||
foreach (int pid, gp->qsRemove)
|
foreach (int pid, gp->qsRemove)
|
||||||
if (pid >= 0)
|
if (pid >= 0)
|
||||||
mpg->add_remove(pid);
|
mpg->add_remove(static_cast< unsigned int >(pid));
|
||||||
}
|
}
|
||||||
Global::get().sh->sendMessage(msg);
|
Global::get().sh->sendMessage(msg);
|
||||||
}
|
}
|
||||||
@ -401,7 +405,7 @@ void ACLEditor::returnQuery(const MumbleProto::QueryUsers &mqu) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < mqu.names_size(); ++i) {
|
for (int i = 0; i < mqu.names_size(); ++i) {
|
||||||
int pid = mqu.ids(i);
|
int pid = static_cast< int >(mqu.ids(i));
|
||||||
QString name = u8(mqu.names(i));
|
QString name = u8(mqu.names(i));
|
||||||
QString lname = name.toLower();
|
QString lname = name.toLower();
|
||||||
qhIDCache.insert(lname, pid);
|
qhIDCache.insert(lname, pid);
|
||||||
|
|||||||
@ -46,7 +46,7 @@ protected:
|
|||||||
ChanACL *pcaPassword;
|
ChanACL *pcaPassword;
|
||||||
|
|
||||||
int numInheritACL;
|
int numInheritACL;
|
||||||
int iChannel;
|
unsigned int iChannel;
|
||||||
bool bAddChannelMode;
|
bool bAddChannelMode;
|
||||||
|
|
||||||
const QString userName(int id);
|
const QString userName(int id);
|
||||||
@ -62,8 +62,8 @@ protected:
|
|||||||
void fillWidgetFromSet(QListWidget *, const QSet< int > &);
|
void fillWidgetFromSet(QListWidget *, const QSet< int > &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ACLEditor(int parentchannelid, QWidget *p = nullptr);
|
ACLEditor(unsigned int parentchannelid, QWidget *p = nullptr);
|
||||||
ACLEditor(int channelid, const MumbleProto::ACL &mea, QWidget *p = nullptr);
|
ACLEditor(unsigned int channelid, const MumbleProto::ACL &mea, QWidget *p = nullptr);
|
||||||
~ACLEditor();
|
~ACLEditor();
|
||||||
void returnQuery(const MumbleProto::QueryUsers &mqu);
|
void returnQuery(const MumbleProto::QueryUsers &mqu);
|
||||||
public slots:
|
public slots:
|
||||||
|
|||||||
@ -367,7 +367,8 @@ void ALSAAudioInput::run() {
|
|||||||
eMicFormat = SampleShort;
|
eMicFormat = SampleShort;
|
||||||
initializeMixer();
|
initializeMixer();
|
||||||
|
|
||||||
char inbuff[wantPeriod * iChannels * sizeof(short)];
|
static std::vector< char > inbuff;
|
||||||
|
inbuff.resize(wantPeriod * iChannels * sizeof(short));
|
||||||
|
|
||||||
qml.unlock();
|
qml.unlock();
|
||||||
|
|
||||||
@ -378,7 +379,7 @@ void ALSAAudioInput::run() {
|
|||||||
snd_pcm_status_dump(status, log);
|
snd_pcm_status_dump(status, log);
|
||||||
snd_pcm_status_free(status);
|
snd_pcm_status_free(status);
|
||||||
#endif
|
#endif
|
||||||
readblapp = snd_pcm_readi(capture_handle, inbuff, static_cast< int >(wantPeriod));
|
readblapp = snd_pcm_readi(capture_handle, inbuff.data(), static_cast< snd_pcm_uframes_t >(wantPeriod));
|
||||||
if (readblapp == -ESTRPIPE) {
|
if (readblapp == -ESTRPIPE) {
|
||||||
qWarning("ALSAAudioInput: PCM suspended, trying to resume");
|
qWarning("ALSAAudioInput: PCM suspended, trying to resume");
|
||||||
while (bRunning && snd_pcm_resume(capture_handle) == -EAGAIN)
|
while (bRunning && snd_pcm_resume(capture_handle) == -EAGAIN)
|
||||||
@ -392,7 +393,7 @@ void ALSAAudioInput::run() {
|
|||||||
err = snd_pcm_prepare(capture_handle);
|
err = snd_pcm_prepare(capture_handle);
|
||||||
qWarning("ALSAAudioInput: %s: %s", snd_strerror(static_cast< int >(readblapp)), snd_strerror(err));
|
qWarning("ALSAAudioInput: %s: %s", snd_strerror(static_cast< int >(readblapp)), snd_strerror(err));
|
||||||
} else if (wantPeriod == static_cast< unsigned int >(readblapp)) {
|
} else if (wantPeriod == static_cast< unsigned int >(readblapp)) {
|
||||||
addMic(inbuff, static_cast< int >(readblapp));
|
addMic(inbuff.data(), static_cast< unsigned int >(readblapp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -452,7 +453,7 @@ void ALSAAudioOutput::run() {
|
|||||||
unsigned int iOutputSize = (iFrameSize * rrate) / SAMPLE_RATE;
|
unsigned int iOutputSize = (iFrameSize * rrate) / SAMPLE_RATE;
|
||||||
|
|
||||||
snd_pcm_uframes_t period_size = iOutputSize;
|
snd_pcm_uframes_t period_size = iOutputSize;
|
||||||
snd_pcm_uframes_t buffer_size = iOutputSize * (Global::get().s.iOutputDelay + 1);
|
snd_pcm_uframes_t buffer_size = iOutputSize * static_cast< unsigned int >(Global::get().s.iOutputDelay + 1);
|
||||||
|
|
||||||
int dir = 1;
|
int dir = 1;
|
||||||
ALSA_ERRBAIL(snd_pcm_hw_params_set_period_size_near(pcm_handle, hw_params, &period_size, &dir));
|
ALSA_ERRBAIL(snd_pcm_hw_params_set_period_size_near(pcm_handle, hw_params, &period_size, &dir));
|
||||||
@ -483,8 +484,10 @@ void ALSAAudioOutput::run() {
|
|||||||
|
|
||||||
const unsigned int buffsize = static_cast< unsigned int >(period_size * iChannels);
|
const unsigned int buffsize = static_cast< unsigned int >(period_size * iChannels);
|
||||||
|
|
||||||
float zerobuff[buffsize];
|
static std::vector< float > zerobuff;
|
||||||
float outbuff[buffsize];
|
zerobuff.resize(buffsize);
|
||||||
|
static std::vector< float > outbuff;
|
||||||
|
outbuff.resize(buffsize);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < buffsize; i++)
|
for (unsigned int i = 0; i < buffsize; i++)
|
||||||
zerobuff[i] = 0;
|
zerobuff[i] = 0;
|
||||||
@ -492,7 +495,7 @@ void ALSAAudioOutput::run() {
|
|||||||
// Fill buffer
|
// Fill buffer
|
||||||
if (bOk && pcm_handle)
|
if (bOk && pcm_handle)
|
||||||
for (unsigned int i = 0; i < buffer_size / period_size; i++)
|
for (unsigned int i = 0; i < buffer_size / period_size; i++)
|
||||||
snd_pcm_writei(pcm_handle, zerobuff, period_size);
|
snd_pcm_writei(pcm_handle, zerobuff.data(), period_size);
|
||||||
|
|
||||||
if (!bOk) {
|
if (!bOk) {
|
||||||
Global::get().mw->msgBox(
|
Global::get().mw->msgBox(
|
||||||
@ -518,25 +521,25 @@ void ALSAAudioOutput::run() {
|
|||||||
initializeMixer(chanmasks);
|
initializeMixer(chanmasks);
|
||||||
|
|
||||||
count = snd_pcm_poll_descriptors_count(pcm_handle);
|
count = snd_pcm_poll_descriptors_count(pcm_handle);
|
||||||
snd_pcm_poll_descriptors(pcm_handle, fds, count);
|
snd_pcm_poll_descriptors(pcm_handle, fds, static_cast< unsigned int >(count));
|
||||||
|
|
||||||
qml.unlock();
|
qml.unlock();
|
||||||
|
|
||||||
while (bRunning && bOk) {
|
while (bRunning && bOk) {
|
||||||
poll(fds, count, 20);
|
poll(fds, static_cast< nfds_t >(count), 20);
|
||||||
unsigned short revents;
|
unsigned short revents;
|
||||||
|
|
||||||
snd_pcm_poll_descriptors_revents(pcm_handle, fds, count, &revents);
|
snd_pcm_poll_descriptors_revents(pcm_handle, fds, static_cast< unsigned int >(count), &revents);
|
||||||
if (revents & POLLERR) {
|
if (revents & POLLERR) {
|
||||||
snd_pcm_prepare(pcm_handle);
|
snd_pcm_prepare(pcm_handle);
|
||||||
} else if (revents & POLLOUT) {
|
} else if (revents & POLLOUT) {
|
||||||
snd_pcm_sframes_t avail{};
|
snd_pcm_sframes_t avail{};
|
||||||
ALSA_ERRCHECK(avail = snd_pcm_avail_update(pcm_handle));
|
ALSA_ERRCHECK(avail = snd_pcm_avail_update(pcm_handle));
|
||||||
while (avail >= static_cast< int >(period_size)) {
|
while (avail >= static_cast< int >(period_size)) {
|
||||||
stillRun = mix(outbuff, static_cast< int >(period_size));
|
stillRun = mix(outbuff.data(), static_cast< unsigned int >(period_size));
|
||||||
if (stillRun) {
|
if (stillRun) {
|
||||||
snd_pcm_sframes_t w = 0;
|
snd_pcm_sframes_t w = 0;
|
||||||
ALSA_ERRCHECK(w = snd_pcm_writei(pcm_handle, outbuff, period_size));
|
ALSA_ERRCHECK(w = snd_pcm_writei(pcm_handle, outbuff.data(), period_size));
|
||||||
if (w < 0) {
|
if (w < 0) {
|
||||||
avail = w;
|
avail = w;
|
||||||
break;
|
break;
|
||||||
@ -550,13 +553,13 @@ void ALSAAudioOutput::run() {
|
|||||||
snd_pcm_drain(pcm_handle);
|
snd_pcm_drain(pcm_handle);
|
||||||
ALSA_ERRCHECK(snd_pcm_prepare(pcm_handle));
|
ALSA_ERRCHECK(snd_pcm_prepare(pcm_handle));
|
||||||
for (unsigned int i = 0; i < buffer_size / period_size; ++i)
|
for (unsigned int i = 0; i < buffer_size / period_size; ++i)
|
||||||
ALSA_ERRCHECK(snd_pcm_writei(pcm_handle, zerobuff, period_size));
|
ALSA_ERRCHECK(snd_pcm_writei(pcm_handle, zerobuff.data(), period_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stillRun) {
|
if (!stillRun) {
|
||||||
snd_pcm_drain(pcm_handle);
|
snd_pcm_drain(pcm_handle);
|
||||||
|
|
||||||
while (bRunning && !mix(outbuff, static_cast< unsigned int >(period_size))) {
|
while (bRunning && !mix(outbuff.data(), static_cast< unsigned int >(period_size))) {
|
||||||
this->msleep(10);
|
this->msleep(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,9 +570,9 @@ void ALSAAudioOutput::run() {
|
|||||||
|
|
||||||
// Fill one frame
|
// Fill one frame
|
||||||
for (unsigned int i = 0; i < (buffer_size / period_size) - 1; i++)
|
for (unsigned int i = 0; i < (buffer_size / period_size) - 1; i++)
|
||||||
snd_pcm_writei(pcm_handle, zerobuff, period_size);
|
snd_pcm_writei(pcm_handle, zerobuff.data(), period_size);
|
||||||
|
|
||||||
snd_pcm_writei(pcm_handle, outbuff, period_size);
|
snd_pcm_writei(pcm_handle, outbuff.data(), period_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,8 +67,8 @@ struct MumbleAPICurator {
|
|||||||
/// This class is a singleton as a way to be able to write C function wrappers for the member functions
|
/// This class is a singleton as a way to be able to write C function wrappers for the member functions
|
||||||
/// that are needed for passing to the plugins.
|
/// that are needed for passing to the plugins.
|
||||||
class MumbleAPI : public QObject {
|
class MumbleAPI : public QObject {
|
||||||
Q_OBJECT;
|
Q_OBJECT
|
||||||
Q_DISABLE_COPY(MumbleAPI);
|
Q_DISABLE_COPY(MumbleAPI)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static MumbleAPI &get();
|
static MumbleAPI &get();
|
||||||
@ -197,15 +197,15 @@ public:
|
|||||||
/// @returns A reference to the PluginData singleton
|
/// @returns A reference to the PluginData singleton
|
||||||
static PluginData &get();
|
static PluginData &get();
|
||||||
}; // class PluginData
|
}; // class PluginData
|
||||||
}; // namespace API
|
} // namespace API
|
||||||
|
|
||||||
|
|
||||||
// Declare the meta-types that we require in order for the API to work
|
// Declare the meta-types that we require in order for the API to work
|
||||||
Q_DECLARE_METATYPE(mumble_settings_key_t);
|
Q_DECLARE_METATYPE(mumble_settings_key_t)
|
||||||
Q_DECLARE_METATYPE(mumble_settings_key_t *);
|
Q_DECLARE_METATYPE(mumble_settings_key_t *)
|
||||||
Q_DECLARE_METATYPE(mumble_transmission_mode_t);
|
Q_DECLARE_METATYPE(mumble_transmission_mode_t)
|
||||||
Q_DECLARE_METATYPE(mumble_transmission_mode_t *);
|
Q_DECLARE_METATYPE(mumble_transmission_mode_t *)
|
||||||
Q_DECLARE_METATYPE(std::shared_ptr< API::api_promise_t >);
|
Q_DECLARE_METATYPE(std::shared_ptr< API::api_promise_t >)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
///////////// SYNCHRONIZATION STRATEGY ///////////////////////
|
///////////// SYNCHRONIZATION STRATEGY ///////////////////////
|
||||||
|
|||||||
@ -32,6 +32,7 @@
|
|||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <cstdint>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -141,7 +142,7 @@ MumbleAPI::MumbleAPI() {
|
|||||||
REGISTER_METATYPE(mumble_transmission_mode_t);
|
REGISTER_METATYPE(mumble_transmission_mode_t);
|
||||||
REGISTER_METATYPE(mumble_userid_t);
|
REGISTER_METATYPE(mumble_userid_t);
|
||||||
REGISTER_METATYPE(mumble_userid_t);
|
REGISTER_METATYPE(mumble_userid_t);
|
||||||
REGISTER_METATYPE(size_t);
|
REGISTER_METATYPE(std::size_t);
|
||||||
REGISTER_METATYPE(uint8_t);
|
REGISTER_METATYPE(uint8_t);
|
||||||
|
|
||||||
// Define additional types that can't be defined using macro REGISTER_METATYPE
|
// Define additional types that can't be defined using macro REGISTER_METATYPE
|
||||||
@ -300,7 +301,7 @@ void MumbleAPI::getUserName_v_1_0_x(mumble_plugin_id_t callerID, mumble_connecti
|
|||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
// +1 for NULL terminator
|
// +1 for NULL terminator
|
||||||
size_t size = user->qsName.toUtf8().size() + 1;
|
std::size_t size = static_cast< std::size_t >(user->qsName.toUtf8().size() + 1);
|
||||||
|
|
||||||
char *nameArray = reinterpret_cast< char * >(malloc(size * sizeof(char)));
|
char *nameArray = reinterpret_cast< char * >(malloc(size * sizeof(char)));
|
||||||
|
|
||||||
@ -340,11 +341,11 @@ void MumbleAPI::getChannelName_v_1_0_x(mumble_plugin_id_t callerID, mumble_conne
|
|||||||
VERIFY_CONNECTION(connection);
|
VERIFY_CONNECTION(connection);
|
||||||
ENSURE_CONNECTION_SYNCHRONIZED(connection);
|
ENSURE_CONNECTION_SYNCHRONIZED(connection);
|
||||||
|
|
||||||
const Channel *channel = Channel::get(channelID);
|
const Channel *channel = Channel::get(static_cast< unsigned int >(channelID));
|
||||||
|
|
||||||
if (channel) {
|
if (channel) {
|
||||||
// +1 for NULL terminator
|
// +1 for NULL terminator
|
||||||
size_t size = channel->qsName.toUtf8().size() + 1;
|
std::size_t size = static_cast< std::size_t >(channel->qsName.toUtf8().size() + 1);
|
||||||
|
|
||||||
char *nameArray = reinterpret_cast< char * >(malloc(size * sizeof(char)));
|
char *nameArray = reinterpret_cast< char * >(malloc(size * sizeof(char)));
|
||||||
|
|
||||||
@ -362,13 +363,13 @@ void MumbleAPI::getChannelName_v_1_0_x(mumble_plugin_id_t callerID, mumble_conne
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MumbleAPI::getAllUsers_v_1_0_x(mumble_plugin_id_t callerID, mumble_connection_t connection,
|
void MumbleAPI::getAllUsers_v_1_0_x(mumble_plugin_id_t callerID, mumble_connection_t connection,
|
||||||
mumble_userid_t **users, size_t *userCount,
|
mumble_userid_t **users, std::size_t *userCount,
|
||||||
std::shared_ptr< api_promise_t > promise) {
|
std::shared_ptr< api_promise_t > promise) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
// Invoke in main thread
|
// Invoke in main thread
|
||||||
QMetaObject::invokeMethod(this, "getAllUsers_v_1_0_x", Qt::QueuedConnection,
|
QMetaObject::invokeMethod(this, "getAllUsers_v_1_0_x", Qt::QueuedConnection,
|
||||||
Q_ARG(mumble_plugin_id_t, callerID), Q_ARG(mumble_connection_t, connection),
|
Q_ARG(mumble_plugin_id_t, callerID), Q_ARG(mumble_connection_t, connection),
|
||||||
Q_ARG(mumble_userid_t **, users), Q_ARG(size_t *, userCount),
|
Q_ARG(mumble_userid_t **, users), Q_ARG(std::size_t *, userCount),
|
||||||
Q_ARG(std::shared_ptr< api_promise_t >, promise));
|
Q_ARG(std::shared_ptr< api_promise_t >, promise));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -386,7 +387,7 @@ void MumbleAPI::getAllUsers_v_1_0_x(mumble_plugin_id_t callerID, mumble_connecti
|
|||||||
|
|
||||||
QReadLocker userLock(&ClientUser::c_qrwlUsers);
|
QReadLocker userLock(&ClientUser::c_qrwlUsers);
|
||||||
|
|
||||||
size_t amount = ClientUser::c_qmUsers.size();
|
std::size_t amount = static_cast< std::size_t >(ClientUser::c_qmUsers.size());
|
||||||
|
|
||||||
auto it = ClientUser::c_qmUsers.constBegin();
|
auto it = ClientUser::c_qmUsers.constBegin();
|
||||||
|
|
||||||
@ -409,13 +410,13 @@ void MumbleAPI::getAllUsers_v_1_0_x(mumble_plugin_id_t callerID, mumble_connecti
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MumbleAPI::getAllChannels_v_1_0_x(mumble_plugin_id_t callerID, mumble_connection_t connection,
|
void MumbleAPI::getAllChannels_v_1_0_x(mumble_plugin_id_t callerID, mumble_connection_t connection,
|
||||||
mumble_channelid_t **channels, size_t *channelCount,
|
mumble_channelid_t **channels, std::size_t *channelCount,
|
||||||
std::shared_ptr< api_promise_t > promise) {
|
std::shared_ptr< api_promise_t > promise) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
// Invoke in main thread
|
// Invoke in main thread
|
||||||
QMetaObject::invokeMethod(this, "getAllChannels_v_1_0_x", Qt::QueuedConnection,
|
QMetaObject::invokeMethod(this, "getAllChannels_v_1_0_x", Qt::QueuedConnection,
|
||||||
Q_ARG(mumble_plugin_id_t, callerID), Q_ARG(mumble_connection_t, connection),
|
Q_ARG(mumble_plugin_id_t, callerID), Q_ARG(mumble_connection_t, connection),
|
||||||
Q_ARG(mumble_channelid_t **, channels), Q_ARG(size_t *, channelCount),
|
Q_ARG(mumble_channelid_t **, channels), Q_ARG(std::size_t *, channelCount),
|
||||||
Q_ARG(std::shared_ptr< api_promise_t >, promise));
|
Q_ARG(std::shared_ptr< api_promise_t >, promise));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -433,7 +434,7 @@ void MumbleAPI::getAllChannels_v_1_0_x(mumble_plugin_id_t callerID, mumble_conne
|
|||||||
|
|
||||||
QReadLocker channelLock(&Channel::c_qrwlChannels);
|
QReadLocker channelLock(&Channel::c_qrwlChannels);
|
||||||
|
|
||||||
size_t amount = Channel::c_qhChannels.size();
|
std::size_t amount = static_cast< std::size_t >(Channel::c_qhChannels.size());
|
||||||
|
|
||||||
auto it = Channel::c_qhChannels.constBegin();
|
auto it = Channel::c_qhChannels.constBegin();
|
||||||
|
|
||||||
@ -442,7 +443,7 @@ void MumbleAPI::getAllChannels_v_1_0_x(mumble_plugin_id_t callerID, mumble_conne
|
|||||||
|
|
||||||
unsigned int index = 0;
|
unsigned int index = 0;
|
||||||
while (it != Channel::c_qhChannels.constEnd()) {
|
while (it != Channel::c_qhChannels.constEnd()) {
|
||||||
channelIDs[index] = it.key();
|
channelIDs[index] = static_cast< mumble_channelid_t >(it.key());
|
||||||
|
|
||||||
it++;
|
it++;
|
||||||
index++;
|
index++;
|
||||||
@ -486,7 +487,7 @@ void MumbleAPI::getChannelOfUser_v_1_0_x(mumble_plugin_id_t callerID, mumble_con
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (user->cChannel) {
|
if (user->cChannel) {
|
||||||
*channelID = user->cChannel->iId;
|
*channelID = static_cast< mumble_channelid_t >(user->cChannel->iId);
|
||||||
|
|
||||||
EXIT_WITH(MUMBLE_STATUS_OK);
|
EXIT_WITH(MUMBLE_STATUS_OK);
|
||||||
} else {
|
} else {
|
||||||
@ -495,14 +496,14 @@ void MumbleAPI::getChannelOfUser_v_1_0_x(mumble_plugin_id_t callerID, mumble_con
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MumbleAPI::getUsersInChannel_v_1_0_x(mumble_plugin_id_t callerID, mumble_connection_t connection,
|
void MumbleAPI::getUsersInChannel_v_1_0_x(mumble_plugin_id_t callerID, mumble_connection_t connection,
|
||||||
mumble_channelid_t channelID, mumble_userid_t **users, size_t *userCount,
|
mumble_channelid_t channelID, mumble_userid_t **users, std::size_t *userCount,
|
||||||
std::shared_ptr< api_promise_t > promise) {
|
std::shared_ptr< api_promise_t > promise) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
// Invoke in main thread
|
// Invoke in main thread
|
||||||
QMetaObject::invokeMethod(this, "getUsersInChannel_v_1_0_x", Qt::QueuedConnection,
|
QMetaObject::invokeMethod(this, "getUsersInChannel_v_1_0_x", Qt::QueuedConnection,
|
||||||
Q_ARG(mumble_plugin_id_t, callerID), Q_ARG(mumble_connection_t, connection),
|
Q_ARG(mumble_plugin_id_t, callerID), Q_ARG(mumble_connection_t, connection),
|
||||||
Q_ARG(mumble_channelid_t, channelID), Q_ARG(mumble_userid_t **, users),
|
Q_ARG(mumble_channelid_t, channelID), Q_ARG(mumble_userid_t **, users),
|
||||||
Q_ARG(size_t *, userCount), Q_ARG(std::shared_ptr< api_promise_t >, promise));
|
Q_ARG(std::size_t *, userCount), Q_ARG(std::shared_ptr< api_promise_t >, promise));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -517,13 +518,13 @@ void MumbleAPI::getUsersInChannel_v_1_0_x(mumble_plugin_id_t callerID, mumble_co
|
|||||||
VERIFY_CONNECTION(connection);
|
VERIFY_CONNECTION(connection);
|
||||||
ENSURE_CONNECTION_SYNCHRONIZED(connection);
|
ENSURE_CONNECTION_SYNCHRONIZED(connection);
|
||||||
|
|
||||||
const Channel *channel = Channel::get(channelID);
|
const Channel *channel = Channel::get(static_cast< unsigned int >(channelID));
|
||||||
|
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
EXIT_WITH(MUMBLE_EC_CHANNEL_NOT_FOUND);
|
EXIT_WITH(MUMBLE_EC_CHANNEL_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t amount = channel->qlUsers.size();
|
std::size_t amount = static_cast< std::size_t >(channel->qlUsers.size());
|
||||||
|
|
||||||
mumble_userid_t *userIDs = reinterpret_cast< mumble_userid_t * >(malloc(sizeof(mumble_userid_t) * amount));
|
mumble_userid_t *userIDs = reinterpret_cast< mumble_userid_t * >(malloc(sizeof(mumble_userid_t) * amount));
|
||||||
|
|
||||||
@ -687,7 +688,7 @@ void MumbleAPI::getUserHash_v_1_0_x(mumble_plugin_id_t callerID, mumble_connecti
|
|||||||
|
|
||||||
// The user's hash is already in hexadecimal representation, so we don't have to worry about null-bytes in it
|
// The user's hash is already in hexadecimal representation, so we don't have to worry about null-bytes in it
|
||||||
// +1 for NULL terminator
|
// +1 for NULL terminator
|
||||||
size_t size = user->qsHash.toUtf8().size() + 1;
|
std::size_t size = static_cast< std::size_t >(user->qsHash.toUtf8().size() + 1);
|
||||||
|
|
||||||
char *hashArray = reinterpret_cast< char * >(malloc(size * sizeof(char)));
|
char *hashArray = reinterpret_cast< char * >(malloc(size * sizeof(char)));
|
||||||
|
|
||||||
@ -726,7 +727,7 @@ void MumbleAPI::getServerHash_v_1_0_x(mumble_plugin_id_t callerID, mumble_connec
|
|||||||
QString strHash = QString::fromLatin1(hashHex);
|
QString strHash = QString::fromLatin1(hashHex);
|
||||||
|
|
||||||
// +1 for NULL terminator
|
// +1 for NULL terminator
|
||||||
size_t size = strHash.toUtf8().size() + 1;
|
std::size_t size = static_cast< std::size_t >(strHash.toUtf8().size() + 1);
|
||||||
|
|
||||||
char *hashArray = reinterpret_cast< char * >(malloc(size * sizeof(char)));
|
char *hashArray = reinterpret_cast< char * >(malloc(size * sizeof(char)));
|
||||||
|
|
||||||
@ -758,7 +759,7 @@ void MumbleAPI::requestLocalUserTransmissionMode_v_1_0_x(mumble_plugin_id_t call
|
|||||||
|
|
||||||
VERIFY_PLUGIN_ID(callerID);
|
VERIFY_PLUGIN_ID(callerID);
|
||||||
|
|
||||||
Settings::AudioTransmit mode;
|
Settings::AudioTransmit mode = Settings::PushToTalk;
|
||||||
bool identifiedTransmissionMode = false;
|
bool identifiedTransmissionMode = false;
|
||||||
|
|
||||||
switch (transmissionMode) {
|
switch (transmissionMode) {
|
||||||
@ -828,7 +829,7 @@ void MumbleAPI::getUserComment_v_1_0_x(mumble_plugin_id_t callerID, mumble_conne
|
|||||||
}
|
}
|
||||||
|
|
||||||
// +1 for NULL terminator
|
// +1 for NULL terminator
|
||||||
size_t size = user->qsComment.toUtf8().size() + 1;
|
std::size_t size = static_cast< std::size_t >(user->qsComment.toUtf8().size() + 1);
|
||||||
|
|
||||||
char *nameArray = reinterpret_cast< char * >(malloc(size * sizeof(char)));
|
char *nameArray = reinterpret_cast< char * >(malloc(size * sizeof(char)));
|
||||||
|
|
||||||
@ -864,7 +865,7 @@ void MumbleAPI::getChannelDescription_v_1_0_x(mumble_plugin_id_t callerID, mumbl
|
|||||||
VERIFY_CONNECTION(connection);
|
VERIFY_CONNECTION(connection);
|
||||||
ENSURE_CONNECTION_SYNCHRONIZED(connection);
|
ENSURE_CONNECTION_SYNCHRONIZED(connection);
|
||||||
|
|
||||||
Channel *channel = Channel::get(channelID);
|
Channel *channel = Channel::get(static_cast< unsigned int >(channelID));
|
||||||
|
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
EXIT_WITH(MUMBLE_EC_CHANNEL_NOT_FOUND);
|
EXIT_WITH(MUMBLE_EC_CHANNEL_NOT_FOUND);
|
||||||
@ -880,7 +881,7 @@ void MumbleAPI::getChannelDescription_v_1_0_x(mumble_plugin_id_t callerID, mumbl
|
|||||||
}
|
}
|
||||||
|
|
||||||
// +1 for NULL terminator
|
// +1 for NULL terminator
|
||||||
size_t size = channel->qsDesc.toUtf8().size() + 1;
|
std::size_t size = static_cast< std::size_t >(channel->qsDesc.toUtf8().size() + 1);
|
||||||
|
|
||||||
char *nameArray = reinterpret_cast< char * >(malloc(size * sizeof(char)));
|
char *nameArray = reinterpret_cast< char * >(malloc(size * sizeof(char)));
|
||||||
|
|
||||||
@ -922,7 +923,7 @@ void MumbleAPI::requestUserMove_v_1_0_x(mumble_plugin_id_t callerID, mumble_conn
|
|||||||
EXIT_WITH(MUMBLE_EC_USER_NOT_FOUND);
|
EXIT_WITH(MUMBLE_EC_USER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Channel *channel = Channel::get(channelID);
|
const Channel *channel = Channel::get(static_cast< unsigned int >(channelID));
|
||||||
|
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
EXIT_WITH(MUMBLE_EC_CHANNEL_NOT_FOUND);
|
EXIT_WITH(MUMBLE_EC_CHANNEL_NOT_FOUND);
|
||||||
@ -935,7 +936,7 @@ void MumbleAPI::requestUserMove_v_1_0_x(mumble_plugin_id_t callerID, mumble_conn
|
|||||||
passwordList << QString::fromUtf8(password);
|
passwordList << QString::fromUtf8(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
Global::get().sh->joinChannel(user->uiSession, channel->iId, passwordList);
|
Global::get().sh->joinChannel(user->uiSession, static_cast< unsigned int >(channel->iId), passwordList);
|
||||||
}
|
}
|
||||||
|
|
||||||
EXIT_WITH(MUMBLE_STATUS_OK);
|
EXIT_WITH(MUMBLE_STATUS_OK);
|
||||||
@ -1163,7 +1164,7 @@ void MumbleAPI::findChannelByName_v_1_0_x(mumble_plugin_id_t callerID, mumble_co
|
|||||||
auto it = Channel::c_qhChannels.constBegin();
|
auto it = Channel::c_qhChannels.constBegin();
|
||||||
while (it != Channel::c_qhChannels.constEnd()) {
|
while (it != Channel::c_qhChannels.constEnd()) {
|
||||||
if (it.value()->qsName == qsChannelName) {
|
if (it.value()->qsName == qsChannelName) {
|
||||||
*channelID = it.key();
|
*channelID = static_cast< mumble_channelid_t >(it.key());
|
||||||
|
|
||||||
EXIT_WITH(MUMBLE_STATUS_OK);
|
EXIT_WITH(MUMBLE_STATUS_OK);
|
||||||
}
|
}
|
||||||
@ -1349,7 +1350,7 @@ void MumbleAPI::getMumbleSetting_string_v_1_0_x(mumble_plugin_id_t callerID, mum
|
|||||||
const QString stringValue = value.toString();
|
const QString stringValue = value.toString();
|
||||||
|
|
||||||
// +1 for NULL terminator
|
// +1 for NULL terminator
|
||||||
size_t size = stringValue.toUtf8().size() + 1;
|
std::size_t size = static_cast< std::size_t >(stringValue.toUtf8().size() + 1);
|
||||||
|
|
||||||
char *valueArray = reinterpret_cast< char * >(malloc(size * sizeof(char)));
|
char *valueArray = reinterpret_cast< char * >(malloc(size * sizeof(char)));
|
||||||
|
|
||||||
@ -1519,14 +1520,15 @@ void MumbleAPI::setMumbleSetting_string_v_1_0_x(mumble_plugin_id_t callerID, mum
|
|||||||
#undef IS_NOT_TYPE
|
#undef IS_NOT_TYPE
|
||||||
|
|
||||||
void MumbleAPI::sendData_v_1_0_x(mumble_plugin_id_t callerID, mumble_connection_t connection,
|
void MumbleAPI::sendData_v_1_0_x(mumble_plugin_id_t callerID, mumble_connection_t connection,
|
||||||
const mumble_userid_t *users, size_t userCount, const uint8_t *data, size_t dataLength,
|
const mumble_userid_t *users, std::size_t userCount, const uint8_t *data,
|
||||||
const char *dataID, std::shared_ptr< api_promise_t > promise) {
|
std::size_t dataLength, const char *dataID, std::shared_ptr< api_promise_t > promise) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
// Invoke in main thread
|
// Invoke in main thread
|
||||||
QMetaObject::invokeMethod(this, "sendData_v_1_0_x", Qt::QueuedConnection, Q_ARG(mumble_plugin_id_t, callerID),
|
QMetaObject::invokeMethod(this, "sendData_v_1_0_x", Qt::QueuedConnection, Q_ARG(mumble_plugin_id_t, callerID),
|
||||||
Q_ARG(mumble_connection_t, connection), Q_ARG(const mumble_userid_t *, users),
|
Q_ARG(mumble_connection_t, connection), Q_ARG(const mumble_userid_t *, users),
|
||||||
Q_ARG(size_t, userCount), Q_ARG(const uint8_t *, data), Q_ARG(size_t, dataLength),
|
Q_ARG(std::size_t, userCount), Q_ARG(const uint8_t *, data),
|
||||||
Q_ARG(const char *, dataID), Q_ARG(std::shared_ptr< api_promise_t >, promise));
|
Q_ARG(std::size_t, dataLength), Q_ARG(const char *, dataID),
|
||||||
|
Q_ARG(std::shared_ptr< api_promise_t >, promise));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1551,7 +1553,7 @@ void MumbleAPI::sendData_v_1_0_x(mumble_plugin_id_t callerID, mumble_connection_
|
|||||||
MumbleProto::PluginDataTransmission mpdt;
|
MumbleProto::PluginDataTransmission mpdt;
|
||||||
mpdt.set_sendersession(Global::get().uiSession);
|
mpdt.set_sendersession(Global::get().uiSession);
|
||||||
|
|
||||||
for (size_t i = 0; i < userCount; i++) {
|
for (std::size_t i = 0; i < userCount; i++) {
|
||||||
const ClientUser *user = ClientUser::get(users[i]);
|
const ClientUser *user = ClientUser::get(users[i]);
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
@ -2156,7 +2158,7 @@ PluginData &PluginData::get() {
|
|||||||
|
|
||||||
return *instance;
|
return *instance;
|
||||||
}
|
}
|
||||||
}; // namespace API
|
} // namespace API
|
||||||
|
|
||||||
#undef EXIT_WITH
|
#undef EXIT_WITH
|
||||||
#undef VERIFY_PLUGIN_ID
|
#undef VERIFY_PLUGIN_ID
|
||||||
|
|||||||
@ -158,7 +158,7 @@ ASIOConfig::ASIOConfig(Settings &st) : ConfigWidget(st) {
|
|||||||
DWORD idx = 0;
|
DWORD idx = 0;
|
||||||
DWORD keynamelen = keynamebufsize;
|
DWORD keynamelen = keynamebufsize;
|
||||||
while (RegEnumKeyEx(hkDevs, idx++, keyname, &keynamelen, nullptr, nullptr, nullptr, &ft) == ERROR_SUCCESS) {
|
while (RegEnumKeyEx(hkDevs, idx++, keyname, &keynamelen, nullptr, nullptr, nullptr, &ft) == ERROR_SUCCESS) {
|
||||||
QString name = QString::fromUtf16(reinterpret_cast< ushort * >(keyname), keynamelen);
|
QString deviceName = QString::fromUtf16(reinterpret_cast< ushort * >(keyname), keynamelen);
|
||||||
HKEY hk;
|
HKEY hk;
|
||||||
if (RegOpenKeyEx(hkDevs, keyname, 0, KEY_READ, &hk) == ERROR_SUCCESS) {
|
if (RegOpenKeyEx(hkDevs, keyname, 0, KEY_READ, &hk) == ERROR_SUCCESS) {
|
||||||
DWORD dtype = REG_SZ;
|
DWORD dtype = REG_SZ;
|
||||||
@ -172,7 +172,7 @@ ASIOConfig::ASIOConfig(Settings &st) : ConfigWidget(st) {
|
|||||||
QString::fromUtf16(reinterpret_cast< ushort * >(wclsid), datasize / 2).toLower().trimmed();
|
QString::fromUtf16(reinterpret_cast< ushort * >(wclsid), datasize / 2).toLower().trimmed();
|
||||||
CLSID clsid;
|
CLSID clsid;
|
||||||
if (!blacklist.contains(qsCls) && !FAILED(CLSIDFromString(wclsid, &clsid))) {
|
if (!blacklist.contains(qsCls) && !FAILED(CLSIDFromString(wclsid, &clsid))) {
|
||||||
ASIODev ad(name, qsCls);
|
ASIODev ad(std::move(deviceName), qsCls);
|
||||||
qlDevs << ad;
|
qlDevs << ad;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -507,7 +507,7 @@ ASIOInput::ASIOInput() {
|
|||||||
|
|
||||||
iEchoChannels = iNumSpeaker;
|
iEchoChannels = iNumSpeaker;
|
||||||
iMicChannels = iNumMic;
|
iMicChannels = iNumMic;
|
||||||
iEchoFreq = iMicFreq = iroundf(srate);
|
iEchoFreq = iMicFreq = static_cast< int >(srate);
|
||||||
|
|
||||||
initializeMixer();
|
initializeMixer();
|
||||||
|
|
||||||
@ -596,15 +596,16 @@ void ASIOInput::addBuffer(ASIOSampleType sampType, int interleave, void *src, fl
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ASIOInput::bufferReady(long buffindex) {
|
void ASIOInput::bufferReady(long buffindex) {
|
||||||
STACKVAR(float, buffer, lBufSize *qMax(iNumMic, iNumSpeaker));
|
static std::vector< float > buffer;
|
||||||
|
buffer.resize(lBufSize * qMax(iNumMic, iNumSpeaker));
|
||||||
|
|
||||||
for (int c = 0; c < iNumSpeaker; ++c)
|
for (int c = 0; c < iNumSpeaker; ++c)
|
||||||
addBuffer(aciInfo[iNumMic + c].type, iNumSpeaker, abiInfo[iNumMic + c].buffers[buffindex], buffer + c);
|
addBuffer(aciInfo[iNumMic + c].type, iNumSpeaker, abiInfo[iNumMic + c].buffers[buffindex], buffer.data() + c);
|
||||||
addEcho(buffer, lBufSize);
|
addEcho(buffer.data(), lBufSize);
|
||||||
|
|
||||||
for (int c = 0; c < iNumMic; ++c)
|
for (int c = 0; c < iNumMic; ++c)
|
||||||
addBuffer(aciInfo[c].type, iNumMic, abiInfo[c].buffers[buffindex], buffer + c);
|
addBuffer(aciInfo[c].type, iNumMic, abiInfo[c].buffers[buffindex], buffer.data() + c);
|
||||||
addMic(buffer, lBufSize);
|
addMic(buffer.data(), lBufSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASIOInput::bufferSwitch(long index, ASIOBool processNow) {
|
void ASIOInput::bufferSwitch(long index, ASIOBool processNow) {
|
||||||
|
|||||||
@ -43,16 +43,16 @@ void LoopUser::addFrame(const Mumble::Protocol::AudioData &audioData) {
|
|||||||
QMutexLocker l(&qmLock);
|
QMutexLocker l(&qmLock);
|
||||||
bool restart = (qetLastFetch.elapsed() > 100);
|
bool restart = (qetLastFetch.elapsed() > 100);
|
||||||
|
|
||||||
double time = qetTicker.elapsed();
|
long time = qetTicker.elapsed();
|
||||||
|
|
||||||
double r;
|
float r;
|
||||||
if (restart)
|
if (restart)
|
||||||
r = 0.0;
|
r = 0;
|
||||||
else
|
else
|
||||||
r = DOUBLE_RAND * Global::get().s.dMaxPacketDelay;
|
r = static_cast< float >(DOUBLE_RAND * Global::get().s.dMaxPacketDelay);
|
||||||
|
|
||||||
|
|
||||||
float virtualArrivalTime = time + r;
|
float virtualArrivalTime = static_cast< float >(time) + r;
|
||||||
// Insert default-constructed AudioPacket object and only then fill its data in-place. This is necessary to
|
// Insert default-constructed AudioPacket object and only then fill its data in-place. This is necessary to
|
||||||
// avoid any moving around of the payload vector which would mess up our pointers in the AudioData object.
|
// avoid any moving around of the payload vector which would mess up our pointers in the AudioData object.
|
||||||
m_packets[virtualArrivalTime] = AudioPacket{};
|
m_packets[virtualArrivalTime] = AudioPacket{};
|
||||||
@ -87,7 +87,7 @@ void LoopUser::fetchFrames() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double cmp = qetTicker.elapsed();
|
float cmp = static_cast< float >(qetTicker.elapsed());
|
||||||
|
|
||||||
auto it = m_packets.begin();
|
auto it = m_packets.begin();
|
||||||
while (it != m_packets.end()) {
|
while (it != m_packets.end()) {
|
||||||
|
|||||||
@ -25,7 +25,8 @@
|
|||||||
// A Wikipedia article claims the average distance between ears is 15.2 cm for men
|
// A Wikipedia article claims the average distance between ears is 15.2 cm for men
|
||||||
// (0.44 ms) and 14.4 cm for women (0.42 ms). We decided to set the delay to 0.43 ms.
|
// (0.44 ms) and 14.4 cm for women (0.42 ms). We decided to set the delay to 0.43 ms.
|
||||||
// The delay is calculated from the distance and the speed of sound.
|
// The delay is calculated from the distance and the speed of sound.
|
||||||
constexpr float INTERAURAL_DELAY = 0.00043 / (1 / static_cast< float >(SAMPLE_RATE));
|
constexpr unsigned int INTERAURAL_DELAY =
|
||||||
|
static_cast< unsigned int >(0.00043f / (1 / static_cast< float >(SAMPLE_RATE)));
|
||||||
|
|
||||||
typedef QPair< QString, QVariant > audioDevice;
|
typedef QPair< QString, QVariant > audioDevice;
|
||||||
|
|
||||||
|
|||||||
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
#include <QSignalBlocker>
|
#include <QSignalBlocker>
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
const QString AudioOutputDialog::name = QLatin1String("AudioOutputWidget");
|
const QString AudioOutputDialog::name = QLatin1String("AudioOutputWidget");
|
||||||
const QString AudioInputDialog::name = QLatin1String("AudioInputWidget");
|
const QString AudioInputDialog::name = QLatin1String("AudioInputWidget");
|
||||||
|
|
||||||
@ -134,10 +136,10 @@ void AudioInputDialog::load(const Settings &r) {
|
|||||||
|
|
||||||
loadComboBox(qcbTransmit, r.atTransmit);
|
loadComboBox(qcbTransmit, r.atTransmit);
|
||||||
loadSlider(qsTransmitHold, r.iVoiceHold);
|
loadSlider(qsTransmitHold, r.iVoiceHold);
|
||||||
loadSlider(qsTransmitMin, iroundf(r.fVADmin * 32767.0f + 0.5f));
|
loadSlider(qsTransmitMin, static_cast< int >(r.fVADmin * 32767.0f + 0.5f));
|
||||||
loadSlider(qsTransmitMax, iroundf(r.fVADmax * 32767.0f + 0.5f));
|
loadSlider(qsTransmitMax, static_cast< int >(r.fVADmax * 32767.0f + 0.5f));
|
||||||
loadSlider(qsFrames, (r.iFramesPerPacket == 1) ? 1 : (r.iFramesPerPacket / 2 + 1));
|
loadSlider(qsFrames, (r.iFramesPerPacket == 1) ? 1 : (r.iFramesPerPacket / 2 + 1));
|
||||||
loadSlider(qsDoublePush, iroundf(static_cast< float >(r.uiDoublePush) / 1000.f + 0.5f));
|
loadSlider(qsDoublePush, static_cast< int >(static_cast< float >(r.uiDoublePush) / 1000.f + 0.5f));
|
||||||
loadSlider(qsPTTHold, static_cast< int >(r.pttHold));
|
loadSlider(qsPTTHold, static_cast< int >(r.pttHold));
|
||||||
|
|
||||||
if (r.vsVAD == Settings::Amplitude)
|
if (r.vsVAD == Settings::Amplitude)
|
||||||
@ -206,7 +208,7 @@ void AudioInputDialog::load(const Settings &r) {
|
|||||||
loadSlider(qsAmp, 20000 - r.iMinLoudness);
|
loadSlider(qsAmp, 20000 - r.iMinLoudness);
|
||||||
|
|
||||||
// Idle auto actions
|
// Idle auto actions
|
||||||
qsbIdle->setValue(r.iIdleTime / 60);
|
qsbIdle->setValue(static_cast< int >(r.iIdleTime) / 60);
|
||||||
loadComboBox(qcbIdleAction, r.iaeIdleAction);
|
loadComboBox(qcbIdleAction, r.iaeIdleAction);
|
||||||
loadCheckBox(qcbUndoIdleAction, r.bUndoIdleActionUponActivity);
|
loadCheckBox(qcbUndoIdleAction, r.bUndoIdleActionUponActivity);
|
||||||
|
|
||||||
@ -261,12 +263,12 @@ void AudioInputDialog::save() const {
|
|||||||
s.vsVAD = qrbSNR->isChecked() ? Settings::SignalToNoise : Settings::Amplitude;
|
s.vsVAD = qrbSNR->isChecked() ? Settings::SignalToNoise : Settings::Amplitude;
|
||||||
s.iFramesPerPacket = qsFrames->value();
|
s.iFramesPerPacket = qsFrames->value();
|
||||||
s.iFramesPerPacket = (s.iFramesPerPacket == 1) ? 1 : ((s.iFramesPerPacket - 1) * 2);
|
s.iFramesPerPacket = (s.iFramesPerPacket == 1) ? 1 : ((s.iFramesPerPacket - 1) * 2);
|
||||||
s.uiDoublePush = qsDoublePush->value() * 1000;
|
s.uiDoublePush = static_cast< unsigned int >(qsDoublePush->value() * 1000);
|
||||||
s.pttHold = qsPTTHold->value();
|
s.pttHold = static_cast< quint64 >(qsPTTHold->value());
|
||||||
s.atTransmit = static_cast< Settings::AudioTransmit >(qcbTransmit->currentIndex());
|
s.atTransmit = static_cast< Settings::AudioTransmit >(qcbTransmit->currentIndex());
|
||||||
|
|
||||||
// Idle auto actions
|
// Idle auto actions
|
||||||
s.iIdleTime = qsbIdle->value() * 60;
|
s.iIdleTime = static_cast< unsigned int >(qsbIdle->value() * 60);
|
||||||
s.iaeIdleAction = static_cast< Settings::IdleAction >(qcbIdleAction->currentIndex());
|
s.iaeIdleAction = static_cast< Settings::IdleAction >(qcbIdleAction->currentIndex());
|
||||||
s.bUndoIdleActionUponActivity = qcbUndoIdleAction->isChecked();
|
s.bUndoIdleActionUponActivity = qcbUndoIdleAction->isChecked();
|
||||||
|
|
||||||
@ -537,14 +539,14 @@ void AudioInputDialog::updateEchoEnableState() {
|
|||||||
qcbEcho->setItemData(0, tr("Disable echo cancellation."), Qt::ToolTipRole);
|
qcbEcho->setItemData(0, tr("Disable echo cancellation."), Qt::ToolTipRole);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (EchoCancelOptionID ecoid : air->echoOptions) {
|
for (EchoCancelOptionID echoid : air->echoOptions) {
|
||||||
if (air->canEcho(ecoid, outputInterface)) {
|
if (air->canEcho(echoid, outputInterface)) {
|
||||||
++i;
|
++i;
|
||||||
hasUsableEchoOption = true;
|
hasUsableEchoOption = true;
|
||||||
const EchoCancelOption &echoOption = EchoCancelOption::getOptions()[static_cast< int >(ecoid)];
|
const EchoCancelOption &echoOption = EchoCancelOption::getOptions()[static_cast< std::size_t >(echoid)];
|
||||||
qcbEcho->insertItem(i, echoOption.description, static_cast< int >(ecoid));
|
qcbEcho->insertItem(i, echoOption.description, static_cast< int >(echoid));
|
||||||
qcbEcho->setItemData(i, echoOption.explanation, Qt::ToolTipRole);
|
qcbEcho->setItemData(i, echoOption.explanation, Qt::ToolTipRole);
|
||||||
if (s.echoOption == ecoid) {
|
if (s.echoOption == echoid) {
|
||||||
qcbEcho->setCurrentIndex(i);
|
qcbEcho->setCurrentIndex(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -578,9 +580,9 @@ void AudioInputDialog::on_Tick_timeout() {
|
|||||||
abSpeech->iAbove = qsTransmitMax->value();
|
abSpeech->iAbove = qsTransmitMax->value();
|
||||||
|
|
||||||
if (qrbAmplitude->isChecked()) {
|
if (qrbAmplitude->isChecked()) {
|
||||||
abSpeech->iValue = iroundf((32767.f / 96.0f) * (96.0f + ai->dPeakCleanMic) + 0.5f);
|
abSpeech->iValue = static_cast< int >((32767.f / 96.0f) * (96.0f + ai->dPeakCleanMic) + 0.5f);
|
||||||
} else {
|
} else {
|
||||||
abSpeech->iValue = iroundf(ai->fSpeechProb * 32767.0f + 0.5f);
|
abSpeech->iValue = static_cast< int >(ai->fSpeechProb * 32767.0f + 0.5f);
|
||||||
}
|
}
|
||||||
abSpeech->update();
|
abSpeech->update();
|
||||||
}
|
}
|
||||||
@ -713,8 +715,8 @@ void AudioOutputDialog::load(const Settings &r) {
|
|||||||
|
|
||||||
loadCheckBox(qcbExclusive, r.bExclusiveOutput);
|
loadCheckBox(qcbExclusive, r.bExclusiveOutput);
|
||||||
loadSlider(qsDelay, r.iOutputDelay);
|
loadSlider(qsDelay, r.iOutputDelay);
|
||||||
loadSlider(qsVolume, iroundf(r.fVolume * 100.0f + 0.5f));
|
loadSlider(qsVolume, static_cast< int >(r.fVolume * 100.0f + 0.5f));
|
||||||
loadSlider(qsOtherVolume, iroundf((1.0f - r.fOtherVolume) * 100.0f + 0.5f));
|
loadSlider(qsOtherVolume, static_cast< int >((1.0f - r.fOtherVolume) * 100.0f + 0.5f));
|
||||||
loadCheckBox(qcbAttenuateOthersOnTalk, r.bAttenuateOthersOnTalk);
|
loadCheckBox(qcbAttenuateOthersOnTalk, r.bAttenuateOthersOnTalk);
|
||||||
loadCheckBox(qcbAttenuateOthers, r.bAttenuateOthers);
|
loadCheckBox(qcbAttenuateOthers, r.bAttenuateOthers);
|
||||||
loadCheckBox(qcbAttenuateUsersOnPrioritySpeak, r.bAttenuateUsersOnPrioritySpeak);
|
loadCheckBox(qcbAttenuateUsersOnPrioritySpeak, r.bAttenuateUsersOnPrioritySpeak);
|
||||||
@ -730,11 +732,11 @@ void AudioOutputDialog::load(const Settings &r) {
|
|||||||
loadSlider(qsJitter, r.iJitterBufferSize);
|
loadSlider(qsJitter, r.iJitterBufferSize);
|
||||||
loadComboBox(qcbLoopback, r.lmLoopMode);
|
loadComboBox(qcbLoopback, r.lmLoopMode);
|
||||||
loadSlider(qsPacketDelay, static_cast< int >(r.dMaxPacketDelay));
|
loadSlider(qsPacketDelay, static_cast< int >(r.dMaxPacketDelay));
|
||||||
loadSlider(qsPacketLoss, iroundf(r.dPacketLoss * 100.0f + 0.5f));
|
loadSlider(qsPacketLoss, static_cast< int >(r.dPacketLoss * 100.0f + 0.5f));
|
||||||
qsbMinimumDistance->setValue(r.fAudioMinDistance);
|
qsbMinimumDistance->setValue(r.fAudioMinDistance);
|
||||||
qsbMaximumDistance->setValue(r.fAudioMaxDistance);
|
qsbMaximumDistance->setValue(r.fAudioMaxDistance);
|
||||||
qsbMinimumVolume->setValue(r.fAudioMaxDistVolume * 100);
|
qsbMinimumVolume->setValue(static_cast< int >(r.fAudioMaxDistVolume * 100));
|
||||||
qsbBloom->setValue(r.fAudioBloom * 100);
|
qsbBloom->setValue(static_cast< int >(r.fAudioBloom * 100));
|
||||||
loadCheckBox(qcbHeadphones, r.bPositionalHeadphone);
|
loadCheckBox(qcbHeadphones, r.bPositionalHeadphone);
|
||||||
loadCheckBox(qcbPositional, r.bPositionalAudio);
|
loadCheckBox(qcbPositional, r.bPositionalAudio);
|
||||||
|
|
||||||
@ -858,7 +860,7 @@ void AudioOutputDialog::on_qcbLoopback_currentIndexChanged(int v) {
|
|||||||
|
|
||||||
void AudioOutputDialog::on_qsMinDistance_valueChanged(int value) {
|
void AudioOutputDialog::on_qsMinDistance_valueChanged(int value) {
|
||||||
QSignalBlocker blocker(qsbMinimumDistance);
|
QSignalBlocker blocker(qsbMinimumDistance);
|
||||||
qsbMinimumDistance->setValue(value / 10.0f);
|
qsbMinimumDistance->setValue(value / 10.0);
|
||||||
|
|
||||||
// Ensure that max distance is always a least 1m larger than min distance
|
// Ensure that max distance is always a least 1m larger than min distance
|
||||||
qsbMaximumDistance->setValue(std::max(qsbMaximumDistance->value(), (value / 10.0) + 1));
|
qsbMaximumDistance->setValue(std::max(qsbMaximumDistance->value(), (value / 10.0) + 1));
|
||||||
@ -866,7 +868,7 @@ void AudioOutputDialog::on_qsMinDistance_valueChanged(int value) {
|
|||||||
|
|
||||||
void AudioOutputDialog::on_qsbMinimumDistance_valueChanged(double value) {
|
void AudioOutputDialog::on_qsbMinimumDistance_valueChanged(double value) {
|
||||||
QSignalBlocker blocker(qsMinDistance);
|
QSignalBlocker blocker(qsMinDistance);
|
||||||
qsMinDistance->setValue(value * 10);
|
qsMinDistance->setValue(static_cast< int >(value * 10));
|
||||||
|
|
||||||
// Ensure that max distance is always a least 1m larger than min distance
|
// Ensure that max distance is always a least 1m larger than min distance
|
||||||
qsMaxDistance->setValue(std::max(qsMaxDistance->value(), static_cast< int >(value * 10) + 10));
|
qsMaxDistance->setValue(std::max(qsMaxDistance->value(), static_cast< int >(value * 10) + 10));
|
||||||
@ -874,14 +876,14 @@ void AudioOutputDialog::on_qsbMinimumDistance_valueChanged(double value) {
|
|||||||
|
|
||||||
void AudioOutputDialog::on_qsMaxDistance_valueChanged(int value) {
|
void AudioOutputDialog::on_qsMaxDistance_valueChanged(int value) {
|
||||||
QSignalBlocker blocker(qsbMaximumDistance);
|
QSignalBlocker blocker(qsbMaximumDistance);
|
||||||
qsbMaximumDistance->setValue(value / 10.0f);
|
qsbMaximumDistance->setValue(value / 10.0);
|
||||||
|
|
||||||
// Ensure that min distance is always a least 1m less than max distance
|
// Ensure that min distance is always a least 1m less than max distance
|
||||||
qsbMinimumDistance->setValue(std::min(qsbMinimumDistance->value(), (value / 10.0) - 1));
|
qsbMinimumDistance->setValue(std::min(qsbMinimumDistance->value(), (value / 10.0) - 1));
|
||||||
}
|
}
|
||||||
void AudioOutputDialog::on_qsbMaximumDistance_valueChanged(double value) {
|
void AudioOutputDialog::on_qsbMaximumDistance_valueChanged(double value) {
|
||||||
QSignalBlocker blocker(qsMaxDistance);
|
QSignalBlocker blocker(qsMaxDistance);
|
||||||
qsMaxDistance->setValue(value * 10);
|
qsMaxDistance->setValue(static_cast< int >(value * 10));
|
||||||
|
|
||||||
// Ensure that min distance is always a least 1m less than max distance
|
// Ensure that min distance is always a least 1m less than max distance
|
||||||
qsMinDistance->setValue(std::min(qsMinDistance->value(), static_cast< int >(value * 10) - 10));
|
qsMinDistance->setValue(std::min(qsMinDistance->value(), static_cast< int >(value * 10) - 10));
|
||||||
|
|||||||
@ -213,7 +213,8 @@ bool AudioInputRegistrar::isMicrophoneAccessDeniedByOS() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioInput::AudioInput() : opusBuffer(Global::get().s.iFramesPerPacket * (SAMPLE_RATE / 100)) {
|
AudioInput::AudioInput()
|
||||||
|
: opusBuffer(static_cast< std::size_t >(Global::get().s.iFramesPerPacket * (SAMPLE_RATE / 100))) {
|
||||||
bDebugDumpInput = Global::get().bDebugDumpInput;
|
bDebugDumpInput = Global::get().bDebugDumpInput;
|
||||||
resync.bDebugPrintQueue = Global::get().bDebugPrintQueue;
|
resync.bDebugPrintQueue = Global::get().bDebugPrintQueue;
|
||||||
if (bDebugDumpInput) {
|
if (bDebugDumpInput) {
|
||||||
@ -319,7 +320,7 @@ AudioInput::~AudioInput() {
|
|||||||
|
|
||||||
bool AudioInput::isTransmitting() const {
|
bool AudioInput::isTransmitting() const {
|
||||||
return bPreviousVoice;
|
return bPreviousVoice;
|
||||||
};
|
}
|
||||||
|
|
||||||
#define IN_MIXER_FLOAT(channels) \
|
#define IN_MIXER_FLOAT(channels) \
|
||||||
static void inMixerFloat##channels(float *RESTRICT buffer, const void *RESTRICT ipt, unsigned int nsamp, \
|
static void inMixerFloat##channels(float *RESTRICT buffer, const void *RESTRICT ipt, unsigned int nsamp, \
|
||||||
@ -356,7 +357,8 @@ static void inMixerFloatMask(float *RESTRICT buffer, const void *RESTRICT ipt, u
|
|||||||
const float *RESTRICT input = reinterpret_cast< const float * >(ipt);
|
const float *RESTRICT input = reinterpret_cast< const float * >(ipt);
|
||||||
|
|
||||||
unsigned int chancount = 0;
|
unsigned int chancount = 0;
|
||||||
STACKVAR(unsigned int, chanindex, N);
|
static std::vector< unsigned int > chanindex;
|
||||||
|
chanindex.resize(N);
|
||||||
for (unsigned int j = 0; j < N; ++j) {
|
for (unsigned int j = 0; j < N; ++j) {
|
||||||
if ((mask & (1ULL << j)) == 0) {
|
if ((mask & (1ULL << j)) == 0) {
|
||||||
continue;
|
continue;
|
||||||
@ -380,7 +382,8 @@ static void inMixerShortMask(float *RESTRICT buffer, const void *RESTRICT ipt, u
|
|||||||
const short *RESTRICT input = reinterpret_cast< const short * >(ipt);
|
const short *RESTRICT input = reinterpret_cast< const short * >(ipt);
|
||||||
|
|
||||||
unsigned int chancount = 0;
|
unsigned int chancount = 0;
|
||||||
STACKVAR(unsigned int, chanindex, N);
|
static std::vector< unsigned int > chanindex;
|
||||||
|
chanindex.resize(N);
|
||||||
for (unsigned int j = 0; j < N; ++j) {
|
for (unsigned int j = 0; j < N; ++j) {
|
||||||
if ((mask & (1ULL << j)) == 0) {
|
if ((mask & (1ULL << j)) == 0) {
|
||||||
continue;
|
continue;
|
||||||
@ -536,9 +539,10 @@ void AudioInput::initializeMixer() {
|
|||||||
imfMic = chooseMixer(iMicChannels, eMicFormat, uiMicChannelMask);
|
imfMic = chooseMixer(iMicChannels, eMicFormat, uiMicChannelMask);
|
||||||
imfEcho = chooseMixer(iEchoChannels, eEchoFormat, uiEchoChannelMask);
|
imfEcho = chooseMixer(iEchoChannels, eEchoFormat, uiEchoChannelMask);
|
||||||
|
|
||||||
iMicSampleSize = static_cast< int >(iMicChannels * ((eMicFormat == SampleFloat) ? sizeof(float) : sizeof(short)));
|
iMicSampleSize =
|
||||||
|
static_cast< unsigned int >(iMicChannels * ((eMicFormat == SampleFloat) ? sizeof(float) : sizeof(short)));
|
||||||
iEchoSampleSize =
|
iEchoSampleSize =
|
||||||
static_cast< int >(iEchoChannels * ((eEchoFormat == SampleFloat) ? sizeof(float) : sizeof(short)));
|
static_cast< unsigned int >(iEchoChannels * ((eEchoFormat == SampleFloat) ? sizeof(float) : sizeof(short)));
|
||||||
|
|
||||||
bResetProcessor = true;
|
bResetProcessor = true;
|
||||||
|
|
||||||
@ -653,7 +657,7 @@ void AudioInput::addEcho(const void *data, unsigned int nsamp) {
|
|||||||
|
|
||||||
// float -> 16bit PCM
|
// float -> 16bit PCM
|
||||||
const float mul = 32768.f;
|
const float mul = 32768.f;
|
||||||
for (int j = 0; j < iEchoFrameSize; ++j) {
|
for (unsigned int j = 0; j < iEchoFrameSize; ++j) {
|
||||||
outbuff[j] = static_cast< short >(qBound(-32768.f, (ptr[j] * mul), 32767.f));
|
outbuff[j] = static_cast< short >(qBound(-32768.f, (ptr[j] * mul), 32767.f));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -762,7 +766,7 @@ void AudioInput::resetAudioProcessor() {
|
|||||||
speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_SET_AGC_TARGET, &iArg);
|
speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_SET_AGC_TARGET, &iArg);
|
||||||
|
|
||||||
float v = 30000.0f / static_cast< float >(Global::get().s.iMinLoudness);
|
float v = 30000.0f / static_cast< float >(Global::get().s.iMinLoudness);
|
||||||
iArg = iroundf(floorf(20.0f * log10f(v)));
|
iArg = static_cast< int >(floorf(20.0f * log10f(v)));
|
||||||
speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_SET_AGC_MAX_GAIN, &iArg);
|
speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_SET_AGC_MAX_GAIN, &iArg);
|
||||||
|
|
||||||
iArg = -60;
|
iArg = -60;
|
||||||
@ -775,8 +779,9 @@ void AudioInput::resetAudioProcessor() {
|
|||||||
|
|
||||||
if (iEchoChannels > 0) {
|
if (iEchoChannels > 0) {
|
||||||
int filterSize = iFrameSize * (10 + resync.getNominalLag());
|
int filterSize = iFrameSize * (10 + resync.getNominalLag());
|
||||||
sesEcho = speex_echo_state_init_mc(iFrameSize, filterSize, 1, bEchoMulti ? iEchoChannels : 1);
|
sesEcho =
|
||||||
iArg = iSampleRate;
|
speex_echo_state_init_mc(iFrameSize, filterSize, 1, bEchoMulti ? static_cast< int >(iEchoChannels) : 1);
|
||||||
|
iArg = iSampleRate;
|
||||||
speex_echo_ctl(sesEcho, SPEEX_ECHO_SET_SAMPLING_RATE, &iArg);
|
speex_echo_ctl(sesEcho, SPEEX_ECHO_SET_SAMPLING_RATE, &iArg);
|
||||||
speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_SET_ECHO_STATE, sesEcho);
|
speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_SET_ECHO_STATE, sesEcho);
|
||||||
|
|
||||||
@ -859,7 +864,6 @@ int AudioInput::encodeOpusFrame(short *source, int size, EncodingOutputBuffer &b
|
|||||||
|
|
||||||
void AudioInput::encodeAudioFrame(AudioChunk chunk) {
|
void AudioInput::encodeAudioFrame(AudioChunk chunk) {
|
||||||
int iArg;
|
int iArg;
|
||||||
int i;
|
|
||||||
float sum;
|
float sum;
|
||||||
short max;
|
short max;
|
||||||
|
|
||||||
@ -872,14 +876,14 @@ void AudioInput::encodeAudioFrame(AudioChunk chunk) {
|
|||||||
// if the value of Global::get().iTarget changes during the execution of this function,
|
// if the value of Global::get().iTarget changes during the execution of this function,
|
||||||
// it won't cause any inconsistencies and the change is reflected once this
|
// it won't cause any inconsistencies and the change is reflected once this
|
||||||
// function is called again.
|
// function is called again.
|
||||||
int voiceTargetID = Global::get().iTarget;
|
std::int32_t voiceTargetID = Global::get().iTarget;
|
||||||
|
|
||||||
if (!bRunning)
|
if (!bRunning)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sum = 1.0f;
|
sum = 1.0f;
|
||||||
max = 1;
|
max = 1;
|
||||||
for (i = 0; i < iFrameSize; i++) {
|
for (unsigned int i = 0; i < iFrameSize; i++) {
|
||||||
sum += static_cast< float >(chunk.mic[i] * chunk.mic[i]);
|
sum += static_cast< float >(chunk.mic[i] * chunk.mic[i]);
|
||||||
max = std::max(static_cast< short >(abs(chunk.mic[i])), max);
|
max = std::max(static_cast< short >(abs(chunk.mic[i])), max);
|
||||||
}
|
}
|
||||||
@ -888,7 +892,7 @@ void AudioInput::encodeAudioFrame(AudioChunk chunk) {
|
|||||||
|
|
||||||
if (chunk.speaker && (iEchoChannels > 0)) {
|
if (chunk.speaker && (iEchoChannels > 0)) {
|
||||||
sum = 1.0f;
|
sum = 1.0f;
|
||||||
for (i = 0; i < iEchoFrameSize; ++i) {
|
for (unsigned int i = 0; i < iEchoFrameSize; ++i) {
|
||||||
sum += static_cast< float >(chunk.speaker[i] * chunk.speaker[i]);
|
sum += static_cast< float >(chunk.speaker[i] * chunk.speaker[i]);
|
||||||
}
|
}
|
||||||
dPeakSpeaker = qMax(20.0f * log10f(sqrtf(sum / static_cast< float >(iFrameSize)) / 32768.0f), -96.0f);
|
dPeakSpeaker = qMax(20.0f * log10f(sqrtf(sum / static_cast< float >(iFrameSize)) / 32768.0f), -96.0f);
|
||||||
@ -918,13 +922,13 @@ void AudioInput::encodeAudioFrame(AudioChunk chunk) {
|
|||||||
// At the time of writing this code, RNNoise only supports a sample rate of 48000 Hz.
|
// At the time of writing this code, RNNoise only supports a sample rate of 48000 Hz.
|
||||||
if (noiseCancel == Settings::NoiseCancelRNN || noiseCancel == Settings::NoiseCancelBoth) {
|
if (noiseCancel == Settings::NoiseCancelRNN || noiseCancel == Settings::NoiseCancelBoth) {
|
||||||
float denoiseFrames[480];
|
float denoiseFrames[480];
|
||||||
for (int i = 0; i < 480; i++) {
|
for (unsigned int i = 0; i < 480; i++) {
|
||||||
denoiseFrames[i] = psSource[i];
|
denoiseFrames[i] = psSource[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
rnnoise_process_frame(denoiseState, denoiseFrames, denoiseFrames);
|
rnnoise_process_frame(denoiseState, denoiseFrames, denoiseFrames);
|
||||||
|
|
||||||
for (int i = 0; i < 480; i++) {
|
for (unsigned int i = 0; i < 480; i++) {
|
||||||
psSource[i] = clampFloatSample(denoiseFrames[i]);
|
psSource[i] = clampFloatSample(denoiseFrames[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -933,7 +937,7 @@ void AudioInput::encodeAudioFrame(AudioChunk chunk) {
|
|||||||
speex_preprocess_run(sppPreprocess, psSource);
|
speex_preprocess_run(sppPreprocess, psSource);
|
||||||
|
|
||||||
sum = 1.0f;
|
sum = 1.0f;
|
||||||
for (i = 0; i < iFrameSize; i++)
|
for (unsigned int i = 0; i < iFrameSize; i++)
|
||||||
sum += static_cast< float >(psSource[i] * psSource[i]);
|
sum += static_cast< float >(psSource[i] * psSource[i]);
|
||||||
float micLevel = sqrtf(sum / static_cast< float >(iFrameSize));
|
float micLevel = sqrtf(sum / static_cast< float >(iFrameSize));
|
||||||
dPeakSignal = qMax(20.0f * log10f(micLevel / 32768.0f), -96.0f);
|
dPeakSignal = qMax(20.0f * log10f(micLevel / 32768.0f), -96.0f);
|
||||||
@ -941,9 +945,11 @@ void AudioInput::encodeAudioFrame(AudioChunk chunk) {
|
|||||||
if (bDebugDumpInput) {
|
if (bDebugDumpInput) {
|
||||||
outMic.write(reinterpret_cast< const char * >(chunk.mic), iFrameSize * sizeof(short));
|
outMic.write(reinterpret_cast< const char * >(chunk.mic), iFrameSize * sizeof(short));
|
||||||
if (chunk.speaker) {
|
if (chunk.speaker) {
|
||||||
outSpeaker.write(reinterpret_cast< const char * >(chunk.speaker), iEchoFrameSize * sizeof(short));
|
outSpeaker.write(reinterpret_cast< const char * >(chunk.speaker),
|
||||||
|
static_cast< std::streamsize >(iEchoFrameSize * sizeof(short)));
|
||||||
}
|
}
|
||||||
outProcessed.write(reinterpret_cast< const char * >(psSource), iFrameSize * sizeof(short));
|
outProcessed.write(reinterpret_cast< const char * >(psSource),
|
||||||
|
static_cast< std::streamsize >(iFrameSize * sizeof(short)));
|
||||||
}
|
}
|
||||||
|
|
||||||
spx_int32_t prob = 0;
|
spx_int32_t prob = 0;
|
||||||
@ -1013,7 +1019,7 @@ void AudioInput::encodeAudioFrame(AudioChunk chunk) {
|
|||||||
if (p) {
|
if (p) {
|
||||||
if (!bIsSpeech)
|
if (!bIsSpeech)
|
||||||
p->setTalking(Settings::Passive);
|
p->setTalking(Settings::Passive);
|
||||||
else if (voiceTargetID == 0)
|
else if (voiceTargetID == Mumble::Protocol::ReservedTargetIDs::REGULAR_SPEECH)
|
||||||
p->setTalking(Settings::Talking);
|
p->setTalking(Settings::Talking);
|
||||||
else
|
else
|
||||||
p->setTalking(Settings::Shouting);
|
p->setTalking(Settings::Shouting);
|
||||||
@ -1118,7 +1124,7 @@ void AudioInput::encodeAudioFrame(AudioChunk chunk) {
|
|||||||
// a codec configuration switch by suddenly using a wildly different
|
// a codec configuration switch by suddenly using a wildly different
|
||||||
// framecount per packet.
|
// framecount per packet.
|
||||||
const int missingFrames = iAudioFrames - iBufferedFrames;
|
const int missingFrames = iAudioFrames - iBufferedFrames;
|
||||||
opusBuffer.insert(opusBuffer.end(), iFrameSize * missingFrames, 0);
|
opusBuffer.insert(opusBuffer.end(), static_cast< std::size_t >(iFrameSize * missingFrames), 0);
|
||||||
iBufferedFrames += missingFrames;
|
iBufferedFrames += missingFrames;
|
||||||
iFrameCounter += missingFrames;
|
iFrameCounter += missingFrames;
|
||||||
}
|
}
|
||||||
@ -1150,18 +1156,18 @@ void AudioInput::encodeAudioFrame(AudioChunk chunk) {
|
|||||||
static void sendAudioFrame(gsl::span< const Mumble::Protocol::byte > encodedPacket) {
|
static void sendAudioFrame(gsl::span< const Mumble::Protocol::byte > encodedPacket) {
|
||||||
ServerHandlerPtr sh = Global::get().sh;
|
ServerHandlerPtr sh = Global::get().sh;
|
||||||
if (sh) {
|
if (sh) {
|
||||||
sh->sendMessage(encodedPacket.data(), encodedPacket.size());
|
sh->sendMessage(encodedPacket.data(), static_cast< int >(encodedPacket.size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioInput::flushCheck(const QByteArray &frame, bool terminator, int voiceTargetID) {
|
void AudioInput::flushCheck(const QByteArray &frame, bool terminator, std::int32_t voiceTargetID) {
|
||||||
qlFrames << frame;
|
qlFrames << frame;
|
||||||
|
|
||||||
if (!terminator && iBufferedFrames < iAudioFrames)
|
if (!terminator && iBufferedFrames < iAudioFrames)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Mumble::Protocol::AudioData audioData;
|
Mumble::Protocol::AudioData audioData;
|
||||||
audioData.targetOrContext = voiceTargetID;
|
audioData.targetOrContext = static_cast< std::uint32_t >(voiceTargetID);
|
||||||
audioData.isLastFrame = terminator;
|
audioData.isLastFrame = terminator;
|
||||||
|
|
||||||
if (terminator && Global::get().iPrevTarget > 0) {
|
if (terminator && Global::get().iPrevTarget > 0) {
|
||||||
@ -1171,7 +1177,7 @@ void AudioInput::flushCheck(const QByteArray &frame, bool terminator, int voiceT
|
|||||||
// is reset to 0 by now. In order to send the last whisper frame correctly, we have to use
|
// is reset to 0 by now. In order to send the last whisper frame correctly, we have to use
|
||||||
// Global::get().iPrevTarget which is set to whatever Global::get().iTarget has been before its last change.
|
// Global::get().iPrevTarget which is set to whatever Global::get().iTarget has been before its last change.
|
||||||
|
|
||||||
audioData.targetOrContext = Global::get().iPrevTarget;
|
audioData.targetOrContext = static_cast< std::uint32_t >(Global::get().iPrevTarget);
|
||||||
|
|
||||||
// We reset Global::get().iPrevTarget as it has fulfilled its purpose for this whisper-action. It'll be set
|
// We reset Global::get().iPrevTarget as it has fulfilled its purpose for this whisper-action. It'll be set
|
||||||
// accordingly once the client whispers for the next time.
|
// accordingly once the client whispers for the next time.
|
||||||
@ -1186,7 +1192,7 @@ void AudioInput::flushCheck(const QByteArray &frame, bool terminator, int voiceT
|
|||||||
int frames = iBufferedFrames;
|
int frames = iBufferedFrames;
|
||||||
iBufferedFrames = 0;
|
iBufferedFrames = 0;
|
||||||
|
|
||||||
audioData.frameNumber = iFrameCounter - frames;
|
audioData.frameNumber = static_cast< std::size_t >(iFrameCounter - frames);
|
||||||
|
|
||||||
if (Global::get().s.bTransmitPosition && Global::get().pluginManager && !Global::get().bCenterPosition
|
if (Global::get().s.bTransmitPosition && Global::get().pluginManager && !Global::get().bCenterPosition
|
||||||
&& Global::get().pluginManager->fetchPositionalData()) {
|
&& Global::get().pluginManager->fetchPositionalData()) {
|
||||||
@ -1204,7 +1210,8 @@ void AudioInput::flushCheck(const QByteArray &frame, bool terminator, int voiceT
|
|||||||
assert(qlFrames.size() == 1);
|
assert(qlFrames.size() == 1);
|
||||||
|
|
||||||
audioData.payload = gsl::span< const Mumble::Protocol::byte >(
|
audioData.payload = gsl::span< const Mumble::Protocol::byte >(
|
||||||
reinterpret_cast< const Mumble::Protocol::byte * >(qlFrames[0].constData()), qlFrames[0].size());
|
reinterpret_cast< const Mumble::Protocol::byte * >(qlFrames[0].constData()),
|
||||||
|
static_cast< std::size_t >(qlFrames[0].size()));
|
||||||
|
|
||||||
{
|
{
|
||||||
ServerHandlerPtr sh = Global::get().sh;
|
ServerHandlerPtr sh = Global::get().sh;
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
#include <boost/array.hpp>
|
#include <boost/array.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -208,7 +209,7 @@ protected:
|
|||||||
unsigned int iMicFreq, iEchoFreq;
|
unsigned int iMicFreq, iEchoFreq;
|
||||||
unsigned int iMicLength, iEchoLength;
|
unsigned int iMicLength, iEchoLength;
|
||||||
unsigned int iMicSampleSize, iEchoSampleSize;
|
unsigned int iMicSampleSize, iEchoSampleSize;
|
||||||
int iEchoMCLength, iEchoFrameSize;
|
unsigned int iEchoMCLength, iEchoFrameSize;
|
||||||
quint64 uiMicChannelMask, uiEchoChannelMask;
|
quint64 uiMicChannelMask, uiEchoChannelMask;
|
||||||
|
|
||||||
bool bEchoMulti;
|
bool bEchoMulti;
|
||||||
@ -258,7 +259,7 @@ protected:
|
|||||||
int iBufferedFrames;
|
int iBufferedFrames;
|
||||||
|
|
||||||
QList< QByteArray > qlFrames;
|
QList< QByteArray > qlFrames;
|
||||||
void flushCheck(const QByteArray &, bool terminator, int voiceTargetID);
|
void flushCheck(const QByteArray &, bool terminator, std::int32_t voiceTargetID);
|
||||||
|
|
||||||
void initializeMixer();
|
void initializeMixer();
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,7 @@
|
|||||||
#include "VoiceRecorder.h"
|
#include "VoiceRecorder.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
// Remember that we cannot use static member classes that are not pointers, as the constructor
|
// Remember that we cannot use static member classes that are not pointers, as the constructor
|
||||||
@ -402,14 +403,15 @@ void AudioOutput::initializeMixer(const unsigned int *chanmasks, bool forceheadp
|
|||||||
fSpeakers[3 * i + 2] /= d;
|
fSpeakers[3 * i + 2] /= d;
|
||||||
}
|
}
|
||||||
float *spf = &fStereoPanningFactor[2 * i];
|
float *spf = &fStereoPanningFactor[2 * i];
|
||||||
spf[0] = (1.0 - fSpeakers[i * 3 + 0]) / 2.0;
|
spf[0] = (1.0f - fSpeakers[i * 3 + 0]) / 2.0f;
|
||||||
spf[1] = (1.0 + fSpeakers[i * 3 + 0]) / 2.0;
|
spf[1] = (1.0f + fSpeakers[i * 3 + 0]) / 2.0f;
|
||||||
}
|
}
|
||||||
} else if (iChannels == 1) {
|
} else if (iChannels == 1) {
|
||||||
fStereoPanningFactor[0] = 0.5;
|
fStereoPanningFactor[0] = 0.5;
|
||||||
fStereoPanningFactor[1] = 0.5;
|
fStereoPanningFactor[1] = 0.5;
|
||||||
}
|
}
|
||||||
iSampleSize = static_cast< int >(iChannels * ((eSampleFormat == SampleFloat) ? sizeof(float) : sizeof(short)));
|
iSampleSize =
|
||||||
|
static_cast< unsigned int >(iChannels * ((eSampleFormat == SampleFloat) ? sizeof(float) : sizeof(short)));
|
||||||
qWarning("AudioOutput: Initialized %d channel %d hz mixer", iChannels, iMixerFreq);
|
qWarning("AudioOutput: Initialized %d channel %d hz mixer", iChannels, iMixerFreq);
|
||||||
|
|
||||||
if (Global::get().s.bPositionalAudio && iChannels == 1) {
|
if (Global::get().s.bPositionalAudio && iChannels == 1) {
|
||||||
@ -467,14 +469,17 @@ bool AudioOutput::mix(void *outbuff, unsigned int frameCount) {
|
|||||||
|
|
||||||
// If the audio backend uses a float-array we can sample and mix the audio sources directly into the output.
|
// If the audio backend uses a float-array we can sample and mix the audio sources directly into the output.
|
||||||
// Otherwise we'll have to use an intermediate buffer which we will convert to an array of shorts later
|
// Otherwise we'll have to use an intermediate buffer which we will convert to an array of shorts later
|
||||||
STACKVAR(float, fOutput, iChannels *frameCount);
|
static std::vector< float > fOutput;
|
||||||
float *output = (eSampleFormat == SampleFloat) ? reinterpret_cast< float * >(outbuff) : fOutput;
|
fOutput.resize(iChannels * frameCount);
|
||||||
|
float *output = (eSampleFormat == SampleFloat) ? reinterpret_cast< float * >(outbuff) : fOutput.data();
|
||||||
memset(output, 0, sizeof(float) * frameCount * iChannels);
|
memset(output, 0, sizeof(float) * frameCount * iChannels);
|
||||||
|
|
||||||
if (!qlMix.isEmpty()) {
|
if (!qlMix.isEmpty()) {
|
||||||
// There are audio sources available -> mix those sources together and feed them into the audio backend
|
// There are audio sources available -> mix those sources together and feed them into the audio backend
|
||||||
STACKVAR(float, speaker, iChannels * 3);
|
static std::vector< float > speaker;
|
||||||
STACKVAR(float, svol, iChannels);
|
speaker.resize(iChannels * 3);
|
||||||
|
static std::vector< float > svol;
|
||||||
|
svol.resize(iChannels);
|
||||||
|
|
||||||
bool validListener = false;
|
bool validListener = false;
|
||||||
|
|
||||||
@ -601,7 +606,9 @@ bool AudioOutput::mix(void *outbuff, unsigned int frameCount) {
|
|||||||
// As the events may cause the output PCM to change, the connection has to be direct in any case
|
// As the events may cause the output PCM to change, the connection has to be direct in any case
|
||||||
const int channels = (speech && speech->bStereo) ? 2 : 1;
|
const int channels = (speech && speech->bStereo) ? 2 : 1;
|
||||||
// If user != nullptr, then the current audio is considered speech
|
// If user != nullptr, then the current audio is considered speech
|
||||||
emit audioSourceFetched(pfBuffer, frameCount, channels, SAMPLE_RATE, static_cast< bool >(user), user);
|
assert(channels >= 0);
|
||||||
|
emit audioSourceFetched(pfBuffer, frameCount, static_cast< unsigned int >(channels), SAMPLE_RATE,
|
||||||
|
static_cast< bool >(user), user);
|
||||||
|
|
||||||
// If recording is enabled add the current audio source to the recording buffer
|
// If recording is enabled add the current audio source to the recording buffer
|
||||||
if (recorder) {
|
if (recorder) {
|
||||||
@ -610,7 +617,7 @@ bool AudioOutput::mix(void *outbuff, unsigned int frameCount) {
|
|||||||
// Mix down stereo to mono. TODO: stereo record support
|
// Mix down stereo to mono. TODO: stereo record support
|
||||||
// frame: for a stereo stream, the [LR] pair inside ...[LR]LRLRLR.... is a frame
|
// frame: for a stereo stream, the [LR] pair inside ...[LR]LRLRLR.... is a frame
|
||||||
for (unsigned int i = 0; i < frameCount; ++i) {
|
for (unsigned int i = 0; i < frameCount; ++i) {
|
||||||
recbuff[i] += (pfBuffer[2 * i] / 2.0 + pfBuffer[2 * i + 1] / 2.0) * volumeAdjustment;
|
recbuff[i] += (pfBuffer[2 * i] / 2.0f + pfBuffer[2 * i + 1] / 2.0f) * volumeAdjustment;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (unsigned int i = 0; i < frameCount; ++i) {
|
for (unsigned int i = 0; i < frameCount; ++i) {
|
||||||
@ -619,7 +626,7 @@ bool AudioOutput::mix(void *outbuff, unsigned int frameCount) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!recorder->isInMixDownMode()) {
|
if (!recorder->isInMixDownMode()) {
|
||||||
recorder->addBuffer(speech->p, recbuff, frameCount);
|
recorder->addBuffer(speech->p, recbuff, static_cast< int >(frameCount));
|
||||||
recbuff = boost::shared_array< float >(new float[frameCount]);
|
recbuff = boost::shared_array< float >(new float[frameCount]);
|
||||||
memset(recbuff.get(), 0, sizeof(float) * frameCount);
|
memset(recbuff.get(), 0, sizeof(float) * frameCount);
|
||||||
}
|
}
|
||||||
@ -634,10 +641,8 @@ bool AudioOutput::mix(void *outbuff, unsigned int frameCount) {
|
|||||||
if (validListener
|
if (validListener
|
||||||
&& ((buffer->fPos[0] != 0.0f) || (buffer->fPos[1] != 0.0f) || (buffer->fPos[2] != 0.0f))) {
|
&& ((buffer->fPos[0] != 0.0f) || (buffer->fPos[1] != 0.0f) || (buffer->fPos[2] != 0.0f))) {
|
||||||
// Add position to position map
|
// Add position to position map
|
||||||
AudioOutputSpeech *speech = qobject_cast< AudioOutputSpeech * >(buffer);
|
|
||||||
#ifdef USE_MANUAL_PLUGIN
|
#ifdef USE_MANUAL_PLUGIN
|
||||||
if (speech) {
|
if (user) {
|
||||||
const ClientUser *user = speech->p;
|
|
||||||
// The coordinates in the plane are actually given by x and z instead of x and y (y is up)
|
// The coordinates in the plane are actually given by x and z instead of x and y (y is up)
|
||||||
positions.insert(user->uiSession, { buffer->fPos[0], buffer->fPos[2] });
|
positions.insert(user->uiSession, { buffer->fPos[0], buffer->fPos[2] });
|
||||||
}
|
}
|
||||||
@ -708,24 +713,25 @@ bool AudioOutput::mix(void *outbuff, unsigned int frameCount) {
|
|||||||
// newly calculated offset for this chunk. This prevents clicking / buzzing when the
|
// newly calculated offset for this chunk. This prevents clicking / buzzing when the
|
||||||
// audio source or camera is moving, because abruptly changing offsets (and thus
|
// audio source or camera is moving, because abruptly changing offsets (and thus
|
||||||
// abruptly changing the playback position) will create a clicking noise.
|
// abruptly changing the playback position) will create a clicking noise.
|
||||||
const int offset =
|
// Normalize dot to range [0,1] instead [-1,1]
|
||||||
INTERAURAL_DELAY * (1.0 + dot) / 2.0; // Normalize dot to range [0,1] instead [-1,1]
|
const int offset = static_cast< int >(INTERAURAL_DELAY * (1.0f + dot) / 2.0f);
|
||||||
const int oldOffset = buffer->piOffset[s];
|
const int oldOffset = static_cast< int >(buffer->piOffset[s]);
|
||||||
const float incOffset = (offset - oldOffset) / static_cast< float >(frameCount);
|
const float incOffset = static_cast< float >(offset - oldOffset) / static_cast< float >(frameCount);
|
||||||
buffer->piOffset[s] = offset;
|
buffer->piOffset[s] = static_cast< unsigned int >(offset);
|
||||||
/*
|
/*
|
||||||
qWarning("%d: Pos %f %f %f : Dot %f Len %f ChannelVol %f", s, speaker[s*3+0],
|
qWarning("%d: Pos %f %f %f : Dot %f Len %f ChannelVol %f", s, speaker[s*3+0],
|
||||||
speaker[s*3+1], speaker[s*3+2], dot, len, channelVol);
|
speaker[s*3+1], speaker[s*3+2], dot, len, channelVol);
|
||||||
*/
|
*/
|
||||||
if ((old >= 0.00000001f) || (channelVol >= 0.00000001f)) {
|
if ((old >= 0.00000001f) || (channelVol >= 0.00000001f)) {
|
||||||
for (unsigned int i = 0; i < frameCount; ++i) {
|
for (unsigned int i = 0; i < frameCount; ++i) {
|
||||||
unsigned int currentOffset = oldOffset + incOffset * i;
|
unsigned int currentOffset = static_cast< unsigned int >(
|
||||||
|
static_cast< float >(oldOffset) + incOffset * static_cast< float >(i));
|
||||||
if (speech && speech->bStereo) {
|
if (speech && speech->bStereo) {
|
||||||
// Mix stereo user's stream into mono
|
// Mix stereo user's stream into mono
|
||||||
// frame: for a stereo stream, the [LR] pair inside ...[LR]LRLRLR.... is a frame
|
// frame: for a stereo stream, the [LR] pair inside ...[LR]LRLRLR.... is a frame
|
||||||
o[i * nchan] +=
|
o[i * nchan] += (pfBuffer[2 * i + currentOffset] / 2.0f
|
||||||
(pfBuffer[2 * i + currentOffset] / 2.0 + pfBuffer[2 * i + currentOffset + 1] / 2.0)
|
+ pfBuffer[2 * i + currentOffset + 1] / 2.0f)
|
||||||
* (old + inc * static_cast< float >(i));
|
* (old + inc * static_cast< float >(i));
|
||||||
} else {
|
} else {
|
||||||
o[i * nchan] += pfBuffer[i + currentOffset] * (old + inc * static_cast< float >(i));
|
o[i * nchan] += pfBuffer[i + currentOffset] * (old + inc * static_cast< float >(i));
|
||||||
}
|
}
|
||||||
@ -755,7 +761,7 @@ bool AudioOutput::mix(void *outbuff, unsigned int frameCount) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (recorder && recorder->isInMixDownMode()) {
|
if (recorder && recorder->isInMixDownMode()) {
|
||||||
recorder->addBuffer(nullptr, recbuff, frameCount);
|
recorder->addBuffer(nullptr, recbuff, static_cast< int >(frameCount));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -51,7 +51,7 @@ void AudioOutputCache::loadFrom(const Mumble::Protocol::AudioData &audioData) {
|
|||||||
// Then copy remaining fields (that we care about)
|
// Then copy remaining fields (that we care about)
|
||||||
m_isLastFrame = audioData.isLastFrame;
|
m_isLastFrame = audioData.isLastFrame;
|
||||||
m_volumeAdjustment = audioData.volumeAdjustment.factor;
|
m_volumeAdjustment = audioData.volumeAdjustment.factor;
|
||||||
m_audioContext = audioData.targetOrContext;
|
m_audioContext = static_cast< Mumble::Protocol::audio_context_t >(audioData.targetOrContext);
|
||||||
|
|
||||||
// And finally copy positional data, if available
|
// And finally copy positional data, if available
|
||||||
if (audioData.containsPositionalData) {
|
if (audioData.containsPositionalData) {
|
||||||
@ -60,7 +60,7 @@ void AudioOutputCache::loadFrom(const Mumble::Protocol::AudioData &audioData) {
|
|||||||
assert(m_position.size() == 3);
|
assert(m_position.size() == 3);
|
||||||
assert(audioData.position.size() == 3);
|
assert(audioData.position.size() == 3);
|
||||||
|
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (unsigned int i = 0; i < 3; ++i) {
|
||||||
m_position[i] = audioData.position[i];
|
m_position[i] = audioData.position[i];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -150,7 +150,8 @@ AudioOutputSample::AudioOutputSample(SoundFile *psndfile, float volume, bool loo
|
|||||||
|
|
||||||
// If the frequencies don't match initialize the resampler
|
// If the frequencies don't match initialize the resampler
|
||||||
if (sfHandle->samplerate() != static_cast< int >(freq)) {
|
if (sfHandle->samplerate() != static_cast< int >(freq)) {
|
||||||
srs = speex_resampler_init(bStereo ? 2 : 1, sfHandle->samplerate(), iOutSampleRate, 3, &err);
|
srs = speex_resampler_init(bStereo ? 2 : 1, static_cast< unsigned int >(sfHandle->samplerate()), iOutSampleRate,
|
||||||
|
3, &err);
|
||||||
if (err != RESAMPLER_ERR_SUCCESS) {
|
if (err != RESAMPLER_ERR_SUCCESS) {
|
||||||
qWarning() << "Initialize " << sfHandle->samplerate() << " to " << iOutSampleRate << " resampler failed!";
|
qWarning() << "Initialize " << sfHandle->samplerate() << " to " << iOutSampleRate << " resampler failed!";
|
||||||
srs = nullptr;
|
srs = nullptr;
|
||||||
@ -233,15 +234,17 @@ bool AudioOutputSample::prepareSampleBuffer(unsigned int frameCount) {
|
|||||||
|
|
||||||
// Check if we can satisfy request with current buffer
|
// Check if we can satisfy request with current buffer
|
||||||
// Maximum interaural delay is accounted for to prevent audio glitches
|
// Maximum interaural delay is accounted for to prevent audio glitches
|
||||||
if (iBufferFilled >= sampleCount + INTERAURAL_DELAY)
|
if (static_cast< float >(iBufferFilled) >= static_cast< float >(sampleCount) + INTERAURAL_DELAY)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Calculate the required buffersize to hold the results
|
// Calculate the required buffersize to hold the results
|
||||||
unsigned int iInputFrames = static_cast< unsigned int >(
|
unsigned int iInputFrames = static_cast< unsigned int >(
|
||||||
ceilf(static_cast< float >(frameCount * sfHandle->samplerate()) / static_cast< float >(iOutSampleRate)));
|
ceilf(static_cast< float >(frameCount * static_cast< unsigned int >(sfHandle->samplerate()))
|
||||||
|
/ static_cast< float >(iOutSampleRate)));
|
||||||
unsigned int iInputSamples = iInputFrames * channels;
|
unsigned int iInputSamples = iInputFrames * channels;
|
||||||
|
|
||||||
STACKVAR(float, fOut, iInputSamples);
|
static std::vector< float > fOut;
|
||||||
|
fOut.resize(iInputSamples);
|
||||||
|
|
||||||
bool eof = false;
|
bool eof = false;
|
||||||
sf_count_t read;
|
sf_count_t read;
|
||||||
@ -249,13 +252,13 @@ bool AudioOutputSample::prepareSampleBuffer(unsigned int frameCount) {
|
|||||||
resizeBuffer(iBufferFilled + sampleCount + INTERAURAL_DELAY);
|
resizeBuffer(iBufferFilled + sampleCount + INTERAURAL_DELAY);
|
||||||
|
|
||||||
// If we need to resample, write to the buffer on stack
|
// If we need to resample, write to the buffer on stack
|
||||||
float *pOut = (srs) ? fOut : pfBuffer + iBufferFilled;
|
float *pOut = (srs) ? fOut.data() : pfBuffer + iBufferFilled;
|
||||||
|
|
||||||
// Try to read all samples needed to satisfy this request
|
// Try to read all samples needed to satisfy this request
|
||||||
if ((read = sfHandle->read(pOut, iInputSamples)) < iInputSamples) {
|
if ((read = sfHandle->read(pOut, iInputSamples)) < iInputSamples) {
|
||||||
if (sfHandle->error() != SF_ERR_NO_ERROR || !bLoop) {
|
if (sfHandle->error() != SF_ERR_NO_ERROR || !bLoop) {
|
||||||
// We reached the eof or encountered an error, stuff with zeroes
|
// We reached the eof or encountered an error, stuff with zeroes
|
||||||
memset(pOut, 0, sizeof(float) * (iInputSamples - read));
|
memset(pOut, 0, sizeof(float) * static_cast< std::size_t >(iInputSamples - read));
|
||||||
read = iInputSamples;
|
read = iInputSamples;
|
||||||
eof = true;
|
eof = true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -42,7 +42,7 @@ std::size_t AudioOutputSpeech::storeAudioOutputCache(const Mumble::Protocol::Aud
|
|||||||
// Write audio data to that free (currently unused) chunk
|
// Write audio data to that free (currently unused) chunk
|
||||||
it->loadFrom(audioData);
|
it->loadFrom(audioData);
|
||||||
|
|
||||||
return std::distance(s_audioCaches.begin(), it);
|
return static_cast< std::size_t >(std::distance(s_audioCaches.begin(), it));
|
||||||
} else {
|
} else {
|
||||||
// The list of audio chunks is full -> extend it
|
// The list of audio chunks is full -> extend it
|
||||||
AudioOutputCache chunk;
|
AudioOutputCache chunk;
|
||||||
@ -81,7 +81,7 @@ AudioOutputSpeech::AudioOutputSpeech(ClientUser *user, unsigned int freq, Mumble
|
|||||||
// Always pretend Stereo mode is true by default. since opus will convert mono stream to stereo stream.
|
// Always pretend Stereo mode is true by default. since opus will convert mono stream to stereo stream.
|
||||||
// https://tools.ietf.org/html/rfc6716#section-2.1.2
|
// https://tools.ietf.org/html/rfc6716#section-2.1.2
|
||||||
bStereo = true;
|
bStereo = true;
|
||||||
opusState = opus_decoder_create(iSampleRate, bStereo ? 2 : 1, nullptr);
|
opusState = opus_decoder_create(static_cast< int >(iSampleRate), bStereo ? 2 : 1, nullptr);
|
||||||
opus_decoder_ctl(opusState,
|
opus_decoder_ctl(opusState,
|
||||||
OPUS_SET_PHASE_INVERSION_DISABLED(1)); // Disable phase inversion for better mono downmix.
|
OPUS_SET_PHASE_INVERSION_DISABLED(1)); // Disable phase inversion for better mono downmix.
|
||||||
|
|
||||||
@ -130,8 +130,8 @@ AudioOutputSpeech::AudioOutputSpeech(ClientUser *user, unsigned int freq, Mumble
|
|||||||
|
|
||||||
m_audioContext = Mumble::Protocol::AudioContext::INVALID;
|
m_audioContext = Mumble::Protocol::AudioContext::INVALID;
|
||||||
|
|
||||||
jbJitter = jitter_buffer_init(iFrameSize);
|
jbJitter = jitter_buffer_init(static_cast< int >(iFrameSize));
|
||||||
int margin = Global::get().s.iJitterBufferSize * iFrameSize;
|
int margin = Global::get().s.iJitterBufferSize * static_cast< int >(iFrameSize);
|
||||||
jitter_buffer_ctl(jbJitter, JITTER_BUFFER_SET_MARGIN, &margin);
|
jitter_buffer_ctl(jbJitter, JITTER_BUFFER_SET_MARGIN, &margin);
|
||||||
|
|
||||||
// We are configuring our Jitter buffer to use a custom deleter function. This prevents the buffer from
|
// We are configuring our Jitter buffer to use a custom deleter function. This prevents the buffer from
|
||||||
@ -183,12 +183,13 @@ void AudioOutputSpeech::addFrameToBuffer(const Mumble::Protocol::AudioData &audi
|
|||||||
assert(m_codec == Mumble::Protocol::AudioCodec::Opus);
|
assert(m_codec == Mumble::Protocol::AudioCodec::Opus);
|
||||||
assert(audioData.usedCodec == m_codec);
|
assert(audioData.usedCodec == m_codec);
|
||||||
|
|
||||||
samples = opus_decoder_get_nb_samples(opusState, audioData.payload.data(),
|
samples = opus_decoder_get_nb_samples(
|
||||||
audioData.payload.size()); // this function return samples per channel
|
opusState, audioData.payload.data(),
|
||||||
samples *= 2; // since we assume all input stream is stereo.
|
static_cast< int >(audioData.payload.size())); // this function return samples per channel
|
||||||
|
samples *= 2; // since we assume all input stream is stereo.
|
||||||
|
|
||||||
// We can't handle frames which are not a multiple of our configured framesize.
|
// We can't handle frames which are not a multiple of our configured framesize.
|
||||||
if (samples % iFrameSize != 0) {
|
if (static_cast< unsigned int >(samples) % iFrameSize != 0) {
|
||||||
qWarning("AudioOutputSpeech: Dropping Opus audio packet, because its sample count (%d) is not a "
|
qWarning("AudioOutputSpeech: Dropping Opus audio packet, because its sample count (%d) is not a "
|
||||||
"multiple of our frame size (%d)",
|
"multiple of our frame size (%d)",
|
||||||
samples, iFrameSize);
|
samples, iFrameSize);
|
||||||
@ -210,8 +211,8 @@ void AudioOutputSpeech::addFrameToBuffer(const Mumble::Protocol::AudioData &audi
|
|||||||
JitterBufferPacket jbp;
|
JitterBufferPacket jbp;
|
||||||
jbp.data = reinterpret_cast< char * >(storageIndex) + 1;
|
jbp.data = reinterpret_cast< char * >(storageIndex) + 1;
|
||||||
jbp.len = 0;
|
jbp.len = 0;
|
||||||
jbp.span = samples;
|
jbp.span = static_cast< unsigned int >(samples);
|
||||||
jbp.timestamp = iFrameSize * audioData.frameNumber;
|
jbp.timestamp = static_cast< unsigned int >(iFrameSize * audioData.frameNumber);
|
||||||
|
|
||||||
jitter_buffer_put(jbJitter, &jbp);
|
jitter_buffer_put(jbJitter, &jbp);
|
||||||
}
|
}
|
||||||
@ -240,7 +241,7 @@ bool AudioOutputSpeech::prepareSampleBuffer(unsigned int frameCount) {
|
|||||||
bool nextalive = bLastAlive;
|
bool nextalive = bLastAlive;
|
||||||
|
|
||||||
while (iBufferFilled < sampleCount + INTERAURAL_DELAY) {
|
while (iBufferFilled < sampleCount + INTERAURAL_DELAY) {
|
||||||
int decodedSamples = iFrameSize;
|
int decodedSamples = static_cast< int >(iFrameSize);
|
||||||
resizeBuffer(iBufferFilled + iOutputSize + INTERAURAL_DELAY);
|
resizeBuffer(iBufferFilled + iOutputSize + INTERAURAL_DELAY);
|
||||||
// TODO: allocating memory in the audio callback will crash mumble in some cases.
|
// TODO: allocating memory in the audio callback will crash mumble in some cases.
|
||||||
// we need to initialize the buffer with an appropriate size when initializing
|
// we need to initialize the buffer with an appropriate size when initializing
|
||||||
@ -260,7 +261,7 @@ bool AudioOutputSpeech::prepareSampleBuffer(unsigned int frameCount) {
|
|||||||
jitter_buffer_ctl(jbJitter, JITTER_BUFFER_GET_AVAILABLE_COUNT, &avail);
|
jitter_buffer_ctl(jbJitter, JITTER_BUFFER_GET_AVAILABLE_COUNT, &avail);
|
||||||
|
|
||||||
if (p && (ts == 0)) {
|
if (p && (ts == 0)) {
|
||||||
int want = iroundf(p->fAverageAvailable);
|
int want = static_cast< int >(p->fAverageAvailable);
|
||||||
if (avail < want) {
|
if (avail < want) {
|
||||||
++iMissCount;
|
++iMissCount;
|
||||||
if (iMissCount < 20) {
|
if (iMissCount < 20) {
|
||||||
@ -276,7 +277,7 @@ bool AudioOutputSpeech::prepareSampleBuffer(unsigned int frameCount) {
|
|||||||
JitterBufferPacket jbp;
|
JitterBufferPacket jbp;
|
||||||
|
|
||||||
spx_int32_t startofs = 0;
|
spx_int32_t startofs = 0;
|
||||||
if (jitter_buffer_get(jbJitter, &jbp, iFrameSize, &startofs) == JITTER_BUFFER_OK) {
|
if (jitter_buffer_get(jbJitter, &jbp, static_cast< int >(iFrameSize), &startofs) == JITTER_BUFFER_OK) {
|
||||||
std::lock_guard< std::mutex > audioChunkLock(s_audioCachesMutex);
|
std::lock_guard< std::mutex > audioChunkLock(s_audioCachesMutex);
|
||||||
|
|
||||||
iMissCount = 0;
|
iMissCount = 0;
|
||||||
@ -295,13 +296,13 @@ bool AudioOutputSpeech::prepareSampleBuffer(unsigned int frameCount) {
|
|||||||
|
|
||||||
// Copy audio data into qlFrames
|
// Copy audio data into qlFrames
|
||||||
qlFrames << QByteArray(reinterpret_cast< const char * >(cache.getAudioData().data()),
|
qlFrames << QByteArray(reinterpret_cast< const char * >(cache.getAudioData().data()),
|
||||||
cache.getAudioData().size());
|
static_cast< int >(cache.getAudioData().size()));
|
||||||
|
|
||||||
if (cache.containsPositionalInformation()) {
|
if (cache.containsPositionalInformation()) {
|
||||||
assert(cache.getPositionalInformation().size() == 3);
|
assert(cache.getPositionalInformation().size() == 3);
|
||||||
assert(fPos.size() == 3);
|
assert(fPos.size() == 3);
|
||||||
|
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (unsigned int i = 0; i < 3; ++i) {
|
||||||
fPos[i] = cache.getPositionalInformation()[i];
|
fPos[i] = cache.getPositionalInformation()[i];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -313,7 +314,7 @@ bool AudioOutputSpeech::prepareSampleBuffer(unsigned int frameCount) {
|
|||||||
|
|
||||||
if (p) {
|
if (p) {
|
||||||
float a = static_cast< float >(avail);
|
float a = static_cast< float >(avail);
|
||||||
if (avail >= p->fAverageAvailable)
|
if (static_cast< float >(avail) >= p->fAverageAvailable)
|
||||||
p->fAverageAvailable = a;
|
p->fAverageAvailable = a;
|
||||||
else
|
else
|
||||||
p->fAverageAvailable *= 0.99f;
|
p->fAverageAvailable *= 0.99f;
|
||||||
@ -345,7 +346,7 @@ bool AudioOutputSpeech::prepareSampleBuffer(unsigned int frameCount) {
|
|||||||
// packet normally in order to be able to play it.
|
// packet normally in order to be able to play it.
|
||||||
decodedSamples = opus_decode_float(
|
decodedSamples = opus_decode_float(
|
||||||
opusState, qba.isEmpty() ? nullptr : reinterpret_cast< const unsigned char * >(qba.constData()),
|
opusState, qba.isEmpty() ? nullptr : reinterpret_cast< const unsigned char * >(qba.constData()),
|
||||||
qba.size(), pOut, iAudioBufferSize, 0);
|
qba.size(), pOut, static_cast< int >(iAudioBufferSize), 0);
|
||||||
} else {
|
} else {
|
||||||
// If the packet is non-empty, but the associated user is locally muted,
|
// If the packet is non-empty, but the associated user is locally muted,
|
||||||
// we don't have to decode the packet. Instead it is enough to know how many
|
// we don't have to decode the packet. Instead it is enough to know how many
|
||||||
@ -356,10 +357,10 @@ bool AudioOutputSpeech::prepareSampleBuffer(unsigned int frameCount) {
|
|||||||
|
|
||||||
// The returned sample count we get from the Opus functions refer to samples per channel.
|
// The returned sample count we get from the Opus functions refer to samples per channel.
|
||||||
// Thus in order to get the total amount, we have to multiply by the channel count.
|
// Thus in order to get the total amount, we have to multiply by the channel count.
|
||||||
decodedSamples *= channels;
|
decodedSamples *= static_cast< int >(channels);
|
||||||
|
|
||||||
if (decodedSamples < 0) {
|
if (decodedSamples < 0) {
|
||||||
decodedSamples = iFrameSize;
|
decodedSamples = static_cast< int >(iFrameSize);
|
||||||
memset(pOut, 0, iFrameSize * sizeof(float));
|
memset(pOut, 0, iFrameSize * sizeof(float));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -397,11 +398,11 @@ bool AudioOutputSpeech::prepareSampleBuffer(unsigned int frameCount) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert(m_codec == Mumble::Protocol::AudioCodec::Opus);
|
assert(m_codec == Mumble::Protocol::AudioCodec::Opus);
|
||||||
decodedSamples = opus_decode_float(opusState, nullptr, 0, pOut, iFrameSize, 0);
|
decodedSamples = opus_decode_float(opusState, nullptr, 0, pOut, static_cast< int >(iFrameSize), 0);
|
||||||
decodedSamples *= channels;
|
decodedSamples *= static_cast< int >(channels);
|
||||||
|
|
||||||
if (decodedSamples < 0) {
|
if (decodedSamples < 0) {
|
||||||
decodedSamples = iFrameSize;
|
decodedSamples = static_cast< int >(iFrameSize);
|
||||||
memset(pOut, 0, iFrameSize * sizeof(float));
|
memset(pOut, 0, iFrameSize * sizeof(float));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -418,7 +419,7 @@ bool AudioOutputSpeech::prepareSampleBuffer(unsigned int frameCount) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = decodedSamples / iFrameSize; i > 0; --i) {
|
for (unsigned int i = static_cast< unsigned int >(decodedSamples) / iFrameSize; i > 0; --i) {
|
||||||
jitter_buffer_tick(jbJitter);
|
jitter_buffer_tick(jbJitter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -428,12 +429,13 @@ bool AudioOutputSpeech::prepareSampleBuffer(unsigned int frameCount) {
|
|||||||
// NOTE: If Opus is used, then in this case no samples have actually been decoded and thus
|
// NOTE: If Opus is used, then in this case no samples have actually been decoded and thus
|
||||||
// we don't discard previously done work (in form of decoding the audio stream) by overwriting
|
// we don't discard previously done work (in form of decoding the audio stream) by overwriting
|
||||||
// it with zeros.
|
// it with zeros.
|
||||||
memset(pOut, 0, decodedSamples * sizeof(float));
|
memset(pOut, 0, static_cast< unsigned int >(decodedSamples) * sizeof(float));
|
||||||
}
|
}
|
||||||
|
|
||||||
spx_uint32_t inlen = decodedSamples / channels; // per channel
|
spx_uint32_t inlen = static_cast< unsigned int >(decodedSamples) / channels; // per channel
|
||||||
spx_uint32_t outlen = static_cast< unsigned int >(
|
spx_uint32_t outlen = static_cast< unsigned int >(
|
||||||
ceilf(static_cast< float >(decodedSamples / channels * iMixerFreq) / static_cast< float >(iSampleRate)));
|
ceilf(static_cast< float >(static_cast< unsigned int >(decodedSamples) / channels * iMixerFreq)
|
||||||
|
/ static_cast< float >(iSampleRate)));
|
||||||
if (srs && bLastAlive) {
|
if (srs && bLastAlive) {
|
||||||
if (channels == 1) {
|
if (channels == 1) {
|
||||||
speex_resampler_process_float(srs, 0, fResamplerBuffer, &inlen, pfBuffer + iBufferFilled, &outlen);
|
speex_resampler_process_float(srs, 0, fResamplerBuffer, &inlen, pfBuffer + iBufferFilled, &outlen);
|
||||||
|
|||||||
@ -55,12 +55,12 @@ void AudioBar::paintEvent(QPaintEvent *) {
|
|||||||
float scale = static_cast< float >(width()) / static_cast< float >(iMax - iMin);
|
float scale = static_cast< float >(width()) / static_cast< float >(iMax - iMin);
|
||||||
int h = height();
|
int h = height();
|
||||||
|
|
||||||
int val = iroundf(static_cast< float >(iValue) * scale + 0.5f);
|
int val = static_cast< int >(static_cast< float >(iValue) * scale + 0.5f);
|
||||||
int below = iroundf(static_cast< float >(iBelow) * scale + 0.5f);
|
int below = static_cast< int >(static_cast< float >(iBelow) * scale + 0.5f);
|
||||||
int above = iroundf(static_cast< float >(iAbove) * scale + 0.5f);
|
int above = static_cast< int >(static_cast< float >(iAbove) * scale + 0.5f);
|
||||||
int max = iroundf(static_cast< float >(iMax) * scale + 0.5f);
|
int max = static_cast< int >(static_cast< float >(iMax) * scale + 0.5f);
|
||||||
int min = iroundf(static_cast< float >(iMin) * scale + 0.5f);
|
int min = static_cast< int >(static_cast< float >(iMin) * scale + 0.5f);
|
||||||
int peak = iroundf(static_cast< float >(iPeak) * scale + 0.5f);
|
int peak = static_cast< int >(static_cast< float >(iPeak) * scale + 0.5f);
|
||||||
|
|
||||||
if (Global::get().s.bHighContrast) {
|
if (Global::get().s.bHighContrast) {
|
||||||
// Draw monochrome representation
|
// Draw monochrome representation
|
||||||
@ -153,22 +153,24 @@ void AudioEchoWidget::paintEvent(QPaintEvent *) {
|
|||||||
spx_int32_t sz;
|
spx_int32_t sz;
|
||||||
speex_echo_ctl(ai->sesEcho, SPEEX_ECHO_GET_IMPULSE_RESPONSE_SIZE, &sz);
|
speex_echo_ctl(ai->sesEcho, SPEEX_ECHO_GET_IMPULSE_RESPONSE_SIZE, &sz);
|
||||||
|
|
||||||
STACKVAR(spx_int32_t, w, sz);
|
static std::vector< spx_int32_t > w;
|
||||||
STACKVAR(float, W, sz);
|
w.resize(static_cast< std::size_t >(sz));
|
||||||
|
static std::vector< float > W;
|
||||||
|
W.resize(static_cast< std::size_t >(sz));
|
||||||
|
|
||||||
speex_echo_ctl(ai->sesEcho, SPEEX_ECHO_GET_IMPULSE_RESPONSE, w);
|
speex_echo_ctl(ai->sesEcho, SPEEX_ECHO_GET_IMPULSE_RESPONSE, w.data());
|
||||||
|
|
||||||
ai->qmSpeex.unlock();
|
ai->qmSpeex.unlock();
|
||||||
|
|
||||||
int N = 160;
|
constexpr unsigned int N = 160;
|
||||||
int n = 2 * N;
|
constexpr unsigned int n = 2 * N;
|
||||||
int M = sz / n;
|
const unsigned int M = static_cast< unsigned int >(sz) / n;
|
||||||
|
|
||||||
drft_lookup d;
|
drft_lookup d;
|
||||||
mumble_drft_init(&d, n);
|
mumble_drft_init(&d, n);
|
||||||
|
|
||||||
for (int j = 0; j < M; j++) {
|
for (unsigned int j = 0; j < M; j++) {
|
||||||
for (int i = 0; i < n; i++)
|
for (unsigned int i = 0; i < n; i++)
|
||||||
W[j * n + i] = static_cast< float >(w[j * n + i]) / static_cast< float >(n);
|
W[j * n + i] = static_cast< float >(w[j * n + i]) / static_cast< float >(n);
|
||||||
mumble_drft_forward(&d, &W[j * n]);
|
mumble_drft_forward(&d, &W[j * n]);
|
||||||
}
|
}
|
||||||
@ -178,8 +180,8 @@ void AudioEchoWidget::paintEvent(QPaintEvent *) {
|
|||||||
float xscale = 1.0f / static_cast< float >(N);
|
float xscale = 1.0f / static_cast< float >(N);
|
||||||
float yscale = 1.0f / static_cast< float >(M);
|
float yscale = 1.0f / static_cast< float >(M);
|
||||||
|
|
||||||
for (int j = 0; j < M; j++) {
|
for (unsigned int j = 0; j < M; j++) {
|
||||||
for (int i = 1; i < N; i++) {
|
for (unsigned int i = 1; i < N; i++) {
|
||||||
float xa = static_cast< float >(i) * xscale;
|
float xa = static_cast< float >(i) * xscale;
|
||||||
float ya = static_cast< float >(j) * yscale;
|
float ya = static_cast< float >(j) * yscale;
|
||||||
|
|
||||||
@ -195,7 +197,7 @@ void AudioEchoWidget::paintEvent(QPaintEvent *) {
|
|||||||
QPolygonF poly;
|
QPolygonF poly;
|
||||||
xscale = 1.0f / (2.0f * static_cast< float >(n));
|
xscale = 1.0f / (2.0f * static_cast< float >(n));
|
||||||
yscale = 1.0f / (200.0f * 32767.0f);
|
yscale = 1.0f / (200.0f * 32767.0f);
|
||||||
for (int i = 0; i < 2 * n; i++) {
|
for (unsigned int i = 0; i < 2 * n; i++) {
|
||||||
poly << QPointF(static_cast< float >(i) * xscale, 0.5f + static_cast< float >(w[i]) * yscale);
|
poly << QPointF(static_cast< float >(i) * xscale, 0.5f + static_cast< float >(w[i]) * yscale);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,11 +226,13 @@ void AudioNoiseWidget::paintEvent(QPaintEvent *) {
|
|||||||
spx_int32_t ps_size = 0;
|
spx_int32_t ps_size = 0;
|
||||||
speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_PSD_SIZE, &ps_size);
|
speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_PSD_SIZE, &ps_size);
|
||||||
|
|
||||||
STACKVAR(spx_int32_t, noise, ps_size);
|
static std::vector< spx_int32_t > noise;
|
||||||
STACKVAR(spx_int32_t, ps, ps_size);
|
noise.resize(static_cast< std::size_t >(ps_size));
|
||||||
|
static std::vector< spx_int32_t > ps;
|
||||||
|
ps.resize(static_cast< std::size_t >(ps_size));
|
||||||
|
|
||||||
speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_PSD, ps);
|
speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_PSD, ps.data());
|
||||||
speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_NOISE_PSD, noise);
|
speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_NOISE_PSD, noise.data());
|
||||||
|
|
||||||
ai->qmSpeex.unlock();
|
ai->qmSpeex.unlock();
|
||||||
|
|
||||||
@ -239,7 +243,7 @@ void AudioNoiseWidget::paintEvent(QPaintEvent *) {
|
|||||||
|
|
||||||
poly << QPointF(0.0f, height() - 1);
|
poly << QPointF(0.0f, height() - 1);
|
||||||
float fftmul = 1.0 / (32768.0);
|
float fftmul = 1.0 / (32768.0);
|
||||||
for (int i = 0; i < ps_size; i++) {
|
for (unsigned int i = 0; i < static_cast< unsigned int >(ps_size); i++) {
|
||||||
qreal xp, yp;
|
qreal xp, yp;
|
||||||
xp = i * sx;
|
xp = i * sx;
|
||||||
yp = sqrtf(sqrtf(static_cast< float >(noise[i]))) - 1.0f;
|
yp = sqrtf(sqrtf(static_cast< float >(noise[i]))) - 1.0f;
|
||||||
@ -258,7 +262,7 @@ void AudioNoiseWidget::paintEvent(QPaintEvent *) {
|
|||||||
|
|
||||||
poly.clear();
|
poly.clear();
|
||||||
|
|
||||||
for (int i = 0; i < ps_size; i++) {
|
for (unsigned int i = 0; i < static_cast< unsigned int >(ps_size); i++) {
|
||||||
qreal xp, yp;
|
qreal xp, yp;
|
||||||
xp = i * sx;
|
xp = i * sx;
|
||||||
yp = sqrtf(sqrtf(static_cast< float >(ps[i]))) - 1.0f;
|
yp = sqrtf(sqrtf(static_cast< float >(ps[i]))) - 1.0f;
|
||||||
@ -335,19 +339,21 @@ void AudioStats::on_Tick_timeout() {
|
|||||||
spx_int32_t ps_size = 0;
|
spx_int32_t ps_size = 0;
|
||||||
speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_PSD_SIZE, &ps_size);
|
speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_PSD_SIZE, &ps_size);
|
||||||
|
|
||||||
STACKVAR(spx_int32_t, noise, ps_size);
|
static std::vector< spx_int32_t > noise;
|
||||||
STACKVAR(spx_int32_t, ps, ps_size);
|
noise.resize(static_cast< std::size_t >(ps_size));
|
||||||
|
static std::vector< spx_int32_t > ps;
|
||||||
|
ps.resize(static_cast< std::size_t >(ps_size));
|
||||||
|
|
||||||
speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_PSD, ps);
|
speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_PSD, ps.data());
|
||||||
speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_NOISE_PSD, noise);
|
speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_NOISE_PSD, noise.data());
|
||||||
|
|
||||||
float s = 0.0f;
|
float s = 0.0f;
|
||||||
float n = 0.0001f;
|
float n = 0.0001f;
|
||||||
|
|
||||||
int start = (ps_size * 300) / SAMPLE_RATE;
|
unsigned int start = static_cast< unsigned int >(ps_size * 300) / SAMPLE_RATE;
|
||||||
int stop = (ps_size * 2000) / SAMPLE_RATE;
|
unsigned int stop = static_cast< unsigned int >(ps_size * 2000) / SAMPLE_RATE;
|
||||||
|
|
||||||
for (int i = start; i < stop; i++) {
|
for (unsigned int i = start; i < stop; i++) {
|
||||||
s += sqrtf(static_cast< float >(ps[i]));
|
s += sqrtf(static_cast< float >(ps[i]));
|
||||||
n += sqrtf(static_cast< float >(noise[i]));
|
n += sqrtf(static_cast< float >(noise[i]));
|
||||||
}
|
}
|
||||||
@ -380,13 +386,13 @@ void AudioStats::on_Tick_timeout() {
|
|||||||
FORMAT_TO_TXT("%04llu ms", Global::get().uiDoublePush / 1000);
|
FORMAT_TO_TXT("%04llu ms", Global::get().uiDoublePush / 1000);
|
||||||
qlDoublePush->setText(txt);
|
qlDoublePush->setText(txt);
|
||||||
|
|
||||||
abSpeech->iBelow = iroundf(Global::get().s.fVADmin * 32767.0f + 0.5f);
|
abSpeech->iBelow = static_cast< int >(Global::get().s.fVADmin * 32767.0f + 0.5f);
|
||||||
abSpeech->iAbove = iroundf(Global::get().s.fVADmax * 32767.0f + 0.5f);
|
abSpeech->iAbove = static_cast< int >(Global::get().s.fVADmax * 32767.0f + 0.5f);
|
||||||
|
|
||||||
if (Global::get().s.vsVAD == Settings::Amplitude) {
|
if (Global::get().s.vsVAD == Settings::Amplitude) {
|
||||||
abSpeech->iValue = iroundf((32767.f / 96.0f) * (96.0f + ai->dPeakCleanMic) + 0.5f);
|
abSpeech->iValue = static_cast< int >((32767.f / 96.0f) * (96.0f + ai->dPeakCleanMic) + 0.5f);
|
||||||
} else {
|
} else {
|
||||||
abSpeech->iValue = iroundf(ai->fSpeechProb * 32767.0f + 0.5f);
|
abSpeech->iValue = static_cast< int >(ai->fSpeechProb * 32767.0f + 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
abSpeech->update();
|
abSpeech->update();
|
||||||
|
|||||||
@ -144,7 +144,7 @@ AudioWizard::AudioWizard(QWidget *p) : QWizard(p) {
|
|||||||
abVAD->qcInside = Qt::yellow;
|
abVAD->qcInside = Qt::yellow;
|
||||||
abVAD->qcAbove = Qt::green;
|
abVAD->qcAbove = Qt::green;
|
||||||
|
|
||||||
qsVAD->setValue(iroundf(Global::get().s.fVADmax * 32767.f + 0.5f));
|
qsVAD->setValue(static_cast< int >(Global::get().s.fVADmax * 32767.f + 0.5f));
|
||||||
|
|
||||||
// Positional
|
// Positional
|
||||||
qcbHeadphone->setChecked(Global::get().s.bPositionalHeadphone);
|
qcbHeadphone->setChecked(Global::get().s.bPositionalHeadphone);
|
||||||
@ -423,7 +423,7 @@ void AudioWizard::accept() {
|
|||||||
Settings::MessageLog mlReplace = qrbNotificationTTS->isChecked() ? Settings::LogSoundfile : Settings::LogTTS;
|
Settings::MessageLog mlReplace = qrbNotificationTTS->isChecked() ? Settings::LogSoundfile : Settings::LogTTS;
|
||||||
|
|
||||||
for (int i = Log::firstMsgType; i <= Log::lastMsgType; ++i) {
|
for (int i = Log::firstMsgType; i <= Log::lastMsgType; ++i) {
|
||||||
if (Global::get().s.qmMessages[i] & mlReplace)
|
if (Global::get().s.qmMessages[i] & static_cast< unsigned int >(mlReplace))
|
||||||
Global::get().s.qmMessages[i] ^= Settings::LogSoundfile | Settings::LogTTS;
|
Global::get().s.qmMessages[i] ^= Settings::LogSoundfile | Settings::LogTTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -468,13 +468,13 @@ void AudioWizard::on_Ticker_timeout() {
|
|||||||
abAmplify->iPeak = iMaxPeak;
|
abAmplify->iPeak = iMaxPeak;
|
||||||
abAmplify->update();
|
abAmplify->update();
|
||||||
|
|
||||||
abVAD->iBelow = iroundf(Global::get().s.fVADmin * 32767.0f + 0.5f);
|
abVAD->iBelow = static_cast< int >(Global::get().s.fVADmin * 32767.0f + 0.5f);
|
||||||
abVAD->iAbove = iroundf(Global::get().s.fVADmax * 32767.0f + 0.5f);
|
abVAD->iAbove = static_cast< int >(Global::get().s.fVADmax * 32767.0f + 0.5f);
|
||||||
|
|
||||||
if (Global::get().s.vsVAD == Settings::Amplitude) {
|
if (Global::get().s.vsVAD == Settings::Amplitude) {
|
||||||
abVAD->iValue = iroundf((32767.f / 96.0f) * (96.0f + ai->dPeakCleanMic) + 0.5f);
|
abVAD->iValue = static_cast< int >((32767.f / 96.0f) * (96.0f + ai->dPeakCleanMic) + 0.5f);
|
||||||
} else {
|
} else {
|
||||||
abVAD->iValue = iroundf(ai->fSpeechProb * 32767.0f + 0.5f);
|
abVAD->iValue = static_cast< int >(ai->fSpeechProb * 32767.0f + 0.5f);
|
||||||
}
|
}
|
||||||
abVAD->update();
|
abVAD->update();
|
||||||
|
|
||||||
@ -513,7 +513,7 @@ void AudioWizard::on_Ticker_timeout() {
|
|||||||
// qgsScene->addLine(QLineF(0,-1,0,1), pen);
|
// qgsScene->addLine(QLineF(0,-1,0,1), pen);
|
||||||
// qgsScene->addLine(QLineF(-1,0,1,0), pen);
|
// qgsScene->addLine(QLineF(-1,0,1,0), pen);
|
||||||
|
|
||||||
const float speakerScale = 0.9;
|
const float speakerScale = 0.9f;
|
||||||
const float speakerRadius = baseRadius * speakerScale;
|
const float speakerRadius = baseRadius * speakerScale;
|
||||||
|
|
||||||
// nspeaker is in format [x1,y1,z1, x2,y2,z2, ...]
|
// nspeaker is in format [x1,y1,z1, x2,y2,z2, ...]
|
||||||
@ -540,7 +540,7 @@ void AudioWizard::on_Ticker_timeout() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const float sourceScale = 0.9;
|
const float sourceScale = 0.9f;
|
||||||
const float sourceRadius = baseRadius * sourceScale;
|
const float sourceRadius = baseRadius * sourceScale;
|
||||||
|
|
||||||
qgiSource = qgsScene->addEllipse(QRectF(-sourceRadius, -sourceRadius, 2 * sourceRadius, 2 * sourceRadius),
|
qgiSource = qgsScene->addEllipse(QRectF(-sourceRadius, -sourceRadius, 2 * sourceRadius, 2 * sourceRadius),
|
||||||
|
|||||||
@ -11,6 +11,8 @@
|
|||||||
#include "ServerHandler.h"
|
#include "ServerHandler.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
BanEditor::BanEditor(const MumbleProto::BanList &msg, QWidget *p) : QDialog(p), maskDefaultValue(32) {
|
BanEditor::BanEditor(const MumbleProto::BanList &msg, QWidget *p) : QDialog(p), maskDefaultValue(32) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
@ -31,7 +33,7 @@ BanEditor::BanEditor(const MumbleProto::BanList &msg, QWidget *p) : QDialog(p),
|
|||||||
const MumbleProto::BanList_BanEntry &be = msg.bans(i);
|
const MumbleProto::BanList_BanEntry &be = msg.bans(i);
|
||||||
Ban b;
|
Ban b;
|
||||||
b.haAddress = be.address();
|
b.haAddress = be.address();
|
||||||
b.iMask = be.mask();
|
b.iMask = static_cast< int >(be.mask());
|
||||||
b.qsUsername = u8(be.name());
|
b.qsUsername = u8(be.name());
|
||||||
b.qsHash = u8(be.hash());
|
b.qsHash = u8(be.hash());
|
||||||
b.qsReason = u8(be.reason());
|
b.qsReason = u8(be.reason());
|
||||||
@ -53,7 +55,8 @@ void BanEditor::accept() {
|
|||||||
foreach (const Ban &b, qlBans) {
|
foreach (const Ban &b, qlBans) {
|
||||||
MumbleProto::BanList_BanEntry *be = msg.add_bans();
|
MumbleProto::BanList_BanEntry *be = msg.add_bans();
|
||||||
be->set_address(b.haAddress.toStdString());
|
be->set_address(b.haAddress.toStdString());
|
||||||
be->set_mask(b.iMask);
|
assert(b.iMask >= 0);
|
||||||
|
be->set_mask(static_cast< unsigned int >(b.iMask));
|
||||||
be->set_name(u8(b.qsUsername));
|
be->set_name(u8(b.qsUsername));
|
||||||
be->set_hash(u8(b.qsHash));
|
be->set_hash(u8(b.qsHash));
|
||||||
be->set_reason(u8(b.qsReason));
|
be->set_reason(u8(b.qsReason));
|
||||||
|
|||||||
@ -317,12 +317,14 @@ set(MUMBLE_SOURCES
|
|||||||
"${SHARED_SOURCE_DIR}/User.cpp"
|
"${SHARED_SOURCE_DIR}/User.cpp"
|
||||||
"${SHARED_SOURCE_DIR}/User.h"
|
"${SHARED_SOURCE_DIR}/User.h"
|
||||||
|
|
||||||
"${3RDPARTY_DIR}/smallft/smallft.cpp"
|
|
||||||
|
|
||||||
"mumble.qrc"
|
"mumble.qrc"
|
||||||
"${CMAKE_SOURCE_DIR}/themes/DefaultTheme.qrc"
|
"${CMAKE_SOURCE_DIR}/themes/DefaultTheme.qrc"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_library(smallft STATIC "${3RDPARTY_DIR}/smallft/smallft.cpp")
|
||||||
|
target_include_directories(smallft PUBLIC "${3RDPARTY_DIR}/smallft")
|
||||||
|
target_disable_warnings(smallft)
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "${CMAKE_BINARY_DIR}/mumble_flags.qrc"
|
OUTPUT "${CMAKE_BINARY_DIR}/mumble_flags.qrc"
|
||||||
COMMAND ${PYTHON_INTERPRETER}
|
COMMAND ${PYTHON_INTERPRETER}
|
||||||
@ -332,6 +334,7 @@ add_custom_command(
|
|||||||
list(APPEND MUMBLE_SOURCES "${CMAKE_BINARY_DIR}/mumble_flags.qrc")
|
list(APPEND MUMBLE_SOURCES "${CMAKE_BINARY_DIR}/mumble_flags.qrc")
|
||||||
|
|
||||||
add_library(mumble_client_object_lib OBJECT ${MUMBLE_SOURCES})
|
add_library(mumble_client_object_lib OBJECT ${MUMBLE_SOURCES})
|
||||||
|
target_link_libraries(mumble_client_object_lib PUBLIC smallft)
|
||||||
|
|
||||||
if(WIN32 AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
if(WIN32 AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
# We don't want the console to appear in release builds.
|
# We don't want the console to appear in release builds.
|
||||||
@ -416,7 +419,6 @@ target_include_directories(mumble_client_object_lib
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR} # This is required for includes in current folder to be found by files from the shared directory.
|
${CMAKE_CURRENT_SOURCE_DIR} # This is required for includes in current folder to be found by files from the shared directory.
|
||||||
"widgets"
|
"widgets"
|
||||||
${SHARED_SOURCE_DIR}
|
${SHARED_SOURCE_DIR}
|
||||||
"${3RDPARTY_DIR}/smallft"
|
|
||||||
"${PLUGINS_DIR}"
|
"${PLUGINS_DIR}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -316,7 +316,7 @@ bool ClientUser::isActive() {
|
|||||||
if (!tLastTalkStateChange.isStarted())
|
if (!tLastTalkStateChange.isStarted())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return tLastTalkStateChange.elapsed() < Global::get().s.os.uiActiveTime * 1000000U;
|
return tLastTalkStateChange.elapsed() < static_cast< unsigned int >(Global::get().s.os.uiActiveTime) * 1000000U;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* From Channel.h
|
/* From Channel.h
|
||||||
|
|||||||
@ -1467,7 +1467,8 @@ void ConnectDialog::fillList() {
|
|||||||
|
|
||||||
while (!ql.isEmpty()) {
|
while (!ql.isEmpty()) {
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||||
ServerItem *si = static_cast< ServerItem * >(ql.takeAt(QRandomGenerator::global()->generate() % ql.count()));
|
ServerItem *si = static_cast< ServerItem * >(
|
||||||
|
ql.takeAt(static_cast< int >(QRandomGenerator::global()->generate()) % ql.count()));
|
||||||
#else
|
#else
|
||||||
// Qt 5.10 introduces the QRandomGenerator class and in Qt 5.15 qrand got deprecated in its favor
|
// Qt 5.10 introduces the QRandomGenerator class and in Qt 5.15 qrand got deprecated in its favor
|
||||||
ServerItem *si = static_cast< ServerItem * >(ql.takeAt(qrand() % ql.count()));
|
ServerItem *si = static_cast< ServerItem * >(ql.takeAt(qrand() % ql.count()));
|
||||||
@ -1790,11 +1791,11 @@ bool ConnectDialog::writePing(const QHostAddress &host, unsigned short port, Ver
|
|||||||
gsl::span< const Mumble::Protocol::byte > encodedPacket = m_udpPingEncoder.encodePingPacket(pingData);
|
gsl::span< const Mumble::Protocol::byte > encodedPacket = m_udpPingEncoder.encodePingPacket(pingData);
|
||||||
|
|
||||||
if (bIPv4 && host.protocol() == QAbstractSocket::IPv4Protocol) {
|
if (bIPv4 && host.protocol() == QAbstractSocket::IPv4Protocol) {
|
||||||
qusSocket4->writeDatagram(reinterpret_cast< const char * >(encodedPacket.data()), encodedPacket.size(), host,
|
qusSocket4->writeDatagram(reinterpret_cast< const char * >(encodedPacket.data()),
|
||||||
port);
|
static_cast< qint64 >(encodedPacket.size()), host, port);
|
||||||
} else if (bIPv6 && host.protocol() == QAbstractSocket::IPv6Protocol) {
|
} else if (bIPv6 && host.protocol() == QAbstractSocket::IPv6Protocol) {
|
||||||
qusSocket6->writeDatagram(reinterpret_cast< const char * >(encodedPacket.data()), encodedPacket.size(), host,
|
qusSocket6->writeDatagram(reinterpret_cast< const char * >(encodedPacket.data()),
|
||||||
port);
|
static_cast< qint64 >(encodedPacket.size()), host, port);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1811,7 +1812,8 @@ void ConnectDialog::udpReply() {
|
|||||||
|
|
||||||
gsl::span< Mumble::Protocol::byte > buffer = m_udpDecoder.getBuffer();
|
gsl::span< Mumble::Protocol::byte > buffer = m_udpDecoder.getBuffer();
|
||||||
|
|
||||||
std::size_t len = sock->readDatagram(reinterpret_cast< char * >(buffer.data()), buffer.size(), &host, &port);
|
std::size_t len = static_cast< std::size_t >(sock->readDatagram(
|
||||||
|
reinterpret_cast< char * >(buffer.data()), static_cast< int >(buffer.size()), &host, &port));
|
||||||
|
|
||||||
// Pings are special in that they can be decoded in the new or the old format, if the protocol version is set to
|
// Pings are special in that they can be decoded in the new or the old format, if the protocol version is set to
|
||||||
// the old format (which UNKNOWN does). Thus by setting the version to UNKNOWN, we effectively enable to decode
|
// the old format (which UNKNOWN does). Thus by setting the version to UNKNOWN, we effectively enable to decode
|
||||||
|
|||||||
@ -72,7 +72,7 @@ QString GetDeviceStringProperty(AudioObjectID device_id, AudioObjectPropertySele
|
|||||||
device_id, &property_address, 0,
|
device_id, &property_address, 0,
|
||||||
nullptr, &size, &property_value);
|
nullptr, &size, &property_value);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
throw CoreAudioException(QString("Unable to get string property %1 of %2.").arg(property_selector, device_id));
|
throw CoreAudioException(QString("Unable to get string property %1 of %2.").arg(property_selector).arg(static_cast<int>(device_id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
@ -89,7 +89,7 @@ UInt32 GetDeviceUint32Property(AudioObjectID device_id, AudioObjectPropertySelec
|
|||||||
UInt32 size = sizeof(property_value);
|
UInt32 size = sizeof(property_value);
|
||||||
OSStatus result = AudioObjectGetPropertyData(device_id, &property_address, 0, nullptr, &size, &property_value);
|
OSStatus result = AudioObjectGetPropertyData(device_id, &property_address, 0, nullptr, &size, &property_value);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
throw CoreAudioException(QString("Unable to get uint32 property %1 of %2.").arg(property_selector, device_id));
|
throw CoreAudioException(QString("Unable to get uint32 property %1 of %2.").arg(property_selector).arg(static_cast<int>(device_id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return property_value;
|
return property_value;
|
||||||
@ -103,7 +103,7 @@ UInt32 GetDevicePropertySize(AudioObjectID device_id, AudioObjectPropertySelecto
|
|||||||
UInt32 size = 0;
|
UInt32 size = 0;
|
||||||
OSStatus result = AudioObjectGetPropertyDataSize(device_id, &property_address, 0, nullptr, &size);
|
OSStatus result = AudioObjectGetPropertyDataSize(device_id, &property_address, 0, nullptr, &size);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
throw CoreAudioException(QString("Unable to get property size of %1 of %2.").arg(property_selector, device_id));
|
throw CoreAudioException(QString("Unable to get property size of %1 of %2.").arg(property_selector).arg(static_cast<int>(device_id)));
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
@ -710,7 +710,7 @@ bool CoreAudioInput::initializeInputAU(AudioUnit au, AudioStreamBasicDescription
|
|||||||
|
|
||||||
qWarning("CoreAudioInput: BufferFrameSizeRange = (%.2f, %.2f)", range.mMinimum, range.mMaximum);
|
qWarning("CoreAudioInput: BufferFrameSizeRange = (%.2f, %.2f)", range.mMinimum, range.mMaximum);
|
||||||
|
|
||||||
actualBufferLength = iMicLength;
|
actualBufferLength = static_cast<int>(iMicLength);
|
||||||
val = iMicLength;
|
val = iMicLength;
|
||||||
propertyAddress.mSelector = kAudioDevicePropertyBufferFrameSize;
|
propertyAddress.mSelector = kAudioDevicePropertyBufferFrameSize;
|
||||||
err = AudioObjectSetPropertyData(inputDevId, &propertyAddress, 0, nullptr, sizeof(UInt32), &val);
|
err = AudioObjectSetPropertyData(inputDevId, &propertyAddress, 0, nullptr, sizeof(UInt32), &val);
|
||||||
@ -836,7 +836,7 @@ void CoreAudioInput::run() {
|
|||||||
buflist.mNumberBuffers = 1;
|
buflist.mNumberBuffers = 1;
|
||||||
AudioBuffer *b = buflist.mBuffers;
|
AudioBuffer *b = buflist.mBuffers;
|
||||||
b->mNumberChannels = iMicChannels;
|
b->mNumberChannels = iMicChannels;
|
||||||
b->mDataByteSize = iMicSampleSize * actualBufferLength;
|
b->mDataByteSize = iMicSampleSize * static_cast<unsigned int>(actualBufferLength);
|
||||||
b->mData = calloc(1, b->mDataByteSize);
|
b->mData = calloc(1, b->mDataByteSize);
|
||||||
|
|
||||||
// Start!
|
// Start!
|
||||||
@ -1003,7 +1003,7 @@ void CoreAudioOutput::run() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
iMixerFreq = static_cast< unsigned int >(fmt.mSampleRate);
|
iMixerFreq = static_cast< unsigned int >(fmt.mSampleRate);
|
||||||
iChannels = static_cast< int >(fmt.mChannelsPerFrame);
|
iChannels = static_cast< unsigned int >(fmt.mChannelsPerFrame);
|
||||||
|
|
||||||
if (fmt.mFormatFlags & kAudioFormatFlagIsFloat) {
|
if (fmt.mFormatFlags & kAudioFormatFlagIsFloat) {
|
||||||
eSampleFormat = SampleFloat;
|
eSampleFormat = SampleFloat;
|
||||||
@ -1064,7 +1064,7 @@ void CoreAudioOutput::run() {
|
|||||||
if (err != noErr) {
|
if (err != noErr) {
|
||||||
qWarning("CoreAudioOutput: Unable to query for allowed buffer size ranges.");
|
qWarning("CoreAudioOutput: Unable to query for allowed buffer size ranges.");
|
||||||
} else {
|
} else {
|
||||||
setBufferSize(range.mMaximum);
|
setBufferSize(static_cast<unsigned int>(range.mMaximum));
|
||||||
qWarning("CoreAudioOutput: BufferFrameSizeRange = (%.2f, %.2f)", range.mMinimum, range.mMaximum);
|
qWarning("CoreAudioOutput: BufferFrameSizeRange = (%.2f, %.2f)", range.mMinimum, range.mMaximum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -88,7 +88,7 @@ void ChatbarTextEdit::contextMenuEvent(QContextMenuEvent *qcme) {
|
|||||||
QMenu *menu = createStandardContextMenu();
|
QMenu *menu = createStandardContextMenu();
|
||||||
|
|
||||||
QAction *action = new QAction(tr("Paste and &Send") + QLatin1Char('\t'), menu);
|
QAction *action = new QAction(tr("Paste and &Send") + QLatin1Char('\t'), menu);
|
||||||
action->setShortcut(Qt::CTRL + Qt::Key_Shift + Qt::Key_V);
|
action->setShortcut(static_cast< int >(Qt::CTRL) | Qt::Key_Shift | Qt::Key_V);
|
||||||
action->setEnabled(!QApplication::clipboard()->text().isEmpty());
|
action->setEnabled(!QApplication::clipboard()->text().isEmpty());
|
||||||
connect(action, SIGNAL(triggered()), this, SLOT(pasteAndSend_triggered()));
|
connect(action, SIGNAL(triggered()), this, SLOT(pasteAndSend_triggered()));
|
||||||
if (menu->actions().count() > 6)
|
if (menu->actions().count() > 6)
|
||||||
@ -138,7 +138,7 @@ QSize ChatbarTextEdit::minimumSizeHint() const {
|
|||||||
QSize ChatbarTextEdit::sizeHint() const {
|
QSize ChatbarTextEdit::sizeHint() const {
|
||||||
QSize sh = QTextEdit::sizeHint();
|
QSize sh = QTextEdit::sizeHint();
|
||||||
const int minHeight = minimumSizeHint().height();
|
const int minHeight = minimumSizeHint().height();
|
||||||
const int documentHeight = document()->documentLayout()->documentSize().height();
|
const int documentHeight = static_cast< int >(document()->documentLayout()->documentSize().height());
|
||||||
sh.setHeight(std::max(minHeight, documentHeight));
|
sh.setHeight(std::max(minHeight, documentHeight));
|
||||||
const_cast< ChatbarTextEdit * >(this)->setMaximumHeight(sh.height());
|
const_cast< ChatbarTextEdit * >(this)->setMaximumHeight(sh.height());
|
||||||
return sh;
|
return sh;
|
||||||
@ -218,7 +218,7 @@ bool ChatbarTextEdit::sendImagesFromMimeData(const QMimeData *source) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ChatbarTextEdit::emitPastedImage(QImage image) {
|
bool ChatbarTextEdit::emitPastedImage(QImage image) {
|
||||||
QString processedImage = Log::imageToImg(image, Global::get().uiImageLength);
|
QString processedImage = Log::imageToImg(image, static_cast< int >(Global::get().uiImageLength));
|
||||||
if (processedImage.length() > 0) {
|
if (processedImage.length() > 0) {
|
||||||
QString imgHtml = QLatin1String("<br />") + processedImage;
|
QString imgHtml = QLatin1String("<br />") + processedImage;
|
||||||
emit pastedImage(imgHtml);
|
emit pastedImage(imgHtml);
|
||||||
@ -413,8 +413,9 @@ bool DockTitleBar::eventFilter(QObject *, QEvent *evt) {
|
|||||||
case QEvent::MouseButtonRelease: {
|
case QEvent::MouseButtonRelease: {
|
||||||
newsize = 0;
|
newsize = 0;
|
||||||
QPoint p = qdw->mapFromGlobal(QCursor::pos());
|
QPoint p = qdw->mapFromGlobal(QCursor::pos());
|
||||||
if ((p.x() >= iroundf(static_cast< float >(qdw->width()) * 0.1f + 0.5f))
|
if ((p.x() >= static_cast< int >(static_cast< float >(qdw->width()) * 0.1f + 0.5f))
|
||||||
&& (p.x() < iroundf(static_cast< float >(qdw->width()) * 0.9f + 0.5f)) && (p.y() >= 0) && (p.y() < 15))
|
&& (p.x() < static_cast< int >(static_cast< float >(qdw->width()) * 0.9f + 0.5f)) && (p.y() >= 0)
|
||||||
|
&& (p.y() < 15))
|
||||||
newsize = 15;
|
newsize = 15;
|
||||||
if (newsize > 0 && !qtTick->isActive())
|
if (newsize > 0 && !qtTick->isActive())
|
||||||
qtTick->start(500);
|
qtTick->start(500);
|
||||||
|
|||||||
@ -399,7 +399,7 @@ void Database::setLocalMuted(const QString &hash, bool muted) {
|
|||||||
execQueryAndLogFailure(query);
|
execQueryAndLogFailure(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelFilterMode Database::getChannelFilterMode(const QByteArray &server_cert_digest, const int channel_id) {
|
ChannelFilterMode Database::getChannelFilterMode(const QByteArray &server_cert_digest, const unsigned int channel_id) {
|
||||||
QSqlQuery query(db);
|
QSqlQuery query(db);
|
||||||
|
|
||||||
query.prepare(QLatin1String(
|
query.prepare(QLatin1String(
|
||||||
@ -415,7 +415,7 @@ ChannelFilterMode Database::getChannelFilterMode(const QByteArray &server_cert_d
|
|||||||
return ChannelFilterMode::NORMAL;
|
return ChannelFilterMode::NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::setChannelFilterMode(const QByteArray &server_cert_digest, const int channel_id,
|
void Database::setChannelFilterMode(const QByteArray &server_cert_digest, const unsigned int channel_id,
|
||||||
const ChannelFilterMode filterMode) {
|
const ChannelFilterMode filterMode) {
|
||||||
QSqlQuery query(db);
|
QSqlQuery query(db);
|
||||||
|
|
||||||
|
|||||||
@ -55,8 +55,9 @@ public:
|
|||||||
QString getUserLocalNickname(const QString &hash);
|
QString getUserLocalNickname(const QString &hash);
|
||||||
void setUserLocalNickname(const QString &hash, const QString &nickname);
|
void setUserLocalNickname(const QString &hash, const QString &nickname);
|
||||||
|
|
||||||
ChannelFilterMode getChannelFilterMode(const QByteArray &server_cert_digest, int channel_id);
|
ChannelFilterMode getChannelFilterMode(const QByteArray &server_cert_digest, unsigned int channel_id);
|
||||||
void setChannelFilterMode(const QByteArray &server_cert_digest, int channel_id, ChannelFilterMode filterMode);
|
void setChannelFilterMode(const QByteArray &server_cert_digest, unsigned int channel_id,
|
||||||
|
ChannelFilterMode filterMode);
|
||||||
|
|
||||||
QMap< UnresolvedServerAddress, unsigned int > getPingCache();
|
QMap< UnresolvedServerAddress, unsigned int > getPingCache();
|
||||||
void setPingCache(const QMap< UnresolvedServerAddress, unsigned int > &cache);
|
void setPingCache(const QMap< UnresolvedServerAddress, unsigned int > &cache);
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
class DeveloperConsole : public QObject {
|
class DeveloperConsole : public QObject {
|
||||||
private:
|
private:
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_DISABLE_COPY(DeveloperConsole);
|
Q_DISABLE_COPY(DeveloperConsole)
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QPointer< QMainWindow > m_window;
|
QPointer< QMainWindow > m_window;
|
||||||
|
|||||||
@ -247,7 +247,7 @@ namespace details {
|
|||||||
|
|
||||||
PROCESS_ALL_ENUMS
|
PROCESS_ALL_ENUMS
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#undef PROCESS
|
#undef PROCESS
|
||||||
#undef AFTER_CODE
|
#undef AFTER_CODE
|
||||||
|
|||||||
@ -62,7 +62,7 @@ void stringToEnum(const std::string &str, OverlaySettings::OverlayShow &e);
|
|||||||
void stringToEnum(const std::string &str, OverlaySettings::OverlaySort &e);
|
void stringToEnum(const std::string &str, OverlaySettings::OverlaySort &e);
|
||||||
void stringToEnum(const std::string &str, OverlaySettings::OverlayExclusionMode &e);
|
void stringToEnum(const std::string &str, OverlaySettings::OverlayExclusionMode &e);
|
||||||
|
|
||||||
}; // namespace details
|
} // namespace details
|
||||||
|
|
||||||
template< typename T > T stringToEnum(const std::string &str) {
|
template< typename T > T stringToEnum(const std::string &str) {
|
||||||
static_assert(std::is_enum< T >::value, "Only enums can be converted to strings with this function");
|
static_assert(std::is_enum< T >::value, "Only enums can be converted to strings with this function");
|
||||||
|
|||||||
@ -138,11 +138,6 @@ Global::Global(const QString &qsConfigPath) {
|
|||||||
|
|
||||||
channelListenerManager = std::make_unique< ChannelListenerManager >();
|
channelListenerManager = std::make_unique< ChannelListenerManager >();
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
|
||||||
QString appdata;
|
|
||||||
wchar_t appData[MAX_PATH];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (qsConfigPath.isEmpty()) {
|
if (qsConfigPath.isEmpty()) {
|
||||||
qdBasePath.setPath(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
|
qdBasePath.setPath(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
|
||||||
|
|
||||||
|
|||||||
@ -74,11 +74,11 @@ public:
|
|||||||
Timer tDoublePush;
|
Timer tDoublePush;
|
||||||
quint64 uiDoublePush;
|
quint64 uiDoublePush;
|
||||||
/// Holds the current VoiceTarget ID to send audio to
|
/// Holds the current VoiceTarget ID to send audio to
|
||||||
int iTarget;
|
std::int32_t iTarget;
|
||||||
/// Holds the value of iTarget before its last change until the current
|
/// Holds the value of iTarget before its last change until the current
|
||||||
/// audio-stream ends (and it has a value > 0). See the comment in
|
/// audio-stream ends (and it has a value > 0). See the comment in
|
||||||
/// AudioInput::flushCheck for further details on this.
|
/// AudioInput::flushCheck for further details on this.
|
||||||
int iPrevTarget;
|
std::int32_t iPrevTarget;
|
||||||
bool bPushToMute;
|
bool bPushToMute;
|
||||||
bool bCenterPosition;
|
bool bCenterPosition;
|
||||||
bool bPosTest;
|
bool bPosTest;
|
||||||
|
|||||||
@ -74,7 +74,7 @@ ShortcutActionWidget::ShortcutActionWidget(QWidget *p) : MUComboBox(p) {
|
|||||||
model()->sort(0);
|
model()->sort(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShortcutActionWidget::setIndex(int idx) {
|
void ShortcutActionWidget::setIndex(unsigned int idx) {
|
||||||
setCurrentIndex(findData(idx));
|
setCurrentIndex(findData(idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,14 +128,14 @@ void ChannelSelectWidget::setCurrentChannel(const ChannelTarget &target) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ChannelTarget ChannelSelectWidget::currentChannel() const {
|
ChannelTarget ChannelSelectWidget::currentChannel() const {
|
||||||
return itemData(currentIndex()).toInt();
|
return itemData(currentIndex()).toUInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void iterateChannelChildren(QTreeWidgetItem *root, Channel *chan, QMap< int, QTreeWidgetItem * > &map) {
|
void iterateChannelChildren(QTreeWidgetItem *root, Channel *chan, QMap< int, QTreeWidgetItem * > &map) {
|
||||||
foreach (Channel *c, chan->qlChannels) {
|
foreach (Channel *c, chan->qlChannels) {
|
||||||
QTreeWidgetItem *sub = new QTreeWidgetItem(root, QStringList(c->qsName));
|
QTreeWidgetItem *sub = new QTreeWidgetItem(root, QStringList(c->qsName));
|
||||||
sub->setData(0, Qt::UserRole, c->iId);
|
sub->setData(0, Qt::UserRole, c->iId);
|
||||||
map.insert(c->iId, sub);
|
map.insert(static_cast< int >(c->iId), sub);
|
||||||
iterateChannelChildren(sub, c, map);
|
iterateChannelChildren(sub, c, map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,7 +254,7 @@ ShortcutTargetDialog::ShortcutTargetDialog(const ShortcutTarget &st, QWidget *pw
|
|||||||
|
|
||||||
QTreeWidgetItem *qtwi;
|
QTreeWidgetItem *qtwi;
|
||||||
if (Global::get().uiSession) {
|
if (Global::get().uiSession) {
|
||||||
qtwi = qmTree.value(ClientUser::get(Global::get().uiSession)->cChannel->iId);
|
qtwi = qmTree.value(static_cast< int >(ClientUser::get(Global::get().uiSession)->cChannel->iId));
|
||||||
if (qtwi)
|
if (qtwi)
|
||||||
qtwChannels->scrollToItem(qtwi);
|
qtwChannels->scrollToItem(qtwi);
|
||||||
}
|
}
|
||||||
@ -408,7 +408,7 @@ QString ShortcutTargetWidget::targetString(const ShortcutTarget &st) {
|
|||||||
return tr("Subchannel #%1").arg(SHORTCUT_TARGET_CURRENT - st.iChannel);
|
return tr("Subchannel #%1").arg(SHORTCUT_TARGET_CURRENT - st.iChannel);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Channel *c = Channel::get(st.iChannel);
|
Channel *c = Channel::get(static_cast< unsigned int >(st.iChannel));
|
||||||
if (c)
|
if (c)
|
||||||
return c->qsName;
|
return c->qsName;
|
||||||
else
|
else
|
||||||
@ -457,9 +457,9 @@ ShortcutDelegate::ShortcutDelegate(QObject *p) : QStyledItemDelegate(p) {
|
|||||||
factory->registerEditor(QVariant::List, new QStandardItemEditorCreator< GlobalShortcutButtons >());
|
factory->registerEditor(QVariant::List, new QStandardItemEditorCreator< GlobalShortcutButtons >());
|
||||||
factory->registerEditor(QVariant::UInt, new QStandardItemEditorCreator< ShortcutActionWidget >());
|
factory->registerEditor(QVariant::UInt, new QStandardItemEditorCreator< ShortcutActionWidget >());
|
||||||
factory->registerEditor(QVariant::Int, new QStandardItemEditorCreator< ShortcutToggleWidget >());
|
factory->registerEditor(QVariant::Int, new QStandardItemEditorCreator< ShortcutToggleWidget >());
|
||||||
factory->registerEditor(static_cast< QVariant::Type >(QVariant::fromValue(ShortcutTarget()).userType()),
|
factory->registerEditor(static_cast< int >(QVariant::fromValue(ShortcutTarget()).userType()),
|
||||||
new QStandardItemEditorCreator< ShortcutTargetWidget >());
|
new QStandardItemEditorCreator< ShortcutTargetWidget >());
|
||||||
factory->registerEditor(static_cast< QVariant::Type >(QVariant::fromValue(ChannelTarget()).userType()),
|
factory->registerEditor(static_cast< int >(QVariant::fromValue(ChannelTarget()).userType()),
|
||||||
new QStandardItemEditorCreator< ChannelSelectWidget >());
|
new QStandardItemEditorCreator< ChannelSelectWidget >());
|
||||||
factory->registerEditor(QVariant::String, new QStandardItemEditorCreator< QLineEdit >());
|
factory->registerEditor(QVariant::String, new QStandardItemEditorCreator< QLineEdit >());
|
||||||
factory->registerEditor(QVariant::Invalid, new QStandardItemEditorCreator< QWidget >());
|
factory->registerEditor(QVariant::Invalid, new QStandardItemEditorCreator< QWidget >());
|
||||||
|
|||||||
@ -59,7 +59,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
ShortcutActionWidget(QWidget *p = nullptr);
|
ShortcutActionWidget(QWidget *p = nullptr);
|
||||||
unsigned int index() const;
|
unsigned int index() const;
|
||||||
void setIndex(int);
|
void setIndex(unsigned int);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ShortcutToggleWidget : public MUComboBox {
|
class ShortcutToggleWidget : public MUComboBox {
|
||||||
|
|||||||
@ -31,11 +31,11 @@ QList< QVariant > GlobalShortcutButtons::buttons() {
|
|||||||
|
|
||||||
QList< QVariant > buttons;
|
QList< QVariant > buttons;
|
||||||
|
|
||||||
const auto rootItem = m_ui->buttonTree->invisibleRootItem();
|
const QTreeWidgetItem *rootItem = m_ui->buttonTree->invisibleRootItem();
|
||||||
for (auto i = 0; i < rootItem->childCount(); ++i) {
|
for (int i = 0; i < rootItem->childCount(); ++i) {
|
||||||
const auto buttonItem = rootItem->child(i);
|
const QTreeWidgetItem *buttonItem = rootItem->child(i);
|
||||||
for (auto i = 0; i < buttonItem->childCount(); ++i) {
|
for (int k = 0; k < buttonItem->childCount(); ++k) {
|
||||||
buttons.append(buttonItem->child(i)->data(0, Qt::UserRole));
|
buttons.append(buttonItem->child(k)->data(0, Qt::UserRole));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -54,8 +54,8 @@ CGEventRef GlobalShortcutMac::callback(CGEventTapProxy proxy, CGEventType type,
|
|||||||
if (Global::get().ocIntercept) {
|
if (Global::get().ocIntercept) {
|
||||||
int64_t dx = CGEventGetIntegerValueField(event, kCGMouseEventDeltaX);
|
int64_t dx = CGEventGetIntegerValueField(event, kCGMouseEventDeltaX);
|
||||||
int64_t dy = CGEventGetIntegerValueField(event, kCGMouseEventDeltaY);
|
int64_t dy = CGEventGetIntegerValueField(event, kCGMouseEventDeltaY);
|
||||||
Global::get().ocIntercept->iMouseX = qBound<int>(0, Global::get().ocIntercept->iMouseX + static_cast<int>(dx), Global::get().ocIntercept->uiWidth - 1);
|
Global::get().ocIntercept->iMouseX = qBound<int>(0, Global::get().ocIntercept->iMouseX + static_cast<int>(dx), Global::get().ocIntercept->iWidth - 1);
|
||||||
Global::get().ocIntercept->iMouseY = qBound<int>(0, Global::get().ocIntercept->iMouseY + static_cast<int>(dy), Global::get().ocIntercept->uiHeight - 1);
|
Global::get().ocIntercept->iMouseY = qBound<int>(0, Global::get().ocIntercept->iMouseY + static_cast<int>(dy), Global::get().ocIntercept->iHeight - 1);
|
||||||
QMetaObject::invokeMethod(Global::get().ocIntercept, "updateMouse", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(Global::get().ocIntercept, "updateMouse", Qt::QueuedConnection);
|
||||||
forward = true;
|
forward = true;
|
||||||
}
|
}
|
||||||
@ -292,7 +292,7 @@ void GlobalShortcutMac::forwardEvent(void *evt) {
|
|||||||
|
|
||||||
if (sel) {
|
if (sel) {
|
||||||
NSPoint p; p.x = (CGFloat) Global::get().ocIntercept->iMouseX;
|
NSPoint p; p.x = (CGFloat) Global::get().ocIntercept->iMouseX;
|
||||||
p.y = (CGFloat) (Global::get().ocIntercept->uiHeight - Global::get().ocIntercept->iMouseY);
|
p.y = (CGFloat) (Global::get().ocIntercept->iHeight - Global::get().ocIntercept->iMouseY);
|
||||||
NSEvent *mouseEvent = [NSEvent mouseEventWithType:[event type] location:p modifierFlags:[event modifierFlags] timestamp:[event timestamp]
|
NSEvent *mouseEvent = [NSEvent mouseEventWithType:[event type] location:p modifierFlags:[event modifierFlags] timestamp:[event timestamp]
|
||||||
windowNumber:0 context:nil eventNumber:[event eventNumber] clickCount:[event clickCount]
|
windowNumber:0 context:nil eventNumber:[event eventNumber] clickCount:[event clickCount]
|
||||||
pressure:[event pressure]];
|
pressure:[event pressure]];
|
||||||
@ -392,7 +392,8 @@ QString GlobalShortcutMac::translateModifierKey(const unsigned int keycode) cons
|
|||||||
QString GlobalShortcutMac::translateKeyName(const unsigned int keycode) const {
|
QString GlobalShortcutMac::translateKeyName(const unsigned int keycode) const {
|
||||||
UInt32 junk = 0;
|
UInt32 junk = 0;
|
||||||
UniCharCount len = 64;
|
UniCharCount len = 64;
|
||||||
UniChar unicodeString[len];
|
std::vector<UniChar> unicodeString;
|
||||||
|
unicodeString.resize(static_cast<std::size_t>(len));
|
||||||
|
|
||||||
if (! kbdLayout)
|
if (! kbdLayout)
|
||||||
return QString();
|
return QString();
|
||||||
@ -400,7 +401,7 @@ QString GlobalShortcutMac::translateKeyName(const unsigned int keycode) const {
|
|||||||
OSStatus err = UCKeyTranslate(kbdLayout, static_cast<UInt16>(keycode),
|
OSStatus err = UCKeyTranslate(kbdLayout, static_cast<UInt16>(keycode),
|
||||||
kUCKeyActionDisplay, 0, LMGetKbdType(),
|
kUCKeyActionDisplay, 0, LMGetKbdType(),
|
||||||
kUCKeyTranslateNoDeadKeysBit, &junk,
|
kUCKeyTranslateNoDeadKeysBit, &junk,
|
||||||
len, &len, unicodeString);
|
len, &len, unicodeString.data());
|
||||||
if (err != noErr)
|
if (err != noErr)
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
@ -412,7 +413,7 @@ QString GlobalShortcutMac::translateKeyName(const unsigned int keycode) const {
|
|||||||
return QLatin1String("Enter");
|
return QLatin1String("Enter");
|
||||||
case '\b':
|
case '\b':
|
||||||
return QLatin1String("Backspace");
|
return QLatin1String("Backspace");
|
||||||
case '\e':
|
case 27:
|
||||||
return QLatin1String("Escape");
|
return QLatin1String("Escape");
|
||||||
case ' ':
|
case ' ':
|
||||||
return QLatin1String("Space");
|
return QLatin1String("Space");
|
||||||
@ -432,7 +433,7 @@ QString GlobalShortcutMac::translateKeyName(const unsigned int keycode) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QString(reinterpret_cast<const QChar *>(unicodeString), len).toUpper();
|
return QString(reinterpret_cast<const QChar *>(unicodeString.data()), static_cast<int>(len)).toUpper();
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalShortcutMac::ButtonInfo GlobalShortcutMac::buttonInfo(const QVariant &v) {
|
GlobalShortcutMac::ButtonInfo GlobalShortcutMac::buttonInfo(const QVariant &v) {
|
||||||
|
|||||||
@ -198,8 +198,8 @@ void GlobalShortcutX::run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 8; i <= 12; ++i) {
|
for (int i = 8; i <= 12; ++i) {
|
||||||
bool oldstate = (mask[idx] & (1 << i)) != 0;
|
bool oldstate = (mask[idx] & static_cast< unsigned int >(1 << i)) != 0;
|
||||||
bool newstate = (mask[next] & (1 << i)) != 0;
|
bool newstate = (mask[next] & static_cast< unsigned int >(1 << i)) != 0;
|
||||||
if (oldstate != newstate) {
|
if (oldstate != newstate) {
|
||||||
handleButton(0x110 + i, newstate);
|
handleButton(0x110 + i, newstate);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,14 @@
|
|||||||
// For detailed info about RAWKEYBOARD handling:
|
// For detailed info about RAWKEYBOARD handling:
|
||||||
// https://blog.molecular-matters.com/2011/09/05/properly-handling-keyboard-input
|
// https://blog.molecular-matters.com/2011/09/05/properly-handling-keyboard-input
|
||||||
|
|
||||||
|
#ifdef _MSVC_LANG
|
||||||
|
# pragma warning(push)
|
||||||
|
// SPSCQueue does some funky alignment tricks which trigger the C4316
|
||||||
|
// warning about potential misalignment on the heap.
|
||||||
|
// We just have to trust the SPSCQueue implementation here.
|
||||||
|
# pragma warning(disable : 4316)
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "GlobalShortcut_win.h"
|
#include "GlobalShortcut_win.h"
|
||||||
|
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
@ -489,7 +497,7 @@ void GlobalShortcutWin::processMsgHid(MsgHid &msg) {
|
|||||||
#endif
|
#endif
|
||||||
auto data = reinterpret_cast< PHIDP_PREPARSED_DATA >(&device.data[0]);
|
auto data = reinterpret_cast< PHIDP_PREPARSED_DATA >(&device.data[0]);
|
||||||
|
|
||||||
ULONG nUsages = device.buttons.size();
|
ULONG nUsages = static_cast< ULONG >(device.buttons.size());
|
||||||
std::vector< USAGE > usages(nUsages);
|
std::vector< USAGE > usages(nUsages);
|
||||||
if (HidP_GetUsages(HidP_Input, HID_USAGE_PAGE_BUTTON, 0, &usages[0], &nUsages, data, &msg.reports[0],
|
if (HidP_GetUsages(HidP_Input, HID_USAGE_PAGE_BUTTON, 0, &usages[0], &nUsages, data, &msg.reports[0],
|
||||||
msg.reportSize)
|
msg.reportSize)
|
||||||
@ -623,12 +631,12 @@ GlobalShortcutWin::DeviceMap::iterator GlobalShortcutWin::addDevice(const HANDLE
|
|||||||
|
|
||||||
std::wstring_convert< std::codecvt_utf8_utf16< wchar_t > > conv;
|
std::wstring_convert< std::codecvt_utf8_utf16< wchar_t > > conv;
|
||||||
|
|
||||||
if (HidD_GetManufacturerString(handle, &name[0], sizeof(wchar_t) * name.size())) {
|
if (HidD_GetManufacturerString(handle, &name[0], static_cast< ULONG >(sizeof(wchar_t) * name.size()))) {
|
||||||
nameStream << ' ' << conv.to_bytes(name);
|
nameStream << ' ' << conv.to_bytes(name);
|
||||||
name.clear();
|
name.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HidD_GetProductString(handle, &name[0], sizeof(wchar_t) * name.size())) {
|
if (HidD_GetProductString(handle, &name[0], static_cast< ULONG >(sizeof(wchar_t) * name.size()))) {
|
||||||
nameStream << ' ' << conv.to_bytes(name);
|
nameStream << ' ' << conv.to_bytes(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -881,3 +889,7 @@ GlobalShortcutWin::ButtonInfo GlobalShortcutWin::buttonInfo(const QVariant &butt
|
|||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _MSVC_LANG
|
||||||
|
# pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|||||||
@ -113,7 +113,7 @@ template<> inline QString from_string< QString >(const std::string &str) {
|
|||||||
return QString::fromStdString(str);
|
return QString::fromStdString(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // namespace details
|
} // namespace details
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -600,17 +600,17 @@ void JackAudioSystem::ringbufferWriteAdvance(jack_ringbuffer_t *buffer, const si
|
|||||||
}
|
}
|
||||||
|
|
||||||
int JackAudioSystem::processCallback(jack_nframes_t frames, void *) {
|
int JackAudioSystem::processCallback(jack_nframes_t frames, void *) {
|
||||||
auto const jai = dynamic_cast< JackAudioInput * >(Global::get().ai.get());
|
auto const input = dynamic_cast< JackAudioInput * >(Global::get().ai.get());
|
||||||
auto const jao = dynamic_cast< JackAudioOutput * >(Global::get().ao.get());
|
auto const output = dynamic_cast< JackAudioOutput * >(Global::get().ao.get());
|
||||||
|
|
||||||
const bool input = (jai && jai->isReady());
|
const bool canInput = (input && input->isReady());
|
||||||
const bool output = (jao && jao->isReady());
|
const bool canOutput = (output && output->isReady());
|
||||||
|
|
||||||
if (input && !jai->process(frames)) {
|
if (canInput && !input->process(frames)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output && !jao->process(frames)) {
|
if (canOutput && !output->process(frames)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -618,29 +618,29 @@ int JackAudioSystem::processCallback(jack_nframes_t frames, void *) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int JackAudioSystem::sampleRateCallback(jack_nframes_t, void *) {
|
int JackAudioSystem::sampleRateCallback(jack_nframes_t, void *) {
|
||||||
auto const jai = dynamic_cast< JackAudioInput * >(Global::get().ai.get());
|
auto const input = dynamic_cast< JackAudioInput * >(Global::get().ai.get());
|
||||||
auto const jao = dynamic_cast< JackAudioOutput * >(Global::get().ao.get());
|
auto const output = dynamic_cast< JackAudioOutput * >(Global::get().ao.get());
|
||||||
|
|
||||||
if (jai) {
|
if (input) {
|
||||||
jai->activate();
|
input->activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jao) {
|
if (output) {
|
||||||
jao->activate();
|
output->activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int JackAudioSystem::bufferSizeCallback(jack_nframes_t frames, void *) {
|
int JackAudioSystem::bufferSizeCallback(jack_nframes_t frames, void *) {
|
||||||
auto const jai = dynamic_cast< JackAudioInput * >(Global::get().ai.get());
|
auto const input = dynamic_cast< JackAudioInput * >(Global::get().ai.get());
|
||||||
auto const jao = dynamic_cast< JackAudioOutput * >(Global::get().ao.get());
|
auto const output = dynamic_cast< JackAudioOutput * >(Global::get().ao.get());
|
||||||
|
|
||||||
if (jai && !jai->allocBuffer(frames)) {
|
if (input && !input->allocBuffer(frames)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jao && !jao->allocBuffer(frames)) {
|
if (output && !output->allocBuffer(frames)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -837,7 +837,7 @@ void JackAudioInput::run() {
|
|||||||
|
|
||||||
while (const auto bytes = qMin(jas->ringbufferReadSpace(buffer), bufferSize)) {
|
while (const auto bytes = qMin(jas->ringbufferReadSpace(buffer), bufferSize)) {
|
||||||
jas->ringbufferRead(buffer, bytes, sampleBuffer.get());
|
jas->ringbufferRead(buffer, bytes, sampleBuffer.get());
|
||||||
addMic(sampleBuffer.get(), bytes / sizeof(jack_default_audio_sample_t));
|
addMic(sampleBuffer.get(), static_cast< unsigned int >(bytes / sizeof(jack_default_audio_sample_t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
qmWait.unlock();
|
qmWait.unlock();
|
||||||
@ -1015,18 +1015,19 @@ bool JackAudioOutput::process(const jack_nframes_t frames) {
|
|||||||
qsSleep.release(1);
|
qsSleep.release(1);
|
||||||
|
|
||||||
for (decltype(iChannels) currentChannel = 0; currentChannel < iChannels; ++currentChannel) {
|
for (decltype(iChannels) currentChannel = 0; currentChannel < iChannels; ++currentChannel) {
|
||||||
auto outputBuffer = jas->getPortBuffer(ports[currentChannel], frames);
|
auto outputBuffer = jas->getPortBuffer(ports[static_cast< int >(currentChannel)], frames);
|
||||||
if (!outputBuffer) {
|
if (!outputBuffer) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
outputBuffers.replace(currentChannel, reinterpret_cast< jack_default_audio_sample_t * >(outputBuffer));
|
outputBuffers.replace(static_cast< int >(currentChannel),
|
||||||
|
reinterpret_cast< jack_default_audio_sample_t * >(outputBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto avail = jas->ringbufferReadSpace(buffer);
|
const auto avail = jas->ringbufferReadSpace(buffer);
|
||||||
if (avail == 0) {
|
if (avail == 0) {
|
||||||
for (decltype(iChannels) currentChannel = 0; currentChannel < iChannels; ++currentChannel) {
|
for (decltype(iChannels) currentChannel = 0; currentChannel < iChannels; ++currentChannel) {
|
||||||
memset(outputBuffers[currentChannel], 0, frames * sizeof(jack_default_audio_sample_t));
|
memset(outputBuffers[static_cast< int >(currentChannel)], 0, frames * sizeof(jack_default_audio_sample_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -1037,7 +1038,7 @@ bool JackAudioOutput::process(const jack_nframes_t frames) {
|
|||||||
if (iChannels == 1) {
|
if (iChannels == 1) {
|
||||||
jas->ringbufferRead(buffer, avail, reinterpret_cast< char * >(outputBuffers[0]));
|
jas->ringbufferRead(buffer, avail, reinterpret_cast< char * >(outputBuffers[0]));
|
||||||
if (avail < needed) {
|
if (avail < needed) {
|
||||||
memset(reinterpret_cast< char * >(&(outputBuffers[avail])), 0, needed - avail);
|
memset(reinterpret_cast< char * >(&(outputBuffers[static_cast< int >(avail)])), 0, needed - avail);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -1047,12 +1048,14 @@ bool JackAudioOutput::process(const jack_nframes_t frames) {
|
|||||||
for (auto currentSample = decltype(samples){ 0 }; currentSample < samples; ++currentSample) {
|
for (auto currentSample = decltype(samples){ 0 }; currentSample < samples; ++currentSample) {
|
||||||
jas->ringbufferRead(
|
jas->ringbufferRead(
|
||||||
buffer, sizeof(jack_default_audio_sample_t),
|
buffer, sizeof(jack_default_audio_sample_t),
|
||||||
reinterpret_cast< char * >(&outputBuffers[currentSample % iChannels][currentSample / iChannels]));
|
reinterpret_cast< char * >(
|
||||||
|
&outputBuffers[static_cast< int >(currentSample % iChannels)][currentSample / iChannels]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((samples / iChannels) < frames) {
|
if ((samples / iChannels) < frames) {
|
||||||
for (decltype(iChannels) currentChannel = 0; currentChannel < iChannels; ++currentChannel) {
|
for (decltype(iChannels) currentChannel = 0; currentChannel < iChannels; ++currentChannel) {
|
||||||
memset(&outputBuffers[currentChannel][avail / samples], 0, (needed - avail) / iChannels);
|
memset(&outputBuffers[static_cast< int >(currentChannel)][avail / samples], 0,
|
||||||
|
(needed - avail) / iChannels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1088,7 +1091,8 @@ void JackAudioOutput::run() {
|
|||||||
|
|
||||||
auto bOk = true;
|
auto bOk = true;
|
||||||
size_t writtenFrames = 0;
|
size_t writtenFrames = 0;
|
||||||
auto wanted = qMin(writeVector->len / iSampleSize, static_cast< size_t >(iFrameSize));
|
unsigned int wanted =
|
||||||
|
qMin(static_cast< unsigned int >(writeVector->len) / iSampleSize, static_cast< unsigned int >(iFrameSize));
|
||||||
if (wanted > 0) {
|
if (wanted > 0) {
|
||||||
bOk = mix(writeVector->buf, wanted);
|
bOk = mix(writeVector->buf, wanted);
|
||||||
writtenFrames += bOk ? wanted : 0;
|
writtenFrames += bOk ? wanted : 0;
|
||||||
|
|||||||
@ -210,7 +210,7 @@ void LCD::initBuffers() {
|
|||||||
foreach (LCDDevice *d, devmgr.qlDevices) {
|
foreach (LCDDevice *d, devmgr.qlDevices) {
|
||||||
QSize size = d->size();
|
QSize size = d->size();
|
||||||
if (!qhImageBuffers.contains(size)) {
|
if (!qhImageBuffers.contains(size)) {
|
||||||
size_t buflen = (size.width() * size.height()) / 8;
|
size_t buflen = static_cast< std::size_t >(size.width() * size.height()) / 8;
|
||||||
qhImageBuffers[size] = new unsigned char[buflen];
|
qhImageBuffers[size] = new unsigned char[buflen];
|
||||||
qhImages[size] = new QImage(qhImageBuffers[size], size.width(), size.height(), QImage::Format_MonoLSB);
|
qhImages[size] = new QImage(qhImageBuffers[size], size.width(), size.height(), QImage::Format_MonoLSB);
|
||||||
}
|
}
|
||||||
@ -429,5 +429,5 @@ LCDDevice::~LCDDevice() {
|
|||||||
/* --- */
|
/* --- */
|
||||||
|
|
||||||
uint qHash(const QSize &size) {
|
uint qHash(const QSize &size) {
|
||||||
return ((size.width() & 0xffff) << 16) | (size.height() & 0xffff);
|
return static_cast< uint >((size.width() & 0xffff) << 16) | (size.height() & 0xffff);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,7 +54,7 @@ void ListenerVolumeSlider::on_VolumeSlider_changeCompleted() {
|
|||||||
|
|
||||||
// Timer values: 0, 50, 150, 350, 750, 1000 (ms)
|
// Timer values: 0, 50, 150, 350, 750, 1000 (ms)
|
||||||
m_resetTimer.stop();
|
m_resetTimer.stop();
|
||||||
m_sendTimer.start(m_currentSendDelay);
|
m_sendTimer.start(static_cast< int >(m_currentSendDelay));
|
||||||
m_currentSendDelay = std::min(1000u, (m_currentSendDelay + 25) * 2);
|
m_currentSendDelay = std::min(1000u, (m_currentSendDelay + 25) * 2);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -29,7 +29,7 @@ private:
|
|||||||
QTimer m_sendTimer;
|
QTimer m_sendTimer;
|
||||||
QTimer m_resetTimer;
|
QTimer m_resetTimer;
|
||||||
unsigned int m_currentSendDelay;
|
unsigned int m_currentSendDelay;
|
||||||
int m_cachedChannelID;
|
unsigned int m_cachedChannelID;
|
||||||
VolumeAdjustment m_cachedAdjustment;
|
VolumeAdjustment m_cachedAdjustment;
|
||||||
|
|
||||||
void sendToServer();
|
void sendToServer();
|
||||||
|
|||||||
@ -280,7 +280,7 @@ void LogConfig::save() const {
|
|||||||
}
|
}
|
||||||
if (i->checkState(ColStaticSound) == Qt::Checked)
|
if (i->checkState(ColStaticSound) == Qt::Checked)
|
||||||
v |= Settings::LogSoundfile;
|
v |= Settings::LogSoundfile;
|
||||||
s.qmMessages[mt] = v;
|
s.qmMessages[mt] = static_cast< unsigned int >(v);
|
||||||
s.qmMessageSounds[mt] = i->text(ColStaticSoundPath);
|
s.qmMessageSounds[mt] = i->text(ColStaticSoundPath);
|
||||||
}
|
}
|
||||||
s.iMaxLogBlocks = qsbMaxBlocks->value();
|
s.iMaxLogBlocks = qsbMaxBlocks->value();
|
||||||
@ -667,7 +667,7 @@ QString Log::validHtml(const QString &html, QTextCursor *tc) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int messageSize = s.width() * s.height();
|
int messageSize = static_cast< int >(s.width() * s.height());
|
||||||
int allowedSize = 2048 * 2048;
|
int allowedSize = 2048 * 2048;
|
||||||
|
|
||||||
if (messageSize > allowedSize) {
|
if (messageSize > allowedSize) {
|
||||||
|
|||||||
@ -192,6 +192,6 @@ public:
|
|||||||
LogDocumentResourceAddedEvent();
|
LogDocumentResourceAddedEvent();
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(Log::MsgType);
|
Q_DECLARE_METATYPE(Log::MsgType)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -943,7 +943,7 @@ bool MainWindow::handleSpecialContextMenu(const QUrl &url, const QPoint &pos_, b
|
|||||||
// plain integers in the host field as IP addresses
|
// plain integers in the host field as IP addresses
|
||||||
QByteArray qbaServerDigest = QByteArray::fromBase64(url.path().remove(0, 1).toLatin1());
|
QByteArray qbaServerDigest = QByteArray::fromBase64(url.path().remove(0, 1).toLatin1());
|
||||||
QString id = url.host().split(".").value(1, "-1");
|
QString id = url.host().split(".").value(1, "-1");
|
||||||
cuContextUser = ClientUser::get(id.toInt(&ok, 10));
|
cuContextUser = ClientUser::get(id.toUInt(&ok, 10));
|
||||||
ServerHandlerPtr sh = Global::get().sh;
|
ServerHandlerPtr sh = Global::get().sh;
|
||||||
ok = ok && sh && (qbaServerDigest == sh->qbaDigest);
|
ok = ok && sh && (qbaServerDigest == sh->qbaDigest);
|
||||||
}
|
}
|
||||||
@ -965,7 +965,7 @@ bool MainWindow::handleSpecialContextMenu(const QUrl &url, const QPoint &pos_, b
|
|||||||
bool ok;
|
bool ok;
|
||||||
QByteArray qbaServerDigest = QByteArray::fromBase64(url.path().remove(0, 1).toLatin1());
|
QByteArray qbaServerDigest = QByteArray::fromBase64(url.path().remove(0, 1).toLatin1());
|
||||||
QString id = url.host().split(".").value(1, "-1");
|
QString id = url.host().split(".").value(1, "-1");
|
||||||
cContextChannel = Channel::get(id.toInt(&ok, 10));
|
cContextChannel = Channel::get(id.toUInt(&ok, 10));
|
||||||
ServerHandlerPtr sh = Global::get().sh;
|
ServerHandlerPtr sh = Global::get().sh;
|
||||||
ok = ok && sh && (qbaServerDigest == sh->qbaDigest);
|
ok = ok && sh && (qbaServerDigest == sh->qbaDigest);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
@ -1227,7 +1227,7 @@ void MainWindow::openUrl(const QUrl &url) {
|
|||||||
std::swap(newSettings, Global::get().s);
|
std::swap(newSettings, Global::get().s);
|
||||||
|
|
||||||
Global::get().l->log(Log::Warning, tr("Settings merged from file."));
|
Global::get().l->log(Log::Warning, tr("Settings merged from file."));
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &) {
|
||||||
Global::get().l->log(Log::Warning, tr("Invalid settings file encountered."));
|
Global::get().l->log(Log::Warning, tr("Invalid settings file encountered."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2393,7 +2393,7 @@ void MainWindow::on_qaChannelRemove_triggered() {
|
|||||||
if (!c)
|
if (!c)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int id = c->iId;
|
unsigned int id = c->iId;
|
||||||
|
|
||||||
ret = QMessageBox::question(
|
ret = QMessageBox::question(
|
||||||
this, QLatin1String("Mumble"),
|
this, QLatin1String("Mumble"),
|
||||||
@ -2413,7 +2413,7 @@ void MainWindow::on_qaChannelACL_triggered() {
|
|||||||
Channel *c = getContextMenuChannel();
|
Channel *c = getContextMenuChannel();
|
||||||
if (!c)
|
if (!c)
|
||||||
c = Channel::get(Channel::ROOT_ID);
|
c = Channel::get(Channel::ROOT_ID);
|
||||||
int id = c->iId;
|
unsigned int id = c->iId;
|
||||||
|
|
||||||
if (!c->qbaDescHash.isEmpty() && c->qsDesc.isEmpty()) {
|
if (!c->qbaDescHash.isEmpty() && c->qsDesc.isEmpty()) {
|
||||||
c->qsDesc = QString::fromUtf8(Global::get().db->blob(c->qbaDescHash));
|
c->qsDesc = QString::fromUtf8(Global::get().db->blob(c->qbaDescHash));
|
||||||
@ -2467,7 +2467,7 @@ void MainWindow::on_qaChannelSendMessage_triggered() {
|
|||||||
if (!c)
|
if (!c)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int id = c->iId;
|
unsigned int id = c->iId;
|
||||||
|
|
||||||
::TextMessage *texm = new ::TextMessage(this, tr("Sending message to channel %1").arg(c->qsName), true);
|
::TextMessage *texm = new ::TextMessage(this, tr("Sending message to channel %1").arg(c->qsName), true);
|
||||||
int res = texm->exec();
|
int res = texm->exec();
|
||||||
@ -2879,7 +2879,7 @@ Channel *MainWindow::mapChannel(int idx) const {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
c = Channel::get(idx);
|
c = Channel::get(static_cast< unsigned int >(idx));
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@ -2903,7 +2903,7 @@ void MainWindow::updateTarget() {
|
|||||||
Channel *c = pmModel->getSelectedChannel();
|
Channel *c = pmModel->getSelectedChannel();
|
||||||
if (c) {
|
if (c) {
|
||||||
nt.bUsers = false;
|
nt.bUsers = false;
|
||||||
nt.iChannel = c->iId;
|
nt.iChannel = static_cast< int >(c->iId);
|
||||||
nt.bLinks = st.bLinks;
|
nt.bLinks = st.bLinks;
|
||||||
nt.bChildren = st.bChildren;
|
nt.bChildren = st.bChildren;
|
||||||
|
|
||||||
@ -2931,7 +2931,7 @@ void MainWindow::updateTarget() {
|
|||||||
if (c) {
|
if (c) {
|
||||||
nt.bLinks = st.bLinks;
|
nt.bLinks = st.bLinks;
|
||||||
nt.bChildren = st.bChildren;
|
nt.bChildren = st.bChildren;
|
||||||
nt.iChannel = c->iId;
|
nt.iChannel = static_cast< int >(c->iId);
|
||||||
nt.qsGroup = st.qsGroup;
|
nt.qsGroup = st.qsGroup;
|
||||||
ql << nt;
|
ql << nt;
|
||||||
}
|
}
|
||||||
@ -2964,7 +2964,7 @@ void MainWindow::updateTarget() {
|
|||||||
// Sets up a VoiceTarget (which is identified by the targetID idx) on the server for the given set
|
// Sets up a VoiceTarget (which is identified by the targetID idx) on the server for the given set
|
||||||
// of ShortcutTargets
|
// of ShortcutTargets
|
||||||
MumbleProto::VoiceTarget mpvt;
|
MumbleProto::VoiceTarget mpvt;
|
||||||
mpvt.set_id(idx);
|
mpvt.set_id(static_cast< unsigned int >(idx));
|
||||||
|
|
||||||
foreach (const ShortcutTarget &st, ql) {
|
foreach (const ShortcutTarget &st, ql) {
|
||||||
MumbleProto::VoiceTarget_Target *t = mpvt.add_targets();
|
MumbleProto::VoiceTarget_Target *t = mpvt.add_targets();
|
||||||
@ -2974,7 +2974,7 @@ void MainWindow::updateTarget() {
|
|||||||
foreach (unsigned int uisession, st.qlSessions)
|
foreach (unsigned int uisession, st.qlSessions)
|
||||||
t->add_session(uisession);
|
t->add_session(uisession);
|
||||||
} else {
|
} else {
|
||||||
t->set_channel_id(st.iChannel);
|
t->set_channel_id(static_cast< unsigned int >(st.iChannel));
|
||||||
if (st.bChildren)
|
if (st.bChildren)
|
||||||
t->set_children(true);
|
t->set_children(true);
|
||||||
if (st.bLinks)
|
if (st.bLinks)
|
||||||
@ -3007,7 +3007,7 @@ void MainWindow::updateTarget() {
|
|||||||
qmTargets.erase(mi);
|
qmTargets.erase(mi);
|
||||||
|
|
||||||
mpvt.Clear();
|
mpvt.Clear();
|
||||||
mpvt.set_id(oldidx);
|
mpvt.set_id(static_cast< unsigned int >(oldidx));
|
||||||
Global::get().sh->sendMessage(mpvt);
|
Global::get().sh->sendMessage(mpvt);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -41,7 +41,7 @@ class PTTButtonWidget;
|
|||||||
|
|
||||||
namespace Search {
|
namespace Search {
|
||||||
class SearchDialog;
|
class SearchDialog;
|
||||||
};
|
}
|
||||||
|
|
||||||
class MenuLabel;
|
class MenuLabel;
|
||||||
class ListenerVolumeSlider;
|
class ListenerVolumeSlider;
|
||||||
|
|||||||
@ -263,7 +263,7 @@ void Manual::on_speakerPositionUpdate(QHash< unsigned int, Position2D > position
|
|||||||
while (remainingIt.hasNext()) {
|
while (remainingIt.hasNext()) {
|
||||||
remainingIt.next();
|
remainingIt.next();
|
||||||
|
|
||||||
const float speakerRadius = 1.2;
|
const float speakerRadius = 1.2f;
|
||||||
QGraphicsItem *speakerItem = m_qgsScene->addEllipse(-speakerRadius, -speakerRadius, 2 * speakerRadius,
|
QGraphicsItem *speakerItem = m_qgsScene->addEllipse(-speakerRadius, -speakerRadius, 2 * speakerRadius,
|
||||||
2 * speakerRadius, QPen(), QBrush(Qt::red));
|
2 * speakerRadius, QPen(), QBrush(Qt::red));
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@ struct Position2D {
|
|||||||
// We need this typedef in order to be able to pass this hash as an argument
|
// We need this typedef in order to be able to pass this hash as an argument
|
||||||
// to QMetaObject::invokeMethod
|
// to QMetaObject::invokeMethod
|
||||||
using PositionMap = QHash< unsigned int, Position2D >;
|
using PositionMap = QHash< unsigned int, Position2D >;
|
||||||
Q_DECLARE_METATYPE(PositionMap);
|
Q_DECLARE_METATYPE(PositionMap)
|
||||||
|
|
||||||
|
|
||||||
/// A struct holding information about a stale entry in the
|
/// A struct holding information about a stale entry in the
|
||||||
|
|||||||
@ -404,4 +404,4 @@ QString markdownToHTML(const QString &markdownInput) {
|
|||||||
|
|
||||||
return htmlString;
|
return htmlString;
|
||||||
}
|
}
|
||||||
}; // namespace Markdown
|
} // namespace Markdown
|
||||||
|
|||||||
@ -15,6 +15,6 @@ namespace Markdown {
|
|||||||
/// @param markdownInput A reference to the input string
|
/// @param markdownInput A reference to the input string
|
||||||
/// @returns The processed HTML string
|
/// @returns The processed HTML string
|
||||||
QString markdownToHTML(const QString &markdownInput);
|
QString markdownToHTML(const QString &markdownInput);
|
||||||
}; // namespace Markdown
|
} // namespace Markdown
|
||||||
|
|
||||||
#endif // MUMBLE_MUMBLE_MARKDOWN_H_
|
#endif // MUMBLE_MUMBLE_MARKDOWN_H_
|
||||||
|
|||||||
@ -149,7 +149,7 @@ void MainWindow::msgServerSync(const MumbleProto::ServerSync &msg) {
|
|||||||
}
|
}
|
||||||
iTargetCounter = 100;
|
iTargetCounter = 100;
|
||||||
|
|
||||||
AudioInput::setMaxBandwidth(msg.max_bandwidth());
|
AudioInput::setMaxBandwidth(static_cast< int >(msg.max_bandwidth()));
|
||||||
|
|
||||||
findDesiredChannel();
|
findDesiredChannel();
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ void MainWindow::msgServerConfig(const MumbleProto::ServerConfig &msg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (msg.has_max_bandwidth())
|
if (msg.has_max_bandwidth())
|
||||||
AudioInput::setMaxBandwidth(msg.max_bandwidth());
|
AudioInput::setMaxBandwidth(static_cast< int >(msg.max_bandwidth()));
|
||||||
if (msg.has_allow_html())
|
if (msg.has_allow_html())
|
||||||
Global::get().bAllowHTML = msg.allow_html();
|
Global::get().bAllowHTML = msg.allow_html();
|
||||||
if (msg.has_message_length())
|
if (msg.has_message_length())
|
||||||
@ -264,7 +264,7 @@ void MainWindow::msgPermissionDenied(const MumbleProto::PermissionDenied &msg) {
|
|||||||
Global::get().s.bTTS = true;
|
Global::get().s.bTTS = true;
|
||||||
quint32 oflags = Global::get().s.qmMessages.value(Log::PermissionDenied);
|
quint32 oflags = Global::get().s.qmMessages.value(Log::PermissionDenied);
|
||||||
Global::get().s.qmMessages[Log::PermissionDenied] =
|
Global::get().s.qmMessages[Log::PermissionDenied] =
|
||||||
(oflags | Settings::LogTTS) & (~Settings::LogSoundfile);
|
(oflags | Settings::LogTTS) & static_cast< unsigned int >(~Settings::LogSoundfile);
|
||||||
Global::get().l->log(Log::PermissionDenied, QString::fromUtf8(Global::get().ccHappyEaster + 39)
|
Global::get().l->log(Log::PermissionDenied, QString::fromUtf8(Global::get().ccHappyEaster + 39)
|
||||||
.arg(Global::get().s.qsUsername.toHtmlEscaped()));
|
.arg(Global::get().s.qsUsername.toHtmlEscaped()));
|
||||||
Global::get().s.qmMessages[Log::PermissionDenied] = oflags;
|
Global::get().s.qmMessages[Log::PermissionDenied] = oflags;
|
||||||
@ -376,7 +376,7 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (msg.has_user_id()) {
|
if (msg.has_user_id()) {
|
||||||
pmModel->setUserId(pDst, msg.user_id());
|
pmModel->setUserId(pDst, static_cast< int >(msg.user_id()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channel) {
|
if (channel) {
|
||||||
@ -501,14 +501,14 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < msg.listening_volume_adjustment_size(); i++) {
|
for (int i = 0; i < msg.listening_volume_adjustment_size(); i++) {
|
||||||
int channelID = msg.listening_volume_adjustment(i).listening_channel();
|
unsigned int channelID = msg.listening_volume_adjustment(i).listening_channel();
|
||||||
float adjustment = msg.listening_volume_adjustment(i).volume_adjustment();
|
float adjustment = msg.listening_volume_adjustment(i).volume_adjustment();
|
||||||
|
|
||||||
const Channel *channel = Channel::get(channelID);
|
const Channel *listenedChannel = Channel::get(channelID);
|
||||||
if (channel && pSelf && pSelf->uiSession == pDst->uiSession) {
|
if (listenedChannel && pSelf && pSelf->uiSession == pDst->uiSession) {
|
||||||
Global::get().channelListenerManager->setListenerVolumeAdjustment(pDst->uiSession, channel->iId,
|
Global::get().channelListenerManager->setListenerVolumeAdjustment(pDst->uiSession, listenedChannel->iId,
|
||||||
VolumeAdjustment::fromFactor(adjustment));
|
VolumeAdjustment::fromFactor(adjustment));
|
||||||
} else if (!channel) {
|
} else if (!listenedChannel) {
|
||||||
qWarning("msgUserState(): Invalid channel ID encountered in volume adjustment");
|
qWarning("msgUserState(): Invalid channel ID encountered in volume adjustment");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -982,7 +982,7 @@ void MainWindow::msgChannelRemove(const MumbleProto::ChannelRemove &msg) {
|
|||||||
|
|
||||||
if (Global::get().mw->m_searchDialog) {
|
if (Global::get().mw->m_searchDialog) {
|
||||||
QMetaObject::invokeMethod(Global::get().mw->m_searchDialog, "on_channelRemoved", Qt::QueuedConnection,
|
QMetaObject::invokeMethod(Global::get().mw->m_searchDialog, "on_channelRemoved", Qt::QueuedConnection,
|
||||||
Q_ARG(int, c->iId));
|
Q_ARG(unsigned int, c->iId));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pmModel->removeChannel(c, true)) {
|
if (!pmModel->removeChannel(c, true)) {
|
||||||
@ -1200,7 +1200,7 @@ void MainWindow::msgPermissionQuery(const MumbleProto::PermissionQuery &msg) {
|
|||||||
c->uiPermissions = 0;
|
c->uiPermissions = 0;
|
||||||
|
|
||||||
// We always need the permissions of the current focus channel
|
// We always need the permissions of the current focus channel
|
||||||
if (current && current->iId != static_cast< int >(msg.channel_id())) {
|
if (current && current->iId != msg.channel_id()) {
|
||||||
Global::get().sh->requestChannelPermissions(current->iId);
|
Global::get().sh->requestChannelPermissions(current->iId);
|
||||||
|
|
||||||
current->uiPermissions = ChanACL::All;
|
current->uiPermissions = ChanACL::All;
|
||||||
@ -1293,14 +1293,14 @@ void MainWindow::msgPluginDataTransmission(const MumbleProto::PluginDataTransmis
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ClientUser *sender = ClientUser::get(msg.sendersession());
|
const ClientUser *sender = ClientUser::get(msg.sendersession());
|
||||||
const std::string &data = msg.data();
|
const std::string &msgData = msg.data();
|
||||||
|
|
||||||
if (sender) {
|
if (sender) {
|
||||||
static_assert(sizeof(unsigned char) == sizeof(uint8_t), "Unsigned char does not have expected 8bit size");
|
static_assert(sizeof(unsigned char) == sizeof(uint8_t), "Unsigned char does not have expected 8bit size");
|
||||||
// As long as above assertion is true, we are only casting away the sign, which is fine
|
// As long as above assertion is true, we are only casting away the sign, which is fine
|
||||||
Global::get().pluginManager->on_receiveData(sender, reinterpret_cast< const uint8_t * >(data.c_str()),
|
Global::get().pluginManager->on_receiveData(sender, reinterpret_cast< const uint8_t * >(msgData.c_str()),
|
||||||
data.size(), msg.dataid().c_str());
|
msgData.size(), msg.dataid().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -220,30 +220,30 @@ void OSSInput::run() {
|
|||||||
qWarning("OSSInput: Failed to set mono mode");
|
qWarning("OSSInput: Failed to set mono mode");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
iMicChannels = ival;
|
iMicChannels = static_cast< unsigned int >(ival);
|
||||||
|
|
||||||
ival = SAMPLE_RATE;
|
ival = SAMPLE_RATE;
|
||||||
if (ioctl(fd, SNDCTL_DSP_SPEED, &ival) == -1) {
|
if (ioctl(fd, SNDCTL_DSP_SPEED, &ival) == -1) {
|
||||||
qWarning("OSSInput: Failed to set speed");
|
qWarning("OSSInput: Failed to set speed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
iMicFreq = ival;
|
iMicFreq = static_cast< unsigned int >(ival);
|
||||||
|
|
||||||
qWarning("OSSInput: Starting audio capture from %s", device.constData());
|
qWarning("OSSInput: Starting audio capture from %s", device.constData());
|
||||||
|
|
||||||
eMicFormat = SampleShort;
|
eMicFormat = SampleShort;
|
||||||
initializeMixer();
|
initializeMixer();
|
||||||
|
|
||||||
|
std::vector< short > buffer;
|
||||||
|
buffer.resize(iMicLength);
|
||||||
while (bRunning) {
|
while (bRunning) {
|
||||||
short buffer[iMicLength];
|
std::size_t len = iMicLength * iMicChannels * sizeof(short);
|
||||||
|
ssize_t l = read(fd, buffer.data(), len);
|
||||||
int len = static_cast< int >(iMicLength * iMicChannels * sizeof(short));
|
if (l != static_cast< ssize_t >(len)) {
|
||||||
ssize_t l = read(fd, buffer, len);
|
|
||||||
if (l != len) {
|
|
||||||
qWarning("OSSInput: Read %zd", l);
|
qWarning("OSSInput: Read %zd", l);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
addMic(buffer, iMicLength);
|
addMic(buffer.data(), iMicLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
qWarning("OSSInput: Releasing.");
|
qWarning("OSSInput: Releasing.");
|
||||||
@ -296,19 +296,19 @@ void OSSOutput::run() {
|
|||||||
|
|
||||||
iChannels = 2;
|
iChannels = 2;
|
||||||
|
|
||||||
ival = iChannels;
|
ival = static_cast< int >(iChannels);
|
||||||
if ((ioctl(fd, SNDCTL_DSP_CHANNELS, &ival) == -1) && (ival == static_cast< int >(iChannels))) {
|
if ((ioctl(fd, SNDCTL_DSP_CHANNELS, &ival) == -1) && (ival == static_cast< int >(iChannels))) {
|
||||||
qWarning("OSSOutput: Failed to set channels");
|
qWarning("OSSOutput: Failed to set channels");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
iChannels = ival;
|
iChannels = static_cast< unsigned int >(ival);
|
||||||
|
|
||||||
ival = SAMPLE_RATE;
|
ival = SAMPLE_RATE;
|
||||||
if (ioctl(fd, SNDCTL_DSP_SPEED, &ival) == -1) {
|
if (ioctl(fd, SNDCTL_DSP_SPEED, &ival) == -1) {
|
||||||
qWarning("OSSOutput: Failed to set speed");
|
qWarning("OSSOutput: Failed to set speed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
iMixerFreq = ival;
|
iMixerFreq = static_cast< unsigned int >(ival);
|
||||||
|
|
||||||
const unsigned int chanmasks[32] = { SPEAKER_FRONT_LEFT, SPEAKER_FRONT_RIGHT, SPEAKER_FRONT_CENTER,
|
const unsigned int chanmasks[32] = { SPEAKER_FRONT_LEFT, SPEAKER_FRONT_RIGHT, SPEAKER_FRONT_CENTER,
|
||||||
SPEAKER_LOW_FREQUENCY, SPEAKER_BACK_LEFT, SPEAKER_BACK_RIGHT,
|
SPEAKER_LOW_FREQUENCY, SPEAKER_BACK_LEFT, SPEAKER_BACK_RIGHT,
|
||||||
@ -318,26 +318,27 @@ void OSSOutput::run() {
|
|||||||
|
|
||||||
initializeMixer(chanmasks);
|
initializeMixer(chanmasks);
|
||||||
|
|
||||||
int iOutputBlock = (iFrameSize * iMixerFreq) / SAMPLE_RATE;
|
unsigned int iOutputBlock = (iFrameSize * iMixerFreq) / SAMPLE_RATE;
|
||||||
|
|
||||||
qWarning("OSSOutput: Starting audio playback to %s", device.constData());
|
qWarning("OSSOutput: Starting audio playback to %s", device.constData());
|
||||||
|
|
||||||
ssize_t blocklen = iOutputBlock * iChannels * sizeof(short);
|
std::size_t blocklen = iOutputBlock * iChannels * sizeof(short);
|
||||||
short mbuffer[iOutputBlock * iChannels];
|
static std::vector< short > mbuffer;
|
||||||
|
mbuffer.resize(iOutputBlock * iChannels);
|
||||||
|
|
||||||
while (bRunning) {
|
while (bRunning) {
|
||||||
bool stillRun = mix(mbuffer, iOutputBlock);
|
bool stillRun = mix(mbuffer.data(), iOutputBlock);
|
||||||
if (stillRun) {
|
if (stillRun) {
|
||||||
ssize_t l = write(fd, mbuffer, blocklen);
|
ssize_t l = write(fd, mbuffer.data(), blocklen);
|
||||||
if (l != blocklen) {
|
if (l != static_cast< ssize_t >(blocklen)) {
|
||||||
qWarning("OSSOutput: Write %zd != %zd", l, blocklen);
|
qWarning("OSSOutput: Write %zd != %zd", l, blocklen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (!mix(mbuffer, iOutputBlock) && bRunning)
|
while (!mix(mbuffer.data(), iOutputBlock) && bRunning)
|
||||||
this->msleep(20);
|
this->msleep(20);
|
||||||
ssize_t l = write(fd, mbuffer, blocklen);
|
ssize_t l = write(fd, mbuffer.data(), blocklen);
|
||||||
if (l != blocklen) {
|
if (l != static_cast< ssize_t >(blocklen)) {
|
||||||
qWarning("OSSOutput: Write %zd != %zd", l, blocklen);
|
qWarning("OSSOutput: Write %zd != %zd", l, blocklen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,7 +43,7 @@ private:
|
|||||||
|
|
||||||
class OverlayGroup : public QGraphicsItem {
|
class OverlayGroup : public QGraphicsItem {
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(OverlayGroup);
|
Q_DISABLE_COPY(OverlayGroup)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 5 };
|
enum { Type = UserType + 5 };
|
||||||
|
|||||||
@ -37,7 +37,7 @@ OverlayClient::OverlayClient(QLocalSocket *socket, QObject *p)
|
|||||||
|
|
||||||
omMsg.omh.iLength = -1;
|
omMsg.omh.iLength = -1;
|
||||||
smMem = nullptr;
|
smMem = nullptr;
|
||||||
uiWidth = uiHeight = 0;
|
iWidth = iHeight = 0;
|
||||||
|
|
||||||
uiPid = ~0ULL;
|
uiPid = ~0ULL;
|
||||||
|
|
||||||
@ -98,7 +98,8 @@ bool OverlayClient::eventFilter(QObject *o, QEvent *e) {
|
|||||||
void OverlayClient::updateFPS() {
|
void OverlayClient::updateFPS() {
|
||||||
if (Global::get().s.os.bFps) {
|
if (Global::get().s.os.bFps) {
|
||||||
const BasepointPixmap &pm =
|
const BasepointPixmap &pm =
|
||||||
OverlayTextLine(QString(QLatin1String("%1")).arg(iroundf(framesPerSecond + 0.5f)), Global::get().s.os.qfFps)
|
OverlayTextLine(QString(QLatin1String("%1")).arg(static_cast< int >(framesPerSecond + 0.5f)),
|
||||||
|
Global::get().s.os.qfFps)
|
||||||
.createPixmap(Global::get().s.os.qcFps);
|
.createPixmap(Global::get().s.os.qcFps);
|
||||||
qgpiFPS->setVisible(true);
|
qgpiFPS->setVisible(true);
|
||||||
qgpiFPS->setPixmap(pm);
|
qgpiFPS->setPixmap(pm);
|
||||||
@ -228,8 +229,8 @@ void OverlayClient::showGui() {
|
|||||||
qgpw->setOpacity(0.90f);
|
qgpw->setOpacity(0.90f);
|
||||||
qgpw->setWidget(w);
|
qgpw->setWidget(w);
|
||||||
if (w == Global::get().mw) {
|
if (w == Global::get().mw) {
|
||||||
qgpw->setPos(uiWidth / 10, uiHeight / 10);
|
qgpw->setPos(static_cast< float >(iWidth) / 10, static_cast< float >(iHeight) / 10);
|
||||||
qgpw->resize((uiWidth * 8) / 10, (uiHeight * 8) / 10);
|
qgpw->resize(static_cast< float >(iWidth * 8) / 10, static_cast< float >(iHeight * 8) / 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
qgs.addItem(qgpw);
|
qgs.addItem(qgpw);
|
||||||
@ -245,8 +246,8 @@ void OverlayClient::showGui() {
|
|||||||
qApp->sendEvent(&qgs, &activateEvent);
|
qApp->sendEvent(&qgs, &activateEvent);
|
||||||
|
|
||||||
QPoint p = QCursor::pos();
|
QPoint p = QCursor::pos();
|
||||||
iMouseX = qBound< int >(0, p.x(), uiWidth - 1);
|
iMouseX = qBound< int >(0, p.x(), static_cast< int >(iWidth) - 1);
|
||||||
iMouseY = qBound< int >(0, p.y(), uiHeight - 1);
|
iMouseY = qBound< int >(0, p.y(), static_cast< int >(iHeight) - 1);
|
||||||
|
|
||||||
qgpiCursor->setPos(iMouseX, iMouseY);
|
qgpiCursor->setPos(iMouseX, iMouseY);
|
||||||
|
|
||||||
@ -276,7 +277,7 @@ void OverlayClient::showGui() {
|
|||||||
om.omh.uiType = OVERLAY_MSGTYPE_INTERACTIVE;
|
om.omh.uiType = OVERLAY_MSGTYPE_INTERACTIVE;
|
||||||
om.omh.iLength = sizeof(struct OverlayMsgInteractive);
|
om.omh.iLength = sizeof(struct OverlayMsgInteractive);
|
||||||
om.omin.state = true;
|
om.omin.state = true;
|
||||||
qlsSocket->write(om.headerbuffer, sizeof(OverlayMsgHeader) + om.omh.iLength);
|
qlsSocket->write(om.headerbuffer, static_cast< int >(sizeof(OverlayMsgHeader)) + om.omh.iLength);
|
||||||
|
|
||||||
Global::get().o->updateOverlay();
|
Global::get().o->updateOverlay();
|
||||||
}
|
}
|
||||||
@ -338,7 +339,7 @@ void OverlayClient::hideGui() {
|
|||||||
om.omh.uiType = OVERLAY_MSGTYPE_INTERACTIVE;
|
om.omh.uiType = OVERLAY_MSGTYPE_INTERACTIVE;
|
||||||
om.omh.iLength = sizeof(struct OverlayMsgInteractive);
|
om.omh.iLength = sizeof(struct OverlayMsgInteractive);
|
||||||
om.omin.state = false;
|
om.omin.state = false;
|
||||||
qlsSocket->write(om.headerbuffer, sizeof(OverlayMsgHeader) + om.omh.iLength);
|
qlsSocket->write(om.headerbuffer, static_cast< int >(sizeof(OverlayMsgHeader)) + om.omh.iLength);
|
||||||
|
|
||||||
Global::get().o->updateOverlay();
|
Global::get().o->updateOverlay();
|
||||||
|
|
||||||
@ -358,15 +359,15 @@ void OverlayClient::readyReadMsgInit(unsigned int length) {
|
|||||||
|
|
||||||
OverlayMsgInit *omi = &omMsg.omi;
|
OverlayMsgInit *omi = &omMsg.omi;
|
||||||
|
|
||||||
uiWidth = omi->uiWidth;
|
iWidth = static_cast< int >(omi->uiWidth);
|
||||||
uiHeight = omi->uiHeight;
|
iHeight = static_cast< int >(omi->uiHeight);
|
||||||
qrLast = QRect();
|
qrLast = QRect();
|
||||||
|
|
||||||
delete smMem;
|
delete smMem;
|
||||||
|
|
||||||
smMem = new SharedMemory2(this, uiWidth * uiHeight * 4);
|
smMem = new SharedMemory2(this, static_cast< unsigned int >(iWidth * iHeight * 4));
|
||||||
if (!smMem->data()) {
|
if (!smMem->data()) {
|
||||||
qWarning() << "OverlayClient: Failed to create shared memory" << uiWidth << uiHeight;
|
qWarning() << "OverlayClient: Failed to create shared memory" << iWidth << iHeight;
|
||||||
delete smMem;
|
delete smMem;
|
||||||
smMem = nullptr;
|
smMem = nullptr;
|
||||||
return;
|
return;
|
||||||
@ -379,8 +380,8 @@ void OverlayClient::readyReadMsgInit(unsigned int length) {
|
|||||||
om.omh.uiType = OVERLAY_MSGTYPE_SHMEM;
|
om.omh.uiType = OVERLAY_MSGTYPE_SHMEM;
|
||||||
om.omh.iLength = key.length();
|
om.omh.iLength = key.length();
|
||||||
Q_ASSERT(sizeof(om.oms.a_cName) >= static_cast< size_t >(key.length())); // Name should be auto-generated and short
|
Q_ASSERT(sizeof(om.oms.a_cName) >= static_cast< size_t >(key.length())); // Name should be auto-generated and short
|
||||||
memcpy(om.oms.a_cName, key.constData(), key.length());
|
memcpy(om.oms.a_cName, key.constData(), static_cast< std::size_t >(key.length()));
|
||||||
qlsSocket->write(om.headerbuffer, sizeof(OverlayMsgHeader) + om.omh.iLength);
|
qlsSocket->write(om.headerbuffer, static_cast< int >(sizeof(OverlayMsgHeader)) + om.omh.iLength);
|
||||||
|
|
||||||
setupRender();
|
setupRender();
|
||||||
|
|
||||||
@ -463,7 +464,7 @@ void OverlayClient::readyRead() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OverlayClient::reset() {
|
void OverlayClient::reset() {
|
||||||
if (!uiWidth || !uiHeight || !smMem)
|
if (!iWidth || !iHeight || !smMem)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qgpiLogo.reset();
|
qgpiLogo.reset();
|
||||||
@ -486,14 +487,14 @@ void OverlayClient::setupScene(bool show) {
|
|||||||
|
|
||||||
QImageReader qir(QLatin1String("skin:mumble.svg"));
|
QImageReader qir(QLatin1String("skin:mumble.svg"));
|
||||||
QSize sz = qir.size();
|
QSize sz = qir.size();
|
||||||
sz.scale(uiWidth, uiHeight, Qt::KeepAspectRatio);
|
sz.scale(static_cast< int >(iWidth), static_cast< int >(iHeight), Qt::KeepAspectRatio);
|
||||||
qir.setScaledSize(sz);
|
qir.setScaledSize(sz);
|
||||||
|
|
||||||
qgpiLogo->setPixmap(QPixmap::fromImage(qir.read()));
|
qgpiLogo->setPixmap(QPixmap::fromImage(qir.read()));
|
||||||
|
|
||||||
QRectF qrf = qgpiLogo->boundingRect();
|
QRectF qrf = qgpiLogo->boundingRect();
|
||||||
qgpiLogo->setPos(iroundf((uiWidth - qrf.width()) / 2.0f + 0.5f),
|
qgpiLogo->setPos(static_cast< int >((iWidth - qrf.width()) / 2.0f + 0.5f),
|
||||||
iroundf((uiHeight - qrf.height()) / 2.0f + 0.5f));
|
static_cast< int >((iHeight - qrf.height()) / 2.0f + 0.5f));
|
||||||
}
|
}
|
||||||
|
|
||||||
qgpiCursor->show();
|
qgpiCursor->show();
|
||||||
@ -520,10 +521,10 @@ void OverlayClient::setupScene(bool show) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OverlayClient::setupRender() {
|
void OverlayClient::setupRender() {
|
||||||
qgs.setSceneRect(0, 0, uiWidth, uiHeight);
|
qgs.setSceneRect(0, 0, iWidth, iHeight);
|
||||||
qgv.setScene(nullptr);
|
qgv.setScene(nullptr);
|
||||||
qgv.setGeometry(-2, -2, uiWidth + 2, uiHeight + 2);
|
qgv.setGeometry(-2, -2, static_cast< int >(iWidth) + 2, static_cast< int >(iHeight) + 2);
|
||||||
qgv.viewport()->setGeometry(0, 0, uiWidth, uiHeight);
|
qgv.viewport()->setGeometry(0, 0, static_cast< int >(iWidth), static_cast< int >(iHeight));
|
||||||
qgv.setScene(&qgs);
|
qgv.setScene(&qgs);
|
||||||
|
|
||||||
smMem->erase();
|
smMem->erase();
|
||||||
@ -534,15 +535,15 @@ void OverlayClient::setupRender() {
|
|||||||
om.omh.iLength = sizeof(OverlayMsgBlit);
|
om.omh.iLength = sizeof(OverlayMsgBlit);
|
||||||
om.omb.x = 0;
|
om.omb.x = 0;
|
||||||
om.omb.y = 0;
|
om.omb.y = 0;
|
||||||
om.omb.w = uiWidth;
|
om.omb.w = static_cast< unsigned int >(iWidth);
|
||||||
om.omb.h = uiHeight;
|
om.omb.h = static_cast< unsigned int >(iHeight);
|
||||||
qlsSocket->write(om.headerbuffer, sizeof(OverlayMsgHeader) + sizeof(OverlayMsgBlit));
|
qlsSocket->write(om.headerbuffer, sizeof(OverlayMsgHeader) + sizeof(OverlayMsgBlit));
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OverlayClient::update() {
|
bool OverlayClient::update() {
|
||||||
if (!uiWidth || !uiHeight || !smMem)
|
if (!iWidth || !iHeight || !smMem)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
ougUsers.updateUsers();
|
ougUsers.updateUsers();
|
||||||
@ -569,7 +570,7 @@ void OverlayClient::render() {
|
|||||||
const QList< QRectF > region = qlDirty;
|
const QList< QRectF > region = qlDirty;
|
||||||
qlDirty.clear();
|
qlDirty.clear();
|
||||||
|
|
||||||
if (!uiWidth || !uiHeight || !smMem)
|
if (!iWidth || !iHeight || !smMem)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QRect active;
|
QRect active;
|
||||||
@ -582,7 +583,7 @@ void OverlayClient::render() {
|
|||||||
|
|
||||||
|
|
||||||
QRect dirty = dirtyf.toAlignedRect();
|
QRect dirty = dirtyf.toAlignedRect();
|
||||||
dirty = dirty.intersected(QRect(0, 0, uiWidth, uiHeight));
|
dirty = dirty.intersected(QRect(0, 0, iWidth, iHeight));
|
||||||
|
|
||||||
if ((dirty.width() <= 0) || (dirty.height() <= 0))
|
if ((dirty.width() <= 0) || (dirty.height() <= 0))
|
||||||
return;
|
return;
|
||||||
@ -590,7 +591,7 @@ void OverlayClient::render() {
|
|||||||
QRect target = dirty;
|
QRect target = dirty;
|
||||||
target.moveTo(0, 0);
|
target.moveTo(0, 0);
|
||||||
|
|
||||||
QImage img(reinterpret_cast< unsigned char * >(smMem->data()), uiWidth, uiHeight,
|
QImage img(reinterpret_cast< unsigned char * >(smMem->data()), iWidth, iHeight,
|
||||||
QImage::Format_ARGB32_Premultiplied);
|
QImage::Format_ARGB32_Premultiplied);
|
||||||
QImage qi(target.size(), QImage::Format_ARGB32_Premultiplied);
|
QImage qi(target.size(), QImage::Format_ARGB32_Premultiplied);
|
||||||
qi.fill(0);
|
qi.fill(0);
|
||||||
@ -613,20 +614,20 @@ void OverlayClient::render() {
|
|||||||
om.omh.uiMagic = OVERLAY_MAGIC_NUMBER;
|
om.omh.uiMagic = OVERLAY_MAGIC_NUMBER;
|
||||||
om.omh.uiType = OVERLAY_MSGTYPE_BLIT;
|
om.omh.uiType = OVERLAY_MSGTYPE_BLIT;
|
||||||
om.omh.iLength = sizeof(OverlayMsgBlit);
|
om.omh.iLength = sizeof(OverlayMsgBlit);
|
||||||
om.omb.x = dirty.x();
|
om.omb.x = static_cast< unsigned int >(dirty.x());
|
||||||
om.omb.y = dirty.y();
|
om.omb.y = static_cast< unsigned int >(dirty.y());
|
||||||
om.omb.w = dirty.width();
|
om.omb.w = static_cast< unsigned int >(dirty.width());
|
||||||
om.omb.h = dirty.height();
|
om.omb.h = static_cast< unsigned int >(dirty.height());
|
||||||
qlsSocket->write(om.headerbuffer, sizeof(OverlayMsgHeader) + sizeof(OverlayMsgBlit));
|
qlsSocket->write(om.headerbuffer, sizeof(OverlayMsgHeader) + sizeof(OverlayMsgBlit));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qgpiCursor->isVisible()) {
|
if (qgpiCursor->isVisible()) {
|
||||||
active = QRect(0, 0, uiWidth, uiHeight);
|
active = QRect(0, 0, iWidth, iHeight);
|
||||||
} else {
|
} else {
|
||||||
active = qgs.itemsBoundingRect().toAlignedRect();
|
active = qgs.itemsBoundingRect().toAlignedRect();
|
||||||
if (active.isEmpty())
|
if (active.isEmpty())
|
||||||
active = QRect(0, 0, 0, 0);
|
active = QRect(0, 0, 0, 0);
|
||||||
active = active.intersected(QRect(0, 0, uiWidth, uiHeight));
|
active = active.intersected(QRect(0, 0, iWidth, iHeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (active != qrLast) {
|
if (active != qrLast) {
|
||||||
@ -636,10 +637,10 @@ void OverlayClient::render() {
|
|||||||
om.omh.uiMagic = OVERLAY_MAGIC_NUMBER;
|
om.omh.uiMagic = OVERLAY_MAGIC_NUMBER;
|
||||||
om.omh.uiType = OVERLAY_MSGTYPE_ACTIVE;
|
om.omh.uiType = OVERLAY_MSGTYPE_ACTIVE;
|
||||||
om.omh.iLength = sizeof(OverlayMsgActive);
|
om.omh.iLength = sizeof(OverlayMsgActive);
|
||||||
om.oma.x = qrLast.x();
|
om.oma.x = static_cast< unsigned int >(qrLast.x());
|
||||||
om.oma.y = qrLast.y();
|
om.oma.y = static_cast< unsigned int >(qrLast.y());
|
||||||
om.oma.w = qrLast.width();
|
om.oma.w = static_cast< unsigned int >(qrLast.width());
|
||||||
om.oma.h = qrLast.height();
|
om.oma.h = static_cast< unsigned int >(qrLast.height());
|
||||||
qlsSocket->write(om.headerbuffer, sizeof(OverlayMsgHeader) + sizeof(OverlayMsgActive));
|
qlsSocket->write(om.headerbuffer, sizeof(OverlayMsgHeader) + sizeof(OverlayMsgActive));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -73,7 +73,7 @@ protected slots:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
QGraphicsView qgv;
|
QGraphicsView qgv;
|
||||||
unsigned int uiWidth, uiHeight;
|
int iWidth, iHeight;
|
||||||
int iMouseX, iMouseY;
|
int iMouseX, iMouseY;
|
||||||
|
|
||||||
OverlayClient(QLocalSocket *, QObject *);
|
OverlayClient(QLocalSocket *, QObject *);
|
||||||
|
|||||||
@ -32,10 +32,11 @@ OverlayEditor::OverlayEditor(QWidget *p, QGraphicsItem *qgi, OverlaySettings *os
|
|||||||
if (qgpw) {
|
if (qgpw) {
|
||||||
qgpw->setFlag(QGraphicsItem::ItemIgnoresParentOpacity);
|
qgpw->setFlag(QGraphicsItem::ItemIgnoresParentOpacity);
|
||||||
if (Global::get().ocIntercept) {
|
if (Global::get().ocIntercept) {
|
||||||
qgpw->setPos(iroundf(static_cast< float >(Global::get().ocIntercept->uiWidth) / 16.0f + 0.5f),
|
qgpw->setPos(static_cast< int >(static_cast< float >(Global::get().ocIntercept->iWidth) / 16.0f + 0.5f),
|
||||||
iroundf(static_cast< float >(Global::get().ocIntercept->uiHeight) / 16.0f + 0.5f));
|
static_cast< int >(static_cast< float >(Global::get().ocIntercept->iHeight) / 16.0f + 0.5f));
|
||||||
qgpw->resize(iroundf(static_cast< float >(Global::get().ocIntercept->uiWidth) * 14.0f / 16.0f + 0.5f),
|
qgpw->resize(
|
||||||
iroundf(static_cast< float >(Global::get().ocIntercept->uiHeight) * 14.0f / 16.0f + 0.5f));
|
static_cast< int >(static_cast< float >(Global::get().ocIntercept->iWidth) * 14.0f / 16.0f + 0.5f),
|
||||||
|
static_cast< int >(static_cast< float >(Global::get().ocIntercept->iHeight) * 14.0f / 16.0f + 0.5f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,6 +160,6 @@ void OverlayEditor::on_qcbBox_clicked() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OverlayEditor::on_qsZoom_valueChanged(int zoom) {
|
void OverlayEditor::on_qsZoom_valueChanged(int zoom) {
|
||||||
oes.uiZoom = zoom;
|
oes.uiZoom = static_cast< unsigned int >(zoom);
|
||||||
oes.resync();
|
oes.resync();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,7 @@ OverlayEditorScene::OverlayEditorScene(const OverlaySettings &srcos, QObject *p)
|
|||||||
uiZoom = 2;
|
uiZoom = 2;
|
||||||
|
|
||||||
if (Global::get().ocIntercept)
|
if (Global::get().ocIntercept)
|
||||||
uiSize = Global::get().ocIntercept->uiHeight;
|
uiSize = static_cast< unsigned int >(Global::get().ocIntercept->iHeight);
|
||||||
else
|
else
|
||||||
uiSize = 1080.f;
|
uiSize = 1080.f;
|
||||||
|
|
||||||
@ -75,13 +75,12 @@ OverlayEditorScene::OverlayEditorScene(const OverlaySettings &srcos, QObject *p)
|
|||||||
resync();
|
resync();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SCALESIZE(var) \
|
|
||||||
iroundf(uiSize *uiZoom *os.qrf##var.width() + 0.5f), iroundf(uiSize *uiZoom *os.qrf##var.height() + 0.5f)
|
|
||||||
|
|
||||||
void OverlayEditorScene::updateMuted() {
|
void OverlayEditorScene::updateMuted() {
|
||||||
|
const unsigned int scaleFactor = uiSize * uiZoom;
|
||||||
QImageReader qir(QLatin1String("skin:muted_self.svg"));
|
QImageReader qir(QLatin1String("skin:muted_self.svg"));
|
||||||
QSize sz = qir.size();
|
QSize sz = qir.size();
|
||||||
sz.scale(SCALESIZE(MutedDeafened), Qt::KeepAspectRatio);
|
sz.scale(static_cast< int >(scaleFactor * os.qrfMutedDeafened.width() + 0.5f),
|
||||||
|
static_cast< int >(scaleFactor * os.qrfMutedDeafened.height() + 0.5f), Qt::KeepAspectRatio);
|
||||||
qir.setScaledSize(sz);
|
qir.setScaledSize(sz);
|
||||||
qgpiMuted->setPixmap(QPixmap::fromImage(qir.read()));
|
qgpiMuted->setPixmap(QPixmap::fromImage(qir.read()));
|
||||||
|
|
||||||
@ -116,8 +115,11 @@ void OverlayEditorScene::updateUserName() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QPixmap &pm =
|
const unsigned int scaleFactor = uiSize * uiZoom;
|
||||||
OverlayTextLine(qsName, os.qfUserName).createPixmap(SCALESIZE(UserName), os.qcUserName[tsColor]);
|
const QPixmap &pm = OverlayTextLine(qsName, os.qfUserName)
|
||||||
|
.createPixmap(static_cast< unsigned int >(scaleFactor * os.qrfUserName.width() + 0.5f),
|
||||||
|
static_cast< unsigned int >(scaleFactor * os.qrfUserName.height() + 0.5f),
|
||||||
|
os.qcUserName[tsColor]);
|
||||||
qgpiName->setPixmap(pm);
|
qgpiName->setPixmap(pm);
|
||||||
|
|
||||||
moveUserName();
|
moveUserName();
|
||||||
@ -131,8 +133,11 @@ void OverlayEditorScene::moveUserName() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OverlayEditorScene::updateChannel() {
|
void OverlayEditorScene::updateChannel() {
|
||||||
|
const unsigned int scaleFactor = uiSize * uiZoom;
|
||||||
const QPixmap &pm =
|
const QPixmap &pm =
|
||||||
OverlayTextLine(Overlay::tr("Channel"), os.qfChannel).createPixmap(SCALESIZE(Channel), os.qcChannel);
|
OverlayTextLine(Overlay::tr("Channel"), os.qfChannel)
|
||||||
|
.createPixmap(static_cast< unsigned int >(scaleFactor * os.qrfChannel.width() + 0.5f),
|
||||||
|
static_cast< unsigned int >(scaleFactor * os.qrfChannel.height() + 0.5f), os.qcChannel);
|
||||||
qgpiChannel->setPixmap(pm);
|
qgpiChannel->setPixmap(pm);
|
||||||
|
|
||||||
moveChannel();
|
moveChannel();
|
||||||
@ -146,10 +151,13 @@ void OverlayEditorScene::moveChannel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OverlayEditorScene::updateAvatar() {
|
void OverlayEditorScene::updateAvatar() {
|
||||||
|
const unsigned int scaleFactor = uiSize * uiZoom;
|
||||||
|
|
||||||
QImage img;
|
QImage img;
|
||||||
QImageReader qir(QLatin1String("skin:default_avatar.svg"));
|
QImageReader qir(QLatin1String("skin:default_avatar.svg"));
|
||||||
QSize sz = qir.size();
|
QSize sz = qir.size();
|
||||||
sz.scale(SCALESIZE(Avatar), Qt::KeepAspectRatio);
|
sz.scale(static_cast< int >(scaleFactor * os.qrfAvatar.width() + 0.5f),
|
||||||
|
static_cast< int >(scaleFactor * os.qrfAvatar.height() + 0.5f), Qt::KeepAspectRatio);
|
||||||
qir.setScaledSize(sz);
|
qir.setScaledSize(sz);
|
||||||
img = qir.read();
|
img = qir.read();
|
||||||
qgpiAvatar->setPixmap(QPixmap::fromImage(img));
|
qgpiAvatar->setPixmap(QPixmap::fromImage(img));
|
||||||
@ -230,11 +238,11 @@ void OverlayEditorScene::drawBackground(QPainter *p, const QRectF &rect) {
|
|||||||
QRectF upscaled = OverlayUser::scaledRect(rect, 128.f / static_cast< float >(uiSize * uiZoom));
|
QRectF upscaled = OverlayUser::scaledRect(rect, 128.f / static_cast< float >(uiSize * uiZoom));
|
||||||
|
|
||||||
{
|
{
|
||||||
int min = iroundf(upscaled.left());
|
int min = static_cast< int >(upscaled.left());
|
||||||
int max = iroundf(ceil(upscaled.right()));
|
int max = static_cast< int >(ceil(upscaled.right()));
|
||||||
|
|
||||||
for (int i = min; i <= max; ++i) {
|
for (int i = min; i <= max; ++i) {
|
||||||
qreal v = (i / 128) * static_cast< qreal >(uiSize * uiZoom);
|
qreal v = (static_cast< qreal >(i) / 128) * static_cast< qreal >(uiSize * uiZoom);
|
||||||
|
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
p->setPen(QPen(QColor(128, 128, 128, 255), 0.0f));
|
p->setPen(QPen(QColor(128, 128, 128, 255), 0.0f));
|
||||||
@ -246,11 +254,11 @@ void OverlayEditorScene::drawBackground(QPainter *p, const QRectF &rect) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int min = iroundf(upscaled.top());
|
int min = static_cast< int >(upscaled.top());
|
||||||
int max = iroundf(ceil(upscaled.bottom()));
|
int max = static_cast< int >(ceil(upscaled.bottom()));
|
||||||
|
|
||||||
for (int i = min; i <= max; ++i) {
|
for (int i = min; i <= max; ++i) {
|
||||||
qreal v = (i / 128) * static_cast< qreal >(uiSize * uiZoom);
|
qreal v = (static_cast< qreal >(i) / 128) * static_cast< qreal >(uiSize * uiZoom);
|
||||||
|
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
p->setPen(QPen(QColor(128, 128, 128, 255), 0.0f));
|
p->setPen(QPen(QColor(128, 128, 128, 255), 0.0f));
|
||||||
@ -865,5 +873,3 @@ Qt::WindowFrameSection OverlayEditorScene::rectSection(const QRectF &qrf, const
|
|||||||
|
|
||||||
return Qt::NoSection;
|
return Qt::NoSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef SCALESIZE
|
|
||||||
|
|||||||
@ -62,7 +62,8 @@ void OverlayPositionableItem::onMove() {
|
|||||||
void OverlayPositionableItem::updateRender() {
|
void OverlayPositionableItem::updateRender() {
|
||||||
const QRectF &sr = scene()->sceneRect();
|
const QRectF &sr = scene()->sceneRect();
|
||||||
// Translate the 0..1 float position to the real scene coordinates (relative to absolute position)
|
// Translate the 0..1 float position to the real scene coordinates (relative to absolute position)
|
||||||
QPoint absPos(iroundf(sr.width() * m_position->x() + 0.5f), iroundf(sr.height() * m_position->y() + 0.5f));
|
QPoint absPos(static_cast< int >(sr.width() * m_position->x() + 0.5f),
|
||||||
|
static_cast< int >(sr.height() * m_position->y() + 0.5f));
|
||||||
|
|
||||||
if (m_isPositionEditable) {
|
if (m_isPositionEditable) {
|
||||||
if (!m_qgeiHandle) {
|
if (!m_qgeiHandle) {
|
||||||
@ -73,7 +74,8 @@ void OverlayPositionableItem::updateRender() {
|
|||||||
|
|
||||||
QRectF br = boundingRect();
|
QRectF br = boundingRect();
|
||||||
// Limit the position by the elements width (to make sure it is right-/bottom-bound rather than outside of the scene
|
// Limit the position by the elements width (to make sure it is right-/bottom-bound rather than outside of the scene
|
||||||
QPoint maxPos(iroundf(sr.width() - br.width() + 0.5f), iroundf(sr.height() - br.height() + 0.5f));
|
QPoint maxPos(static_cast< int >(sr.width() - br.width() + 0.5f),
|
||||||
|
static_cast< int >(sr.height() - br.height() + 0.5f));
|
||||||
int basex = qBound< int >(0, absPos.x(), maxPos.x());
|
int basex = qBound< int >(0, absPos.x(), maxPos.x());
|
||||||
int basey = qBound< int >(0, absPos.y(), maxPos.y());
|
int basey = qBound< int >(0, absPos.y(), maxPos.y());
|
||||||
setPos(basex, basey);
|
setPos(basex, basey);
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
class OverlayPositionableItem : public QObject, public QGraphicsPixmapItem {
|
class OverlayPositionableItem : public QObject, public QGraphicsPixmapItem {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_DISABLE_COPY(OverlayPositionableItem);
|
Q_DISABLE_COPY(OverlayPositionableItem)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OverlayPositionableItem(QRectF *posPtr, const bool isPositionable = false);
|
OverlayPositionableItem(QRectF *posPtr, const bool isPositionable = false);
|
||||||
|
|||||||
@ -55,8 +55,8 @@ BasepointPixmap OverlayTextLine::render(int w, int h, const QColor &col, const Q
|
|||||||
imgp.setPen(Qt::NoPen);
|
imgp.setPen(Qt::NoPen);
|
||||||
imgp.drawPath(qpp);
|
imgp.drawPath(qpp);
|
||||||
|
|
||||||
img.iAscent = iroundf(fAscent + 0.5f);
|
img.iAscent = static_cast< int >(fAscent + 0.5f);
|
||||||
img.iDescent = iroundf(fDescent + 0.5f);
|
img.iDescent = static_cast< int >(fDescent + 0.5f);
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,8 +89,9 @@ BasepointPixmap OverlayTextLine::createPixmap(QColor col) {
|
|||||||
|
|
||||||
qr = qpp.controlPointRect();
|
qr = qpp.controlPointRect();
|
||||||
|
|
||||||
return render(iroundf(qr.right() + 2.0f * fEdge + 0.5f), iroundf(qr.bottom() + 2.0f * fEdge + 0.5f), col,
|
return render(static_cast< int >(qr.right() + 2.0f * fEdge + 0.5f),
|
||||||
QPoint(iroundf(fXCorrection + 0.5f), iroundf(fYCorrection + fAscent + 0.5f)));
|
static_cast< int >(qr.bottom() + 2.0f * fEdge + 0.5f), col,
|
||||||
|
QPoint(static_cast< int >(fXCorrection + 0.5f), static_cast< int >(fYCorrection + fAscent + 0.5f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
BasepointPixmap OverlayTextLine::createPixmap(unsigned int maxwidth, unsigned int height, QColor col) {
|
BasepointPixmap OverlayTextLine::createPixmap(unsigned int maxwidth, unsigned int height, QColor col) {
|
||||||
@ -158,7 +159,7 @@ BasepointPixmap OverlayTextLine::createPixmap(unsigned int maxwidth, unsigned in
|
|||||||
|
|
||||||
// eliding by previously calculated width
|
// eliding by previously calculated width
|
||||||
if ((bb.width() * scale) + twice_edge > maxwidth) {
|
if ((bb.width() * scale) + twice_edge > maxwidth) {
|
||||||
int eliding_width = iroundf((static_cast< float >(maxwidth) / scale) - twice_edge + 0.5f);
|
int eliding_width = static_cast< int >((static_cast< float >(maxwidth) / scale) - twice_edge + 0.5f);
|
||||||
QString str = fm.elidedText(qsText, Qt::ElideRight, eliding_width);
|
QString str = fm.elidedText(qsText, Qt::ElideRight, eliding_width);
|
||||||
|
|
||||||
// use ellipsis as shortest possible string
|
// use ellipsis as shortest possible string
|
||||||
@ -190,14 +191,15 @@ BasepointPixmap OverlayTextLine::createPixmap(unsigned int maxwidth, unsigned in
|
|||||||
}
|
}
|
||||||
|
|
||||||
qpp = correction.map(qpp);
|
qpp = correction.map(qpp);
|
||||||
iCurWidth = iroundf(bb.width() * scale + 0.5f);
|
iCurWidth = static_cast< int >(bb.width() * scale + 0.5f);
|
||||||
iCurHeight = height;
|
iCurHeight = static_cast< int >(height);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF qr = qpp.controlPointRect();
|
QRectF qr = qpp.controlPointRect();
|
||||||
|
|
||||||
return render(iroundf(qr.width() + twice_edge + 0.5f), iroundf(fAscent + fDescent + twice_edge + 0.5f), col,
|
return render(static_cast< int >(qr.width() + twice_edge + 0.5f),
|
||||||
QPoint(0, iroundf(fAscent + fEdge + 0.5f)));
|
static_cast< int >(fAscent + fDescent + twice_edge + 0.5f), col,
|
||||||
|
QPoint(0, static_cast< int >(fAscent + fEdge + 0.5f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverlayTextLine::setFont(const QFont &font) {
|
void OverlayTextLine::setFont(const QFont &font) {
|
||||||
|
|||||||
@ -58,16 +58,21 @@ void OverlayUser::setup() {
|
|||||||
qgpiBox->hide();
|
qgpiBox->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef SCALESIZE
|
template< typename T > int roundToInt(T value) {
|
||||||
#define SCALESIZE(var) \
|
return static_cast< int >(value + 0.5f);
|
||||||
iroundf(uiSize * os->fZoom * os->qrf##var.width() + 0.5f), \
|
}
|
||||||
iroundf(uiSize * os->fZoom * os->qrf##var.height() + 0.5f)
|
|
||||||
|
template< typename T > unsigned int roundToUInt(T value) {
|
||||||
|
return static_cast< unsigned int >(value + 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
void OverlayUser::updateLayout() {
|
void OverlayUser::updateLayout() {
|
||||||
QPixmap pm;
|
QPixmap pm;
|
||||||
|
|
||||||
|
const double scaleFactor = uiSize * os->fZoom;
|
||||||
|
|
||||||
if (scene())
|
if (scene())
|
||||||
uiSize = iroundf(scene()->sceneRect().height() + 0.5);
|
uiSize = static_cast< unsigned int >(scene()->sceneRect().height() + 0.5);
|
||||||
|
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
|
||||||
@ -80,7 +85,8 @@ void OverlayUser::updateLayout() {
|
|||||||
{
|
{
|
||||||
QImageReader qir(QLatin1String("skin:muted_self.svg"));
|
QImageReader qir(QLatin1String("skin:muted_self.svg"));
|
||||||
QSize sz = qir.size();
|
QSize sz = qir.size();
|
||||||
sz.scale(SCALESIZE(MutedDeafened), Qt::KeepAspectRatio);
|
sz.scale(roundToInt(os->qrfMutedDeafened.width() * scaleFactor),
|
||||||
|
roundToInt(os->qrfMutedDeafened.height() * scaleFactor), Qt::KeepAspectRatio);
|
||||||
qir.setScaledSize(sz);
|
qir.setScaledSize(sz);
|
||||||
qgpiMuted->setPixmap(QPixmap::fromImage(qir.read()));
|
qgpiMuted->setPixmap(QPixmap::fromImage(qir.read()));
|
||||||
}
|
}
|
||||||
@ -88,7 +94,8 @@ void OverlayUser::updateLayout() {
|
|||||||
{
|
{
|
||||||
QImageReader qir(QLatin1String("skin:deafened_self.svg"));
|
QImageReader qir(QLatin1String("skin:deafened_self.svg"));
|
||||||
QSize sz = qir.size();
|
QSize sz = qir.size();
|
||||||
sz.scale(SCALESIZE(MutedDeafened), Qt::KeepAspectRatio);
|
sz.scale(roundToInt(os->qrfMutedDeafened.width() * scaleFactor),
|
||||||
|
roundToInt(os->qrfMutedDeafened.height() * scaleFactor), Qt::KeepAspectRatio);
|
||||||
qir.setScaledSize(sz);
|
qir.setScaledSize(sz);
|
||||||
qgpiDeafened->setPixmap(QPixmap::fromImage(qir.read()));
|
qgpiDeafened->setPixmap(QPixmap::fromImage(qir.read()));
|
||||||
}
|
}
|
||||||
@ -155,13 +162,16 @@ void OverlayUser::updateLayout() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OverlayUser::updateUser() {
|
void OverlayUser::updateUser() {
|
||||||
|
const double scaleFactor = uiSize * os->fZoom;
|
||||||
|
|
||||||
if (os->bUserName && (qgpiName[0]->pixmap().isNull() || (cuUser && (qsName != cuUser->qsName)))) {
|
if (os->bUserName && (qgpiName[0]->pixmap().isNull() || (cuUser && (qsName != cuUser->qsName)))) {
|
||||||
if (cuUser)
|
if (cuUser)
|
||||||
qsName = cuUser->qsName;
|
qsName = cuUser->qsName;
|
||||||
|
|
||||||
OverlayTextLine tl(qsName, os->qfUserName);
|
OverlayTextLine tl(qsName, os->qfUserName);
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (unsigned int i = 0; i < 4; ++i) {
|
||||||
const QPixmap &pm = tl.createPixmap(SCALESIZE(UserName), os->qcUserName[i]);
|
const QPixmap &pm = tl.createPixmap(roundToUInt(os->qrfUserName.width() * scaleFactor),
|
||||||
|
roundToUInt(os->qrfUserName.height() * scaleFactor), os->qcUserName[i]);
|
||||||
qgpiName[i]->setPixmap(pm);
|
qgpiName[i]->setPixmap(pm);
|
||||||
|
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
@ -176,8 +186,9 @@ void OverlayUser::updateUser() {
|
|||||||
if (cuUser)
|
if (cuUser)
|
||||||
qsChannelName = cuUser->cChannel->qsName;
|
qsChannelName = cuUser->cChannel->qsName;
|
||||||
|
|
||||||
const QPixmap &pm =
|
const QPixmap &pm = OverlayTextLine(qsChannelName, os->qfChannel)
|
||||||
OverlayTextLine(qsChannelName, os->qfChannel).createPixmap(SCALESIZE(Channel), os->qcChannel);
|
.createPixmap(roundToUInt(os->qrfChannel.width() * scaleFactor),
|
||||||
|
roundToUInt(os->qrfChannel.height() * scaleFactor), os->qcChannel);
|
||||||
qgpiChannel->setPixmap(pm);
|
qgpiChannel->setPixmap(pm);
|
||||||
qgpiChannel->setPos(alignedPosition(scaledRect(os->qrfChannel, uiSize * os->fZoom), qgpiChannel->boundingRect(),
|
qgpiChannel->setPos(alignedPosition(scaledRect(os->qrfChannel, uiSize * os->fZoom), qgpiChannel->boundingRect(),
|
||||||
os->qaChannel));
|
os->qaChannel));
|
||||||
@ -194,7 +205,8 @@ void OverlayUser::updateUser() {
|
|||||||
} else if (qbaAvatar.isNull()) {
|
} else if (qbaAvatar.isNull()) {
|
||||||
QImageReader qir(QLatin1String("skin:default_avatar.svg"));
|
QImageReader qir(QLatin1String("skin:default_avatar.svg"));
|
||||||
QSize sz = qir.size();
|
QSize sz = qir.size();
|
||||||
sz.scale(SCALESIZE(Avatar), Qt::KeepAspectRatio);
|
sz.scale(roundToInt(os->qrfAvatar.width() * scaleFactor), roundToInt(os->qrfAvatar.height() * scaleFactor),
|
||||||
|
Qt::KeepAspectRatio);
|
||||||
qir.setScaledSize(sz);
|
qir.setScaledSize(sz);
|
||||||
img = qir.read();
|
img = qir.read();
|
||||||
} else {
|
} else {
|
||||||
@ -203,7 +215,8 @@ void OverlayUser::updateUser() {
|
|||||||
|
|
||||||
QImageReader qir(&qb, cuUser->qbaTextureFormat);
|
QImageReader qir(&qb, cuUser->qbaTextureFormat);
|
||||||
QSize sz = qir.size();
|
QSize sz = qir.size();
|
||||||
sz.scale(SCALESIZE(Avatar), Qt::KeepAspectRatio);
|
sz.scale(roundToInt(os->qrfAvatar.width() * scaleFactor), roundToInt(os->qrfAvatar.height() * scaleFactor),
|
||||||
|
Qt::KeepAspectRatio);
|
||||||
qir.setScaledSize(sz);
|
qir.setScaledSize(sz);
|
||||||
img = qir.read();
|
img = qir.read();
|
||||||
}
|
}
|
||||||
@ -283,7 +296,5 @@ QPointF OverlayUser::alignedPosition(const QRectF &box, const QRectF &item, Qt::
|
|||||||
else if (a & Qt::AlignVCenter)
|
else if (a & Qt::AlignVCenter)
|
||||||
yofs += hdiff * 0.5f;
|
yofs += hdiff * 0.5f;
|
||||||
|
|
||||||
return QPointF(iroundf(xofs + 0.5f), iroundf(yofs + 0.5f));
|
return QPointF(static_cast< int >(xofs + 0.5f), static_cast< int >(yofs + 0.5f));
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef SCALESIZE
|
|
||||||
|
|||||||
@ -183,7 +183,7 @@ void OverlayUserGroup::contextMenuEvent(QGraphicsSceneContextMenuEvent *e) {
|
|||||||
os->osSort = OverlaySettings::LastStateChange;
|
os->osSort = OverlaySettings::LastStateChange;
|
||||||
updateUsers();
|
updateUsers();
|
||||||
} else {
|
} else {
|
||||||
for (int i = 1; i <= 5; ++i) {
|
for (unsigned int i = 1; i <= 5; ++i) {
|
||||||
if (act == qaColumns[i]) {
|
if (act == qaColumns[i]) {
|
||||||
os->uiColumns = i;
|
os->uiColumns = i;
|
||||||
updateLayout();
|
updateLayout();
|
||||||
@ -245,7 +245,7 @@ void OverlayUserGroup::updateLayout() {
|
|||||||
void OverlayUserGroup::updateUsers() {
|
void OverlayUserGroup::updateUsers() {
|
||||||
const QRectF &sr = scene()->sceneRect();
|
const QRectF &sr = scene()->sceneRect();
|
||||||
|
|
||||||
unsigned int uiHeight = iroundf(sr.height() + 0.5f);
|
unsigned int uiHeight = static_cast< unsigned int >(sr.height() + 0.5f);
|
||||||
|
|
||||||
QList< QGraphicsItem * > items;
|
QList< QGraphicsItem * > items;
|
||||||
foreach (QGraphicsItem *qgi, childItems())
|
foreach (QGraphicsItem *qgi, childItems())
|
||||||
@ -338,15 +338,15 @@ void OverlayUserGroup::updateUsers() {
|
|||||||
|
|
||||||
QRectF childrenBounds = os->qrfAvatar | os->qrfChannel | os->qrfMutedDeafened | os->qrfUserName;
|
QRectF childrenBounds = os->qrfAvatar | os->qrfChannel | os->qrfMutedDeafened | os->qrfUserName;
|
||||||
|
|
||||||
int pad = os->bBox ? iroundf(uiHeight * os->fZoom * (os->fBoxPad + os->fBoxPenWidth) + 0.5f) : 0;
|
int pad = os->bBox ? static_cast< int >(uiHeight * os->fZoom * (os->fBoxPad + os->fBoxPenWidth) + 0.5f) : 0;
|
||||||
int width = iroundf(childrenBounds.width() * uiHeight * os->fZoom + 0.5f) + 2 * pad;
|
int width = static_cast< int >(childrenBounds.width() * uiHeight * os->fZoom + 0.5f) + 2 * pad;
|
||||||
int height = iroundf(childrenBounds.height() * uiHeight * os->fZoom + 0.5f) + 2 * pad;
|
int height = static_cast< int >(childrenBounds.height() * uiHeight * os->fZoom + 0.5f) + 2 * pad;
|
||||||
|
|
||||||
int xOffset = -iroundf(childrenBounds.left() * uiHeight * os->fZoom + 0.5f) + pad;
|
int xOffset = -static_cast< int >(childrenBounds.left() * uiHeight * os->fZoom + 0.5f) + pad;
|
||||||
int yOffset = -iroundf(childrenBounds.top() * uiHeight * os->fZoom + 0.5f) + pad;
|
int yOffset = -static_cast< int >(childrenBounds.top() * uiHeight * os->fZoom + 0.5f) + pad;
|
||||||
|
|
||||||
unsigned int yPos = 0;
|
int yPos = 0;
|
||||||
unsigned int xPos = 0;
|
int xPos = 0;
|
||||||
|
|
||||||
foreach (OverlayUser *ou, users) {
|
foreach (OverlayUser *ou, users) {
|
||||||
if (!ou->parentItem())
|
if (!ou->parentItem())
|
||||||
@ -356,7 +356,7 @@ void OverlayUserGroup::updateUsers() {
|
|||||||
ou->updateUser();
|
ou->updateUser();
|
||||||
ou->show();
|
ou->show();
|
||||||
|
|
||||||
if (xPos >= (os->uiColumns - 1)) {
|
if (static_cast< unsigned int >(xPos) >= (os->uiColumns - 1)) {
|
||||||
xPos = 0;
|
xPos = 0;
|
||||||
++yPos;
|
++yPos;
|
||||||
} else {
|
} else {
|
||||||
@ -366,8 +366,10 @@ void OverlayUserGroup::updateUsers() {
|
|||||||
|
|
||||||
QRectF br = boundingRect< OverlayUser >();
|
QRectF br = boundingRect< OverlayUser >();
|
||||||
|
|
||||||
int basex = qBound< int >(0, iroundf(sr.width() * os->fX + 0.5f), iroundf(sr.width() - br.width() + 0.5f));
|
int basex = qBound< int >(0, static_cast< int >(sr.width() * os->fX + 0.5f),
|
||||||
int basey = qBound< int >(0, iroundf(sr.height() * os->fY + 0.5f), iroundf(sr.height() - br.height() + 0.5f));
|
static_cast< int >(sr.width() - br.width() + 0.5f));
|
||||||
|
int basey = qBound< int >(0, static_cast< int >(sr.height() * os->fY + 0.5f),
|
||||||
|
static_cast< int >(sr.height() - br.height() + 0.5f));
|
||||||
|
|
||||||
setPos(basex, basey);
|
setPos(basex, basey);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ class OverlayUser;
|
|||||||
class OverlayUserGroup : public QObject, public OverlayGroup {
|
class OverlayUserGroup : public QObject, public OverlayGroup {
|
||||||
private:
|
private:
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_DISABLE_COPY(OverlayUserGroup);
|
Q_DISABLE_COPY(OverlayUserGroup)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 3 };
|
enum { Type = UserType + 3 };
|
||||||
|
|||||||
@ -271,7 +271,7 @@ static bool isInstallerNewer(QString path, NSUInteger curVer) {
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
QXmlStreamReader reader(QByteArray::fromRawData(data, size));
|
QXmlStreamReader reader(QByteArray::fromRawData(data, static_cast<int>(size)));
|
||||||
while (! reader.atEnd()) {
|
while (! reader.atEnd()) {
|
||||||
QXmlStreamReader::TokenType tok = reader.readNext();
|
QXmlStreamReader::TokenType tok = reader.readNext();
|
||||||
if (tok == QXmlStreamReader::StartElement) {
|
if (tok == QXmlStreamReader::StartElement) {
|
||||||
|
|||||||
@ -217,9 +217,8 @@ void OverlayPrivateWin::onHelperProcessStarted() {
|
|||||||
qFatal("OverlayPrivateWin: unknown QProcess found in onHelperProcessStarted().");
|
qFatal("OverlayPrivateWin: unknown QProcess found in onHelperProcessStarted().");
|
||||||
}
|
}
|
||||||
|
|
||||||
PROCESS_INFORMATION *pi = helper->pid();
|
std::uint64_t processID = helper->processId();
|
||||||
qWarning("OverlayPrivateWin: overlay helper process '%s' started with PID %llu.", qPrintable(path),
|
qWarning("OverlayPrivateWin: overlay helper process '%s' started with PID %llu.", qPrintable(path), processID);
|
||||||
static_cast< unsigned long long >(pi->dwProcessId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverlayPrivateWin::onHelperProcessError(QProcess::ProcessError processError) {
|
void OverlayPrivateWin::onHelperProcessError(QProcess::ProcessError processError) {
|
||||||
|
|||||||
@ -332,29 +332,30 @@ bool PortAudioSystem::stopStream(PaStream *stream) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PortAudioSystem::streamCallback(const void *input, void *output, unsigned long frames,
|
int PortAudioSystem::streamCallback(const void *inBuffer, void *outBuffer, unsigned long frames,
|
||||||
const PaStreamCallbackTimeInfo *, PaStreamCallbackFlags, void *isInput) {
|
const PaStreamCallbackTimeInfo *, PaStreamCallbackFlags, void *isInput) {
|
||||||
if (isInput) {
|
if (isInput) {
|
||||||
auto const pai = dynamic_cast< PortAudioInput * >(Global::get().ai.get());
|
auto const input = dynamic_cast< PortAudioInput * >(Global::get().ai.get());
|
||||||
if (!pai) {
|
if (!input) {
|
||||||
return paAbort;
|
return paAbort;
|
||||||
}
|
}
|
||||||
|
|
||||||
pai->process(frames, input);
|
input->process(static_cast< unsigned int >(frames), inBuffer);
|
||||||
} else {
|
} else {
|
||||||
auto const pao = dynamic_cast< PortAudioOutput * >(Global::get().ao.get());
|
auto const output = dynamic_cast< PortAudioOutput * >(Global::get().ao.get());
|
||||||
if (!pao) {
|
if (!output) {
|
||||||
return paAbort;
|
return paAbort;
|
||||||
}
|
}
|
||||||
|
|
||||||
pao->process(frames, output);
|
output->process(static_cast< unsigned int >(frames), outBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return paContinue;
|
return paContinue;
|
||||||
}
|
}
|
||||||
|
|
||||||
PortAudioInput::PortAudioInput() : stream(nullptr) {
|
PortAudioInput::PortAudioInput() : stream(nullptr) {
|
||||||
iMicChannels = pas->openStream(&stream, Global::get().s.iPortAudioInput, iFrameSize, true);
|
iMicChannels =
|
||||||
|
static_cast< unsigned int >(pas->openStream(&stream, Global::get().s.iPortAudioInput, iFrameSize, true));
|
||||||
if (!iMicChannels) {
|
if (!iMicChannels) {
|
||||||
qWarning("PortAudioInput: failed to open stream");
|
qWarning("PortAudioInput: failed to open stream");
|
||||||
return;
|
return;
|
||||||
@ -405,7 +406,8 @@ void PortAudioInput::run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PortAudioOutput::PortAudioOutput() : stream(nullptr) {
|
PortAudioOutput::PortAudioOutput() : stream(nullptr) {
|
||||||
iChannels = pas->openStream(&stream, Global::get().s.iPortAudioOutput, iFrameSize, false);
|
iChannels =
|
||||||
|
static_cast< unsigned int >(pas->openStream(&stream, Global::get().s.iPortAudioOutput, iFrameSize, false));
|
||||||
if (!iChannels) {
|
if (!iChannels) {
|
||||||
qWarning("PortAudioOutput: failed to open stream");
|
qWarning("PortAudioOutput: failed to open stream");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -72,7 +72,7 @@ const QList< audioDevice > PipeWireInputRegistrar::getDeviceChoices() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PipeWireInputRegistrar::setDeviceChoice(const QVariant &choice, Settings &settings) {
|
void PipeWireInputRegistrar::setDeviceChoice(const QVariant &choice, Settings &settings) {
|
||||||
settings.pipeWireInput = choice.toUInt();
|
settings.pipeWireInput = static_cast< std::uint8_t >(choice.toUInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PipeWireInputRegistrar::canEcho(EchoCancelOptionID, const QString &) const {
|
bool PipeWireInputRegistrar::canEcho(EchoCancelOptionID, const QString &) const {
|
||||||
@ -101,7 +101,7 @@ const QList< audioDevice > PipeWireOutputRegistrar::getDeviceChoices() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PipeWireOutputRegistrar::setDeviceChoice(const QVariant &choice, Settings &settings) {
|
void PipeWireOutputRegistrar::setDeviceChoice(const QVariant &choice, Settings &settings) {
|
||||||
settings.pipeWireOutput = choice.toUInt();
|
settings.pipeWireOutput = static_cast< std::uint8_t >(choice.toUInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PipeWireOutputRegistrar::usesOutputDelay() const {
|
bool PipeWireOutputRegistrar::usesOutputDelay() const {
|
||||||
@ -321,7 +321,7 @@ PipeWireInput::PipeWireInput() {
|
|||||||
SPEAKER_FRONT_RIGHT,
|
SPEAKER_FRONT_RIGHT,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!m_engine->connect(PW_DIRECTION_INPUT, CHANNELS, iMicChannels)) {
|
if (!m_engine->connect(PW_DIRECTION_INPUT, CHANNELS, static_cast< std::uint8_t >(iMicChannels))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,7 +349,7 @@ void PipeWireInput::processCallback(void *param) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pwi->addMic(data.data, data.chunk->size / sizeof(float));
|
pwi->addMic(data.data, static_cast< unsigned int >(data.chunk->size / sizeof(float)));
|
||||||
|
|
||||||
pwi->m_engine->queueBuffer(buffer);
|
pwi->m_engine->queueBuffer(buffer);
|
||||||
}
|
}
|
||||||
@ -378,7 +378,7 @@ PipeWireOutput::PipeWireOutput() {
|
|||||||
constexpr uint32_t CHANNELS[]{ SPEAKER_FRONT_LEFT, SPEAKER_FRONT_RIGHT, SPEAKER_LOW_FREQUENCY, SPEAKER_FRONT_CENTER,
|
constexpr uint32_t CHANNELS[]{ SPEAKER_FRONT_LEFT, SPEAKER_FRONT_RIGHT, SPEAKER_LOW_FREQUENCY, SPEAKER_FRONT_CENTER,
|
||||||
SPEAKER_BACK_LEFT, SPEAKER_BACK_RIGHT, SPEAKER_SIDE_LEFT, SPEAKER_SIDE_RIGHT };
|
SPEAKER_BACK_LEFT, SPEAKER_BACK_RIGHT, SPEAKER_SIDE_LEFT, SPEAKER_SIDE_RIGHT };
|
||||||
|
|
||||||
if (!m_engine->connect(PW_DIRECTION_OUTPUT, CHANNELS, iChannels)) {
|
if (!m_engine->connect(PW_DIRECTION_OUTPUT, CHANNELS, static_cast< std::uint8_t >(iChannels))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,11 +412,11 @@ void PipeWireOutput::processCallback(void *param) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
chunk->offset = 0;
|
chunk->offset = 0;
|
||||||
chunk->stride = sizeof(float) * pwo->iChannels;
|
chunk->stride = static_cast< int >(sizeof(float) * pwo->iChannels);
|
||||||
|
|
||||||
const uint32_t frames = std::min(data.maxsize / chunk->stride, pwo->iFrameSize);
|
const uint32_t frames = std::min(data.maxsize / static_cast< std::uint32_t >(chunk->stride), pwo->iFrameSize);
|
||||||
|
|
||||||
chunk->size = frames * chunk->stride;
|
chunk->size = frames * static_cast< unsigned int >(chunk->stride);
|
||||||
if (!pwo->mix(data.data, frames)) {
|
if (!pwo->mix(data.data, frames)) {
|
||||||
// When the mixer has no data available to write, we still need to push silence.
|
// When the mixer has no data available to write, we still need to push silence.
|
||||||
// This is to avoid an infinite loop when destroying the stream.
|
// This is to avoid an infinite loop when destroying the stream.
|
||||||
|
|||||||
@ -57,7 +57,7 @@ Plugin::~Plugin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString Plugin::extractWrappedString(MumbleStringWrapper wrapper) const {
|
QString Plugin::extractWrappedString(MumbleStringWrapper wrapper) const {
|
||||||
QString wrappedString = QString::fromUtf8(wrapper.data, wrapper.size);
|
QString wrappedString = QString::fromUtf8(wrapper.data, static_cast< int >(wrapper.size));
|
||||||
|
|
||||||
if (wrapper.needsReleasing) {
|
if (wrapper.needsReleasing) {
|
||||||
releaseResource(static_cast< const void * >(wrapper.data));
|
releaseResource(static_cast< const void * >(wrapper.data));
|
||||||
@ -694,7 +694,7 @@ void Plugin::onKeyEvent(mumble_keycode_t keyCode, bool wasPress) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_pluginFnc.onKeyEvent) {
|
if (m_pluginFnc.onKeyEvent) {
|
||||||
m_pluginFnc.onKeyEvent(keyCode, wasPress);
|
m_pluginFnc.onKeyEvent(static_cast< std::uint32_t >(keyCode), wasPress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -33,8 +33,8 @@ public:
|
|||||||
/// directory on the FileSystem.
|
/// directory on the FileSystem.
|
||||||
class PluginInstaller : public QDialog, public Ui::PluginInstaller {
|
class PluginInstaller : public QDialog, public Ui::PluginInstaller {
|
||||||
private:
|
private:
|
||||||
Q_OBJECT;
|
Q_OBJECT
|
||||||
Q_DISABLE_COPY(PluginInstaller);
|
Q_DISABLE_COPY(PluginInstaller)
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// The file the installer has been invoked on
|
/// The file the installer has been invoked on
|
||||||
|
|||||||
@ -157,7 +157,8 @@ bool PluginManager::eventFilter(QObject *target, QEvent *event) {
|
|||||||
// them. However we want to process each event only once.
|
// them. However we want to process each event only once.
|
||||||
if (!kEvent->isAutoRepeat() && !processedEvents.contains(kEvent)) {
|
if (!kEvent->isAutoRepeat() && !processedEvents.contains(kEvent)) {
|
||||||
// Fire event
|
// Fire event
|
||||||
emit keyEvent(kEvent->key(), kEvent->modifiers(), kEvent->type() == QEvent::KeyPress);
|
emit keyEvent(static_cast< unsigned int >(kEvent->key()), kEvent->modifiers(),
|
||||||
|
kEvent->type() == QEvent::KeyPress);
|
||||||
|
|
||||||
processedEvents << kEvent;
|
processedEvents << kEvent;
|
||||||
|
|
||||||
@ -655,8 +656,9 @@ void PluginManager::on_channelEntered(const Channel *newChannel, const Channel *
|
|||||||
|
|
||||||
foreachPlugin([user, newChannel, prevChannel, connectionID](Plugin &plugin) {
|
foreachPlugin([user, newChannel, prevChannel, connectionID](Plugin &plugin) {
|
||||||
if (plugin.isLoaded()) {
|
if (plugin.isLoaded()) {
|
||||||
plugin.onChannelEntered(connectionID, user->uiSession, prevChannel ? prevChannel->iId : -1,
|
plugin.onChannelEntered(connectionID, user->uiSession,
|
||||||
newChannel->iId);
|
prevChannel ? static_cast< int >(prevChannel->iId) : -1,
|
||||||
|
static_cast< int >(newChannel->iId));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -670,7 +672,7 @@ void PluginManager::on_channelExited(const Channel *channel, const User *user) c
|
|||||||
|
|
||||||
foreachPlugin([user, channel, connectionID](Plugin &plugin) {
|
foreachPlugin([user, channel, connectionID](Plugin &plugin) {
|
||||||
if (plugin.isLoaded()) {
|
if (plugin.isLoaded()) {
|
||||||
plugin.onChannelExited(connectionID, user->uiSession, channel->iId);
|
plugin.onChannelExited(connectionID, user->uiSession, static_cast< int >(channel->iId));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -750,7 +752,8 @@ void PluginManager::on_audioInput(short *inputPCM, unsigned int sampleCount, uns
|
|||||||
|
|
||||||
foreachPlugin([inputPCM, sampleCount, channelCount, sampleRate, isSpeech](Plugin &plugin) {
|
foreachPlugin([inputPCM, sampleCount, channelCount, sampleRate, isSpeech](Plugin &plugin) {
|
||||||
if (plugin.isLoaded()) {
|
if (plugin.isLoaded()) {
|
||||||
plugin.onAudioInput(inputPCM, sampleCount, channelCount, sampleRate, isSpeech);
|
plugin.onAudioInput(inputPCM, sampleCount, static_cast< std::uint16_t >(channelCount), sampleRate,
|
||||||
|
isSpeech);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -767,8 +770,8 @@ void PluginManager::on_audioSourceFetched(float *outputPCM, unsigned int sampleC
|
|||||||
|
|
||||||
foreachPlugin([outputPCM, sampleCount, channelCount, sampleRate, isSpeech, user](Plugin &plugin) {
|
foreachPlugin([outputPCM, sampleCount, channelCount, sampleRate, isSpeech, user](Plugin &plugin) {
|
||||||
if (plugin.isLoaded()) {
|
if (plugin.isLoaded()) {
|
||||||
plugin.onAudioSourceFetched(outputPCM, sampleCount, channelCount, sampleRate, isSpeech,
|
plugin.onAudioSourceFetched(outputPCM, sampleCount, static_cast< std::uint16_t >(channelCount), sampleRate,
|
||||||
user ? user->uiSession : -1);
|
isSpeech, user ? user->uiSession : static_cast< unsigned int >(-1));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -781,7 +784,8 @@ void PluginManager::on_audioOutputAboutToPlay(float *outputPCM, unsigned int sam
|
|||||||
#endif
|
#endif
|
||||||
foreachPlugin([outputPCM, sampleCount, channelCount, sampleRate, modifiedAudio](Plugin &plugin) {
|
foreachPlugin([outputPCM, sampleCount, channelCount, sampleRate, modifiedAudio](Plugin &plugin) {
|
||||||
if (plugin.isLoaded()) {
|
if (plugin.isLoaded()) {
|
||||||
if (plugin.onAudioOutputAboutToPlay(outputPCM, sampleCount, channelCount, sampleRate)) {
|
if (plugin.onAudioOutputAboutToPlay(outputPCM, sampleCount, static_cast< std::uint16_t >(channelCount),
|
||||||
|
sampleRate)) {
|
||||||
*modifiedAudio = true;
|
*modifiedAudio = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -929,7 +933,8 @@ void PluginManager::on_syncPositionalData() {
|
|||||||
|
|
||||||
if (m_sentData.context != m_positionalData.m_context) {
|
if (m_sentData.context != m_positionalData.m_context) {
|
||||||
m_sentData.context = m_positionalData.m_context;
|
m_sentData.context = m_positionalData.m_context;
|
||||||
mpus.set_plugin_context(m_sentData.context.toUtf8().constData(), m_sentData.context.size());
|
mpus.set_plugin_context(m_sentData.context.toUtf8().constData(),
|
||||||
|
static_cast< std::size_t >(m_sentData.context.size()));
|
||||||
}
|
}
|
||||||
if (m_sentData.identity != m_positionalData.m_identity) {
|
if (m_sentData.identity != m_positionalData.m_identity) {
|
||||||
m_sentData.identity = m_positionalData.m_identity;
|
m_sentData.identity = m_positionalData.m_identity;
|
||||||
|
|||||||
@ -21,7 +21,7 @@ void PluginManifest::parse(std::istream &input) {
|
|||||||
Poco::AutoPtr< Poco::XML::Document > doc;
|
Poco::AutoPtr< Poco::XML::Document > doc;
|
||||||
try {
|
try {
|
||||||
doc = parser.parse(&source);
|
doc = parser.parse(&source);
|
||||||
} catch (const Poco::XML::SAXParseException &e) {
|
} catch (const Poco::XML::SAXParseException &) {
|
||||||
throw PluginManifestException("Plugin manifest uses malformed XML");
|
throw PluginManifestException("Plugin manifest uses malformed XML");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +70,8 @@ void PluginManifest::parse_v1_0_0(Poco::AutoPtr< Poco::XML::Document > document)
|
|||||||
Poco::AutoPtr< Poco::XML::NodeList > pluginNodes = assets->getElementsByTagName("plugin");
|
Poco::AutoPtr< Poco::XML::NodeList > pluginNodes = assets->getElementsByTagName("plugin");
|
||||||
|
|
||||||
for (std::size_t i = 0; i < pluginNodes->length(); ++i) {
|
for (std::size_t i = 0; i < pluginNodes->length(); ++i) {
|
||||||
Poco::XML::Element *current = dynamic_cast< Poco::XML::Element * >(pluginNodes->item(i));
|
Poco::XML::Element *current =
|
||||||
|
dynamic_cast< Poco::XML::Element * >(pluginNodes->item(static_cast< unsigned long >(i)));
|
||||||
if (!current) {
|
if (!current) {
|
||||||
throw PluginManifestException("Plugin manifest uses \"plugin\" node of unexpected type");
|
throw PluginManifestException("Plugin manifest uses \"plugin\" node of unexpected type");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,8 +16,8 @@
|
|||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace XML {
|
namespace XML {
|
||||||
class Document;
|
class Document;
|
||||||
}; // namespace XML
|
} // namespace XML
|
||||||
}; // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
struct PluginManifestException : std::runtime_error {
|
struct PluginManifestException : std::runtime_error {
|
||||||
PluginManifestException(const std::string &msg = "") : std::runtime_error(msg) {}
|
PluginManifestException(const std::string &msg = "") : std::runtime_error(msg) {}
|
||||||
@ -39,7 +39,7 @@ template<> struct hash< PluginRuntimeSpec > {
|
|||||||
return std::hash< std::string >()(spec.os) ^ (std::hash< std::string >()(spec.architecture) << 1);
|
return std::hash< std::string >()(spec.os) ^ (std::hash< std::string >()(spec.architecture) << 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}; // namespace std
|
} // namespace std
|
||||||
|
|
||||||
class PluginManifest {
|
class PluginManifest {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -40,8 +40,8 @@ struct UpdateEntry {
|
|||||||
/// a Dialog that can be used to prompt the user whether certain updates should be updated.
|
/// a Dialog that can be used to prompt the user whether certain updates should be updated.
|
||||||
class PluginUpdater : public QDialog, public Ui::PluginUpdater {
|
class PluginUpdater : public QDialog, public Ui::PluginUpdater {
|
||||||
private:
|
private:
|
||||||
Q_OBJECT;
|
Q_OBJECT
|
||||||
Q_DISABLE_COPY(PluginUpdater);
|
Q_DISABLE_COPY(PluginUpdater)
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// An atomic flag indicating whether the plugin update has been interrupted. It is used
|
/// An atomic flag indicating whether the plugin update has been interrupted. It is used
|
||||||
|
|||||||
@ -28,19 +28,19 @@ void PositionalAudioViewer::update() {
|
|||||||
|
|
||||||
pluginManager->fetchPositionalData();
|
pluginManager->fetchPositionalData();
|
||||||
|
|
||||||
const PositionalData &data = pluginManager->getPositionalData();
|
const PositionalData &posData = pluginManager->getPositionalData();
|
||||||
|
|
||||||
updatePlayer(data);
|
updatePlayer(posData);
|
||||||
updateCamera(data);
|
updateCamera(posData);
|
||||||
|
|
||||||
m_ui->context->setPlainText(data.getContext());
|
m_ui->context->setPlainText(posData.getContext());
|
||||||
m_ui->identity->setPlainText(data.getPlayerIdentity());
|
m_ui->identity->setPlainText(posData.getPlayerIdentity());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PositionalAudioViewer::updatePlayer(const PositionalData &data) {
|
void PositionalAudioViewer::updatePlayer(const PositionalData &posData) {
|
||||||
const Position3D pos = data.getPlayerPos();
|
const Position3D pos = posData.getPlayerPos();
|
||||||
const Vector3D dir = data.getPlayerDir();
|
const Vector3D dir = posData.getPlayerDir();
|
||||||
const Vector3D axis = data.getPlayerAxis();
|
const Vector3D axis = posData.getPlayerAxis();
|
||||||
|
|
||||||
m_ui->playerPosX->setValue(pos.x);
|
m_ui->playerPosX->setValue(pos.x);
|
||||||
m_ui->playerPosY->setValue(pos.y);
|
m_ui->playerPosY->setValue(pos.y);
|
||||||
@ -55,10 +55,10 @@ void PositionalAudioViewer::updatePlayer(const PositionalData &data) {
|
|||||||
m_ui->playerAxisZ->setValue(axis.z);
|
m_ui->playerAxisZ->setValue(axis.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PositionalAudioViewer::updateCamera(const PositionalData &data) {
|
void PositionalAudioViewer::updateCamera(const PositionalData &posData) {
|
||||||
const Position3D pos = data.getCameraPos();
|
const Position3D pos = posData.getCameraPos();
|
||||||
const Vector3D dir = data.getCameraDir();
|
const Vector3D dir = posData.getCameraDir();
|
||||||
const Vector3D axis = data.getCameraAxis();
|
const Vector3D axis = posData.getCameraAxis();
|
||||||
|
|
||||||
m_ui->cameraPosX->setValue(pos.x);
|
m_ui->cameraPosX->setValue(pos.x);
|
||||||
m_ui->cameraPosY->setValue(pos.y);
|
m_ui->cameraPosY->setValue(pos.y);
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class PositionalAudioViewer;
|
class PositionalAudioViewer;
|
||||||
};
|
}
|
||||||
|
|
||||||
class PositionalAudioViewer : public QDialog {
|
class PositionalAudioViewer : public QDialog {
|
||||||
public:
|
public:
|
||||||
@ -31,7 +31,7 @@ protected:
|
|||||||
std::unique_ptr< Ui::PositionalAudioViewer > m_ui;
|
std::unique_ptr< Ui::PositionalAudioViewer > m_ui;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_OBJECT;
|
Q_OBJECT
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user