Revision 538:8ffb8985ae8f
| src/vamp-hostsdk/PluginWrapper.cpp | ||
|---|---|---|
| 44 | 44 |
|
| 45 | 45 |
PluginWrapper::PluginWrapper(Plugin *plugin) : |
| 46 | 46 |
Plugin(plugin->getInputSampleRate()), |
| 47 |
m_plugin(plugin) |
|
| 47 |
m_plugin(plugin), |
|
| 48 |
m_pluginIsOwned(true) |
|
| 48 | 49 |
{
|
| 49 | 50 |
} |
| 50 | 51 |
|
| 51 | 52 |
PluginWrapper::~PluginWrapper() |
| 52 | 53 |
{
|
| 53 |
delete m_plugin; |
|
| 54 |
if (m_pluginIsOwned) {
|
|
| 55 |
delete m_plugin; |
|
| 56 |
} |
|
| 57 |
} |
|
| 58 |
|
|
| 59 |
void |
|
| 60 |
PluginWrapper::disownPlugin() |
|
| 61 |
{
|
|
| 62 |
m_pluginIsOwned = false; |
|
| 54 | 63 |
} |
| 55 | 64 |
|
| 56 | 65 |
bool |
| vamp-hostsdk/PluginBufferingAdapter.h | ||
|---|---|---|
| 69 | 69 |
* |
| 70 | 70 |
* In other respects, the PluginBufferingAdapter behaves identically |
| 71 | 71 |
* to the plugin that it wraps. The wrapped plugin will be deleted |
| 72 |
* when the wrapper is deleted. |
|
| 72 |
* when the wrapper is deleted. If you wish to prevent this, call |
|
| 73 |
* disownPlugin(). |
|
| 73 | 74 |
*/ |
| 74 | 75 |
|
| 75 | 76 |
class PluginBufferingAdapter : public PluginWrapper |
| ... | ... | |
| 78 | 79 |
/** |
| 79 | 80 |
* Construct a PluginBufferingAdapter wrapping the given plugin. |
| 80 | 81 |
* The adapter takes ownership of the plugin, which will be |
| 81 |
* deleted when the adapter is deleted. |
|
| 82 |
* deleted when the adapter is deleted. If you wish to prevent |
|
| 83 |
* this, call disownPlugin(). |
|
| 82 | 84 |
*/ |
| 83 | 85 |
PluginBufferingAdapter(Plugin *plugin); |
| 84 | 86 |
virtual ~PluginBufferingAdapter(); |
| vamp-hostsdk/PluginChannelAdapter.h | ||
|---|---|---|
| 104 | 104 |
* In every respect other than its management of channels, the |
| 105 | 105 |
* PluginChannelAdapter behaves identically to the plugin that it |
| 106 | 106 |
* wraps. The wrapped plugin will be deleted when the wrapper is |
| 107 |
* deleted. |
|
| 107 |
* deleted. If you wish to prevent this, call disownPlugin().
|
|
| 108 | 108 |
* |
| 109 | 109 |
* \note This class was introduced in version 1.1 of the Vamp plugin SDK. |
| 110 | 110 |
*/ |
| ... | ... | |
| 115 | 115 |
/** |
| 116 | 116 |
* Construct a PluginChannelAdapter wrapping the given plugin. |
| 117 | 117 |
* The adapter takes ownership of the plugin, which will be |
| 118 |
* deleted when the adapter is deleted. |
|
| 118 |
* deleted when the adapter is deleted. If you wish to prevent |
|
| 119 |
* this, call disownPlugin(). |
|
| 119 | 120 |
*/ |
| 120 | 121 |
PluginChannelAdapter(Plugin *plugin); |
| 121 | 122 |
virtual ~PluginChannelAdapter(); |
| vamp-hostsdk/PluginInputDomainAdapter.h | ||
|---|---|---|
| 79 | 79 |
* In every respect other than its input domain handling, the |
| 80 | 80 |
* PluginInputDomainAdapter behaves identically to the plugin that it |
| 81 | 81 |
* wraps. The wrapped plugin will be deleted when the wrapper is |
| 82 |
* deleted. |
|
| 82 |
* deleted. If you wish to prevent this, call disownPlugin().
|
|
| 83 | 83 |
* |
| 84 | 84 |
* \note This class was introduced in version 1.1 of the Vamp plugin SDK. |
| 85 | 85 |
*/ |
| ... | ... | |
| 90 | 90 |
/** |
| 91 | 91 |
* Construct a PluginInputDomainAdapter wrapping the given plugin. |
| 92 | 92 |
* The adapter takes ownership of the plugin, which will be |
| 93 |
* deleted when the adapter is deleted. |
|
| 93 |
* deleted when the adapter is deleted. If you wish to prevent |
|
| 94 |
* this, call disownPlugin(). |
|
| 94 | 95 |
*/ |
| 95 | 96 |
PluginInputDomainAdapter(Plugin *plugin); |
| 96 | 97 |
virtual ~PluginInputDomainAdapter(); |
| vamp-hostsdk/PluginSummarisingAdapter.h | ||
|---|---|---|
| 89 | 89 |
/** |
| 90 | 90 |
* Construct a PluginSummarisingAdapter wrapping the given plugin. |
| 91 | 91 |
* The adapter takes ownership of the plugin, which will be |
| 92 |
* deleted when the adapter is deleted. |
|
| 92 |
* deleted when the adapter is deleted. If you wish to prevent |
|
| 93 |
* this, call disownPlugin(). |
|
| 93 | 94 |
*/ |
| 94 | 95 |
PluginSummarisingAdapter(Plugin *plugin); |
| 95 | 96 |
virtual ~PluginSummarisingAdapter(); |
| vamp-hostsdk/PluginWrapper.h | ||
|---|---|---|
| 56 | 56 |
* override only the methods that are meaningful for the particular |
| 57 | 57 |
* adapter. |
| 58 | 58 |
* |
| 59 |
* A PluginWrapper takes ownership of the plugin it wraps, and deletes |
|
| 60 |
* it when it is itself deleted. To prevent this, call disownPlugin(). |
|
| 61 |
* |
|
| 59 | 62 |
* \note This class was introduced in version 1.1 of the Vamp plugin SDK. |
| 60 | 63 |
*/ |
| 61 | 64 |
|
| ... | ... | |
| 121 | 124 |
return 0; |
| 122 | 125 |
} |
| 123 | 126 |
|
| 127 |
/** |
|
| 128 |
* Disown the wrapped plugin, so that we no longer delete it on |
|
| 129 |
* our own destruction. The identity of the wrapped plugin is |
|
| 130 |
* unchanged, but this switches the expectation about ownership so |
|
| 131 |
* that the caller is expected to handle the lifecycle of the |
|
| 132 |
* wrapped plugin and to ensure that it outlasts this wrapper. |
|
| 133 |
* |
|
| 134 |
* This is not the normal model, but could be useful in situations |
|
| 135 |
* where a plugin is already managed using a smart pointer model |
|
| 136 |
* before being adapted into this wrapper. Note that this can't be |
|
| 137 |
* reversed - if you call this, you must subsequently take charge |
|
| 138 |
* of the wrapped plugin yourself. |
|
| 139 |
*/ |
|
| 140 |
void disownPlugin(); |
|
| 141 |
|
|
| 124 | 142 |
protected: |
| 125 | 143 |
PluginWrapper(Plugin *plugin); // I take ownership of plugin |
| 126 | 144 |
Plugin *m_plugin; |
| 145 |
bool m_pluginIsOwned; |
|
| 127 | 146 |
}; |
| 128 | 147 |
|
| 129 | 148 |
} |
Also available in: Unified diff