Merge branch 'sfml'
Added Singleton to AudioWidget Conflicts: lms-audio.xlm puredata/layer_audio.pd src/audiolayerwidget.cpp src/audiolayerwidget.h src/audiomasterwidget.cpp src/audiomasterwidget.h src/audiomotor.cpp src/audiomotor.h src/audiowidget.cpp src/defines.h src/libremediaserver-audio.cpp src/libremediaserver-audio.h src/libremediaserver-audio.pro src/libremediaserver-audio.ui src/medialibrary.cpp src/medialibrary.h src/olathread.cpp src/olathread.h src/settings.cpp src/settings.h
This commit is contained in:
commit
2d16fb6af7
31 changed files with 1112 additions and 1296 deletions
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "defines.h"
|
||||
#include "dmxPersonality.h"
|
||||
#include "settings.h"
|
||||
|
||||
class olaThread : public QThread
|
||||
{
|
||||
|
|
@ -31,7 +32,6 @@ public:
|
|||
*@param int channel the channel for the value wanted
|
||||
*@return int the value
|
||||
*/
|
||||
|
||||
inline int getValue(int layer, int channel) {
|
||||
return m_dmx[layer][channel];
|
||||
}
|
||||
|
|
@ -39,70 +39,91 @@ public:
|
|||
/**
|
||||
* @brief resendDMX emite todo el buffer DMX
|
||||
*/
|
||||
|
||||
void resendDmx();
|
||||
|
||||
private:
|
||||
|
||||
void run ();
|
||||
|
||||
ola::client::OlaClientWrapper *m_clientWrapper;
|
||||
ola::client::OlaClient *m_client;
|
||||
unsigned int m_counter;
|
||||
struct timeval m_last_data; // Last DMX frame received
|
||||
|
||||
// DMX Conf
|
||||
// Cambiar para múltiples universos. Array? método de de ola::client?
|
||||
QList<int> *m_universe; // Registered universes.
|
||||
int m_layersNumber; // Number of layers in wich divide the dmx frame. Each layer, one source.
|
||||
|
||||
int m_dmx[LAYERS_NUMBER][LAYER_CHANNELS]; // DMX Buffer. Habría que cambiarlo si queremos hacer las capas dinámicas
|
||||
|
||||
QList<dmxSetting> m_settings;
|
||||
|
||||
inline void registerUniverse(int universe)
|
||||
{
|
||||
|
||||
// void ola::client::OlaClient::RegisterUniverse(unsigned int universe,RegisterAction register_action,SetCallback * callback
|
||||
m_client->RegisterUniverse(universe, ola::client::REGISTER,ola::NewSingleCallback(this, &olaThread::RegisterComplete));
|
||||
}
|
||||
|
||||
/**
|
||||
* Control de errores en el registro de Universos en OLA
|
||||
* @brief Callback from ola. Control de errores en el registro de Universos en OLA
|
||||
* typedef SingleUseCallback1<void, const Result&> ola::client::SetCallback
|
||||
* @param ola::client::Result &error
|
||||
* @return void
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
// typedef SingleUseCallback1<void, const Result&> ola::client::SetCallback
|
||||
|
||||
inline void RegisterComplete(const ola::client::Result &error) {
|
||||
if (error.Success()) {
|
||||
qDebug() << "Register Universe success";
|
||||
qDebug("Register Universe success");
|
||||
emit toTerminal("Register Universe success");
|
||||
} else {
|
||||
qWarning() << "olaThread|" << "Register command failed" << QString::fromStdString(error.Error());
|
||||
qWarning("Register command failed: %s", error.Error().c_str());
|
||||
emit toTerminal("olaThread| Register command failed " + QString::fromStdString(error.Error()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if the dmx info is arriving each 4 seconds
|
||||
* @return bool
|
||||
*/
|
||||
bool CheckDataLoss();
|
||||
|
||||
// typedef Callback2<void, const DMXMetadata&, const DmxBuffer&> ola::client::RepeatableDMXCallback
|
||||
void NewDmx(const ola::client::DMXMetadata &dmx_meta, const ola::DmxBuffer &buffer); // Callback from OlaCLient when there is new dmx info
|
||||
/**
|
||||
* @brief RepeteableDMXCallBack from ola called when arrives a new dmx frame
|
||||
* typedef Callback2<void, const DMXMetadata&, const DmxBuffer&> ola::client::RepeatableDMXCallback
|
||||
* This is called one for second if there is not updated in the DMX frame. We need emit only the channels that
|
||||
* has changed to save resources.
|
||||
*
|
||||
*
|
||||
*/
|
||||
void NewDmx(const ola::client::DMXMetadata &dmx_meta, const ola::DmxBuffer &buffer); //
|
||||
|
||||
/**
|
||||
* @brief Sometimes the ola server closes the connection. This is a callback to handle this event an reconect to ola
|
||||
*
|
||||
*
|
||||
*/
|
||||
void socketClosed();
|
||||
|
||||
/**
|
||||
* @brief Open the connection with olad and start processing data.
|
||||
*
|
||||
*
|
||||
*/
|
||||
void init();
|
||||
|
||||
public slots:
|
||||
|
||||
void stop(); // Close the connection with olad.
|
||||
void setLayersNumber(int layersNumber);
|
||||
|
||||
inline void setDMXConf(dmxSetting set)
|
||||
{
|
||||
if (set.layer >= m_layersNumber) { return; }
|
||||
/**
|
||||
* @brief register one Universe
|
||||
* void ola::client::OlaClient::RegisterUniverse(unsigned int universe,RegisterAction register_action,SetCallback * callback
|
||||
* @param universe
|
||||
*/
|
||||
inline void registerUniverse(int universe) {
|
||||
qDebug("Registering universe %d", universe);
|
||||
m_client->RegisterUniverse(universe,
|
||||
ola::client::REGISTER,
|
||||
ola::NewSingleCallback
|
||||
(this, &olaThread::RegisterComplete));
|
||||
}
|
||||
|
||||
m_settings.replace(set.layer, set);
|
||||
|
||||
// ToDo: registro del nuevo universo si no está registrado ya
|
||||
if (!m_universe->contains(set.universe)) {
|
||||
registerUniverse(set.universe);
|
||||
m_universe->append(set.universe);
|
||||
/**
|
||||
* @brief Register all the universes again
|
||||
*
|
||||
*/
|
||||
inline void registerUniverse() {
|
||||
QSet<int> unis = Settings::getInstance()->getUniverses();
|
||||
foreach (const int &universe, unis) {
|
||||
registerUniverse(universe);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -114,6 +135,9 @@ signals:
|
|||
void dmxOutput(int layer, int channel, int value); // Signal when a channel has changed
|
||||
void toTerminal(QString message);
|
||||
void universeReceived(uint universe);
|
||||
void layerReceived();
|
||||
};
|
||||
|
||||
using namespace ola;
|
||||
|
||||
#endif // OLATHREAD_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue