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 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
/*
* Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
* (C) 2020 Vladimir Sadovnikov <sadko4u@gmail.com>
*
* This file is part of lsp-plugin-fw
* Created on: 24 нояб. 2020 г.
*
* lsp-plugin-fw is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* lsp-plugin-fw is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with lsp-plugin-fw. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef LSP_PLUG_IN_PLUG_FW_BACK_MODULE_H_
#define LSP_PLUG_IN_PLUG_FW_BACK_MODULE_H_
#ifndef LSP_PLUG_IN_PLUG_FW_PLUG_IMPL_H_
#error "Use #include <lsp-plug.in/plug-fw/plug.h>"
#endif /* LSP_PLUG_IN_PLUG_FW_PLUG_IMPL_H_ */
#include <lsp-plug.in/plug-fw/version.h>
#include <lsp-plug.in/plug-fw/plug/IPort.h>
#include <lsp-plug.in/plug-fw/plug/ICanvas.h>
#include <lsp-plug.in/plug-fw/plug/data.h>
#include <lsp-plug.in/plug-fw/core/KVTStorage.h>
#include <lsp-plug.in/common/types.h>
#include <lsp-plug.in/dsp-units/iface/IStateDumper.h>
namespace lsp
{
namespace plug
{
class IWrapper;
/**
* Main plugin class
*/
class Module
{
private:
Module &operator = (const Module &);
protected:
const meta::plugin_t *pMetadata;
IWrapper *pWrapper;
long fSampleRate;
ssize_t nLatency;
bool bActivated;
bool bUIActive;
public:
explicit Module(const meta::plugin_t *meta);
virtual ~Module();
/** Initialize plugin module
*
* @param wrapper plugin wrapper interface
* @param ports list of ports supplied by plugin wrapper
*/
virtual void init(IWrapper *wrapper, IPort **ports);
/** Destroy plugin module
*
*/
virtual void destroy();
public:
const meta::plugin_t *metadata() const { return pMetadata; }
inline ssize_t latency() const { return nLatency; }
inline void set_latency(ssize_t latency) { nLatency = latency; }
void set_sample_rate(long sr);
inline long get_sample_rate() const { return fSampleRate; }
inline bool active() const { return bActivated; }
inline bool ui_active() const { return bUIActive; }
inline IWrapper *wrapper() { return pWrapper; }
void activate_ui();
void deactivate_ui();
void activate();
void deactivate();
public:
/** Update sample rate of data processing
*
* @param sr new sample rate
*/
virtual void update_sample_rate(long sr);
/** Triggered plugin activation
*
*/
virtual void activated();
/** Triggered UI activation
*
*/
virtual void ui_activated();
/** Triggered input port change, need to update configuration
*
*/
virtual void update_settings();
/** Report current time position for plugin
*
* @param pos current time position
* @return true if need to call for plugin setting update
*/
virtual bool set_position(const position_t *pos);
/** Process data
*
* @param samples number of samples to process
*/
virtual void process(size_t samples);
/** Draw inline display on canvas
* This feature will not work unless E_INLINE_DISPLAY extension is
* specified in plugin's metadata
*
* @param cv canvas
* @param width maximum canvas width
* @param height maximum canvas height
* @return status of operation
*/
virtual bool inline_display(ICanvas *cv, size_t width, size_t height);
/** Triggered UI deactivation
*
*/
virtual void ui_deactivated();
/** Triggered plugin deactivation
*
*/
virtual void deactivated();
/**
* Lock the KVT storage
* @return pointer to KVT storage or NULL
*/
virtual core::KVTStorage *kvt_lock();
/**
* Try to lock the KVT storage
* @return pointer to KVT storage or NULL if not locked/not supported
*/
virtual core::KVTStorage *kvt_trylock();
/**
* Release the KVT storage
*/
virtual void kvt_release();
/** Callback for case when plugin's state has been saved
*
*/
virtual void state_saved();
/** Callback for case when plugin's state has been loaded
*
*/
virtual void state_loaded();
/**
* Dump plugin state
* @param v state dumper
*/
virtual void dump(dspu::IStateDumper *v) const;
};
}
}
#endif /* LSP_PLUG_IN_PLUG_FW_BACK_MODULE_H_ */
|