Skip to content

Commit

Permalink
Fix some more threading errors (#911)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-seker authored Aug 2, 2020
1 parent d9e3388 commit 8824e69
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 155 deletions.
2 changes: 1 addition & 1 deletion include/hyperion/ComponentRegister.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ComponentRegister : public QObject
int isComponentEnabled(const hyperion::Components& comp) const;

/// contains all components and their state
std::map<hyperion::Components, bool> getRegister() { return _componentStates; };
std::map<hyperion::Components, bool> getRegister() const { return _componentStates; };

signals:
///
Expand Down
54 changes: 22 additions & 32 deletions include/hyperion/Hyperion.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@
#include <QJsonValue>
#include <QJsonArray>
#include <QMap>
#include <QMutex>

// hyperion-utils includes
#include <utils/Image.h>
#include <utils/ColorRgb.h>
#include <utils/Logger.h>
#include <utils/Components.h>
#include <utils/VideoMode.h>

Expand Down Expand Up @@ -49,6 +47,7 @@ class BGEffectHandler;
class CaptureCont;
class BoblightServer;
class LedDeviceWrapper;
class Logger;

///
/// The main class of Hyperion. This gives other 'users' access to the attached LedDevice through
Expand All @@ -71,42 +70,41 @@ class Hyperion : public QObject
///
void freeObjects(bool emitCloseSignal=false);

ImageProcessor* getImageProcessor() { return _imageProcessor; }
ImageProcessor* getImageProcessor() const { return _imageProcessor; }

///
/// @brief Get instance index of this instance
/// @return The index of this instance
///
const quint8 & getInstanceIndex() { return _instIndex; }
quint8 getInstanceIndex() const { return _instIndex; }

///
/// @brief Return the size of led grid
///
QSize getLedGridSize() const { return _ledGridSize; }

/// gets the methode how image is maped to leds
const int & getLedMappingType();
int getLedMappingType() const;

/// forward smoothing config
unsigned addSmoothingConfig(int settlingTime_ms, double ledUpdateFrequency_hz=25.0, unsigned updateDelay=0);
unsigned updateSmoothingConfig(unsigned id, int settlingTime_ms=200, double ledUpdateFrequency_hz=25.0, unsigned updateDelay=0);


const VideoMode & getCurrentVideoMode();
VideoMode getCurrentVideoMode() const;

///
/// @brief Get the current active led device
/// @return The device name
///
const QString & getActiveDeviceType();
QString getActiveDeviceType() const;

public slots:

///
/// @brief Get pointer to current LedDevice
/// Updates the priority muxer with the current time and (re)writes the led color with applied
/// transforms.
///
LedDevice * getActiveDevice() const;

public slots:
int getLatchTime() const;
void update();

///
/// Returns the number of attached leds
Expand Down Expand Up @@ -176,7 +174,7 @@ public slots:
/// Returns the ColorAdjustment with the given identifier
/// @return The adjustment with the given identifier (or nullptr if the identifier does not exist)
///
ColorAdjustment * getAdjustment(const QString& id);
ColorAdjustment * getAdjustment(const QString& id) const;

/// Tell Hyperion that the corrections have changed and the leds need to be updated
void adjustmentsUpdated();
Expand All @@ -198,7 +196,7 @@ public slots:
/// @return EffectEngine instance pointer
///

EffectEngine* getEffectEngineInstance() { return _effectEngine; }
EffectEngine* getEffectEngineInstance() const { return _effectEngine; }
///
/// @brief Save an effect
/// @param obj The effect args
Expand Down Expand Up @@ -239,11 +237,11 @@ public slots:

/// Get the list of active effects
/// @return The list of active effects
const std::list<ActiveEffectDefinition> &getActiveEffects();
const std::list<ActiveEffectDefinition> &getActiveEffects() const;

/// Get the list of available effect schema files
/// @return The list of available effect schema files
const std::list<EffectSchema> &getEffectSchemas();
const std::list<EffectSchema> &getEffectSchemas() const;

/// #############
/// PRIORITYMUXER
Expand Down Expand Up @@ -298,7 +296,7 @@ public slots:
///
/// @return The information of the given, a not found priority will return lowest priority as fallback
///
const InputInfo getPriorityInfo(const int priority) const;
InputInfo getPriorityInfo(const int priority) const;

/// #############
/// SETTINGSMANAGER
Expand All @@ -307,11 +305,11 @@ public slots:
/// @param type The settingsType from enum
/// @return Data Document
///
QJsonDocument getSetting(const settings::type& type);
QJsonDocument getSetting(const settings::type& type) const;

/// gets the current json config object from SettingsManager
/// @return json config
const QJsonObject& getQJsonConfig();
const QJsonObject& getQJsonConfig() const;

///
/// @brief Save a complete json config
Expand All @@ -327,7 +325,7 @@ public slots:
/// @brief Get the component Register
/// return Component register pointer
///
ComponentRegister& getComponentRegister() { return _componentRegister; }
ComponentRegister & getComponentRegister() { return _componentRegister; }

///
/// @brief Called from components to update their current state. DO NOT CALL FROM USERS
Expand All @@ -340,7 +338,7 @@ public slots:
/// @brief Get a list of all contrable components and their current state
/// @return list of components
///
std::map<hyperion::Components, bool> getAllComponents();
std::map<hyperion::Components, bool> getAllComponents() const;

///
/// @brief Test if a component is enabled
Expand Down Expand Up @@ -368,6 +366,8 @@ public slots:
///
void stop();

int getLatchTime() const;

signals:
/// Signal which is emitted when a priority channel is actively cleared
/// This signal will not be emitted when a priority channel time out
Expand Down Expand Up @@ -456,15 +456,7 @@ public slots:
///
void started();

public slots:
///
/// Updates the priority muxer with the current time and (re)writes the led color with applied
/// transforms.
///
void update();

private slots:

///
/// @brief Handle whenever the visible component changed
/// @param comp The new component
Expand Down Expand Up @@ -548,6 +540,4 @@ private slots:

/// Boblight instance
BoblightServer* _boblightServer;

QMutex _changes;
};
68 changes: 34 additions & 34 deletions include/leddevice/LedDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,12 @@ class LedDevice : public QObject
///
~LedDevice() override;

///
/// @brief Get color order of device.
///
/// @return The color order
///
const QString & getColorOrder() const { return _colorOrder; }

///
/// @brief Set the current active LED-device type.
///
/// @param deviceType Device's type
///
void setActiveDeviceType(const QString& deviceType);

///
/// @brief Get the current active LED-device type.
///
const QString & getActiveDeviceType() const { return _activeDeviceType; }
void setActiveDeviceType(const QString& deviceType);

///
/// @brief Set the number of LEDs supported by the device.
Expand All @@ -76,13 +64,6 @@ class LedDevice : public QObject
///
void setLedCount(unsigned int ledCount);

///
/// @brief Get the number of LEDs supported by the device.
///
/// @return Number of device's LEDs
///
unsigned int getLedCount() const { return _ledCount; }

///
/// @brief Check, if the device is enabled.
///
Expand All @@ -100,13 +81,6 @@ class LedDevice : public QObject
///
void setLatchTime(int latchTime_ms);

///
/// @brief Get the currently defined LatchTime.
///
/// @return Latch time in milliseconds
///
int getLatchTime() const { return _latchTime_ms; }

///
/// @brief Discover devices of this type available (for configuration).
/// @note Mainly used for network devices. Allows to find devices, e.g. via ssdp, mDNS or cloud ways.
Expand Down Expand Up @@ -167,13 +141,6 @@ class LedDevice : public QObject
///
bool isInError() const { return _isDeviceInError; }

///
/// @brief Get the LED-Device component's state.
///
/// @return True, if enabled
///
inline bool componentState() const { return isEnabled(); }

///
/// @brief Prints the color values to stdout.
///
Expand Down Expand Up @@ -214,6 +181,39 @@ public slots:
///
void setEnable(bool enable);

///
/// @brief Get the currently defined LatchTime.
///
/// @return Latch time in milliseconds
///
int getLatchTime() const { return _latchTime_ms; }

///
/// @brief Get the number of LEDs supported by the device.
///
/// @return Number of device's LEDs
///
unsigned int getLedCount() const { return _ledCount; }

///
/// @brief Get the current active LED-device type.
///
QString getActiveDeviceType() const { return _activeDeviceType; }

///
/// @brief Get color order of device.
///
/// @return The color order
///
QString getColorOrder() const { return _colorOrder; }

///
/// @brief Get the LED-Device component's state.
///
/// @return True, if enabled
///
inline bool componentState() const { return isEnabled(); }

signals:
///
/// @brief Emits whenever the LED-Device switches between on/off.
Expand Down
7 changes: 5 additions & 2 deletions include/leddevice/LedDeviceWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <utils/ColorRgb.h>
#include <utils/Components.h>

#include <QMutex>

class LedDevice;
class Hyperion;

Expand Down Expand Up @@ -53,7 +55,7 @@ class LedDeviceWrapper : public QObject
///
/// @brief Get the current active ledDevice type
///
const QString & getActiveDeviceType();
QString getActiveDeviceType();

///
/// @brief Return the last enable state
Expand All @@ -63,7 +65,7 @@ class LedDeviceWrapper : public QObject
///
/// @brief Get the current colorOrder from device
///
const QString & getColorOrder();
QString getColorOrder();

///
/// @brief Get the number of LEDs from device
Expand Down Expand Up @@ -103,6 +105,7 @@ private slots:
protected:
/// contains all available led device constructors
static LedDeviceRegistry _ledDeviceMap;
static QMutex _ledDeviceMapLock;

private:
///
Expand Down
Loading

0 comments on commit 8824e69

Please sign in to comment.