-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathProjectMWrapper.h
112 lines (86 loc) · 3.73 KB
/
ProjectMWrapper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#pragma once
#include "notifications/PlaybackControlNotification.h"
#include <projectM-4/projectM.h>
#include <projectM-4/playlist.h>
#include <Poco/Logger.h>
#include <Poco/NObserver.h>
#include <Poco/Util/AbstractConfiguration.h>
#include <Poco/Util/Subsystem.h>
#include <memory>
class ProjectMWrapper : public Poco::Util::Subsystem
{
public:
const char* name() const override;
void initialize(Poco::Util::Application& app) override;
void uninitialize() override;
/**
* Returns the projectM instance handle.
* @return The projectM instance handle used to call API functions.
*/
projectm_handle ProjectM() const;
/**
* Returns the playlist handle.
* @return The plaslist handle.
*/
projectm_playlist_handle Playlist() const;
/**
* Renders a single projectM frame.
*/
void RenderFrame() const;
/**
* @brief Returns the targeted FPS value.
* @return The user-configured target FPS. Can be 0, which means unlimited.
*/
int TargetFPS();
/**
* @brief Updates projectM with the current, actual FPS value.
* @param fps The current FPS value.
*/
void UpdateRealFPS(float fps);
/**
* @brief If splash is disabled, shows the initial preset.
* If shuffle is on, a random preset will be picked. Otherwise, the first playlist item is displayed.
*/
void DisplayInitialPreset();
/**
* @brief Changes beat sensitivity by the given value.
* @param value A positive or negative delta value.
*/
void ChangeBeatSensitivity(float value);
/**
* @brief Returns the libprojectM version this application was built against.
* @return A string with the libprojectM build version.
*/
std::string ProjectMBuildVersion();
/**
* @brief Returns the libprojectM version this applications currently runs with.
* @return A string with the libprojectM runtime library version.
*/
std::string ProjectMRuntimeVersion();
private:
/**
* @brief projectM callback. Called whenever a preset is switched.
* @param isHardCut True if the switch was a hard cut.
* @param index New preset playlist index.
* @param context Callback context, e.g. "this" pointer.
*/
static void PresetSwitchedEvent(bool isHardCut, unsigned int index, void* context);
void PlaybackControlNotificationHandler(const Poco::AutoPtr<PlaybackControlNotification>& notification);
std::vector<std::string> GetPathListWithDefault(const std::string& baseKey, const std::string& defaultPath);
/**
* @brief Event callback if a configuration value has changed.
* @param property The key and value that has been changed.
*/
void OnConfigurationPropertyChanged(const Poco::Util::AbstractConfiguration::KeyValue& property);
/**
* @brief Event callback if a configuration value has been removed.
* @param key The key of the removed property.
*/
void OnConfigurationPropertyRemoved(const std::string& key);
Poco::AutoPtr<Poco::Util::AbstractConfiguration> _userConfig; //!< View of the "projectM" configuration subkey in the "user" configuration.
Poco::AutoPtr<Poco::Util::AbstractConfiguration> _projectMConfigView; //!< View of the "projectM" configuration subkey in the "effective" configuration.
projectm_handle _projectM{nullptr}; //!< Pointer to the projectM instance used by the application.
projectm_playlist_handle _playlist{nullptr}; //!< Pointer to the projectM playlist manager instance.
Poco::NObserver<ProjectMWrapper, PlaybackControlNotification> _playbackControlNotificationObserver{*this, &ProjectMWrapper::PlaybackControlNotificationHandler};
Poco::Logger& _logger{Poco::Logger::get("SDLRenderingWindow")}; //!< The class logger.
};