Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ option(WANT_DEBUG_TSAN "Enable ThreadSanitizer" OFF)
option(WANT_DEBUG_MSAN "Enable MemorySanitizer" OFF)
option(WANT_DEBUG_UBSAN "Enable UndefinedBehaviorSanitizer" OFF)
option(WANT_DEBUG_GPROF "Enable gprof profiler" OFF)
option(WANT_DEBUG_TRACY "Enable Tracy profiler" OFF)
OPTION(BUNDLE_QT_TRANSLATIONS "Install Qt translation files for LMMS" OFF)
option(WANT_DEBUG_CPACK "Show detailed logs for packaging commands" OFF)
option(WANT_CPACK_TARBALL "Request CPack to create a tarball instead of an installer" OFF)
Expand Down Expand Up @@ -709,7 +710,30 @@ if(WANT_DEBUG_GPROF)
add_link_options(-pg)
set(STATUS_GPROF "OK")
else()
set(STATUS_GPROF "Disabled ${STATUS_GPROF}")
set(STATUS_GPROF "Disabled${STATUS_GPROF}")
endif()

# Tracy profiler
if(WANT_DEBUG_TRACY)
include(FetchContent)

FetchContent_Declare(
tracy
GIT_REPOSITORY https://github.com/wolfpld/tracy.git
GIT_TAG 05cceee0df3b8d7c6fa87e9638af311dbabc63cb # v0.13.1
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(tracy)

if(TARGET TracyClient)
set(LMMS_DEBUG_TRACY TRUE)
set(STATUS_TRACY "Enabled")
else()
set(STATUS_TRACY "Error fetching dependency")
endif()
else()
set(STATUS_TRACY "Disabled")
endif()

# add enabled sanitizers
Expand Down Expand Up @@ -880,6 +904,7 @@ MESSAGE(
"* Debug using UBSanitizer : ${STATUS_DEBUG_UBSAN}\n"
"* Debug packaging commands : ${STATUS_DEBUG_CPACK}\n"
"* Profile using GNU profiler : ${STATUS_GPROF}\n"
"* Profile using Tracy profiler : ${STATUS_TRACY}\n"
"* Debug assertions : ${STATUS_ASSERTIONS}\n"
"* Experimental Qt6 support : ${STATUS_QT6}\n"
)
Expand Down
30 changes: 15 additions & 15 deletions include/AudioEngineProfiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <atomic>
#include <QFile>

#include "lmmsconfig.h"
#include "LmmsTypes.h"
#include "MicroTimer.h"

Expand All @@ -38,13 +39,10 @@ namespace lmms
class AudioEngineProfiler
{
public:
AudioEngineProfiler();
AudioEngineProfiler() = default;
~AudioEngineProfiler() = default;

void startPeriod()
{
m_periodTimer.reset();
}
void startPeriod();

void finishPeriod( sample_rate_t sampleRate, f_cnt_t framesPerPeriod );

Expand Down Expand Up @@ -73,20 +71,22 @@ class AudioEngineProfiler
class Probe
{
public:
Probe(AudioEngineProfiler& profiler, AudioEngineProfiler::DetailType type)
: m_profiler(profiler)
, m_type(type)
{
profiler.startDetail(type);
}
~Probe() { m_profiler.finishDetail(m_type); }
Probe& operator=(const Probe&) = delete;
Probe(AudioEngineProfiler& profiler, AudioEngineProfiler::DetailType type);
~Probe();

Probe(const Probe&) = delete;
Probe(Probe&&) = delete;
Probe& operator=(const Probe&) = delete;
Probe& operator=(Probe&&) = delete;

private:
AudioEngineProfiler &m_profiler;
AudioEngineProfiler& m_profiler;
const AudioEngineProfiler::DetailType m_type;

#ifdef LMMS_DEBUG_TRACY
struct TracyZoneContext { std::uint32_t id; std::int32_t active; };
[[maybe_unused]] TracyZoneContext m_context{};
#endif
};

private:
Expand All @@ -97,7 +97,7 @@ class AudioEngineProfiler
}

MicroTimer m_periodTimer;
std::atomic<float> m_cpuLoad;
std::atomic<float> m_cpuLoad = 0;
QFile m_outputFile;

// Use arrays to avoid dynamic allocations in realtime code
Expand Down
13 changes: 11 additions & 2 deletions include/AudioEngineWorkerThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
#include <QThread>

#include <atomic>
#include <condition_variable>
#include <optional>

class QWaitCondition;
#include "lmmsconfig.h"

namespace lmms
{
Expand Down Expand Up @@ -113,7 +115,14 @@ class AudioEngineWorkerThread : public QThread
void run() override;

static JobQueue globalJobQueue;
static QWaitCondition * queueReadyWaitCond;

#ifdef LMMS_DEBUG_TRACY
// Tracy uses a std::mutex wrapper, so it requires std::condition_variable_any
static inline std::optional<std::condition_variable_any> queueReadyWaitCond{};
#else
static inline std::optional<std::condition_variable> queueReadyWaitCond{};
#endif

static QList<AudioEngineWorkerThread *> workerThreads;

volatile bool m_quit;
Expand Down
1 change: 1 addition & 0 deletions include/InstrumentSoundShaping.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class InstrumentSoundShaping : public Model, public JournallingObject
f_cnt_t envFrames( const bool _only_vol = false ) const;
f_cnt_t releaseFrames() const;

// TODO: Remove? (dead code)
float volumeLevel( NotePlayHandle * _n, const f_cnt_t _frame );


Expand Down
2 changes: 1 addition & 1 deletion include/NotePlayHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class LMMS_EXPORT NotePlayHandle : public PlayHandle, public Note
return m_totalFramesPlayed;
}

/*! Returns volume level at given frame (envelope/LFO) */
/*! Returns volume level at given frame (envelope/LFO) TODO: Remove? (dead code) */
float volumeLevel( const f_cnt_t frame );

/*! Returns instrument track which is being played by this handle (const version) */
Expand Down
7 changes: 7 additions & 0 deletions include/Plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include <QStringList>
#include <QMap>
#include <string>

#include "JournallingObject.h"
#include "Model.h"
Expand Down Expand Up @@ -244,6 +245,9 @@ class LMMS_EXPORT Plugin : public Model, public JournallingObject
//! Return display-name out of sub plugin or descriptor
QString displayName() const override;

//! Same as @ref displayName, but as a cached UTF-8 string
const std::string& displayNameUtf8() const;

//! Return logo out of sub plugin or descriptor
const PixmapLoader *logo() const;

Expand Down Expand Up @@ -303,6 +307,9 @@ class LMMS_EXPORT Plugin : public Model, public JournallingObject

Descriptor::SubPluginFeatures::Key m_key;

//! Cached UTF-8 display name
mutable std::string m_displayName;

// pointer to instantiation-function in plugin
using InstantiationHook = Plugin* (*)(Model*, void*);
} ;
Expand Down
10 changes: 8 additions & 2 deletions include/Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,19 @@ class LMMS_EXPORT Track : public Model, public JournallingObject
// name-stuff
virtual const QString & name() const
{
return m_name;
return m_nameQString;
}

QString displayName() const override
{
return name();
}

const std::string& displayNameUtf8() const
{
return m_name;
}

using Model::dataChanged;

inline int getHeight()
Expand Down Expand Up @@ -214,7 +219,8 @@ public slots:
private:
TrackContainer* m_trackContainer;
Type m_type;
QString m_name;
std::string m_name;
QString m_nameQString;
int m_height;

protected:
Expand Down
Loading
Loading