Skip to content

Commit ac21ef2

Browse files
committed
0.20.1
1 parent ec61977 commit ac21ef2

File tree

7 files changed

+65
-6
lines changed

7 files changed

+65
-6
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ add_subdirectory(lib/atkaudio)
4949
file(READ "${CMAKE_SOURCE_DIR}/buildspec.json" buildspec)
5050
string(JSON PLUGIN_DISPLAY_NAME GET ${buildspec} displayName)
5151
string(JSON PLUGIN_AUTHOR GET ${buildspec} author)
52+
string(JSON PLUGIN_OBS_VERSION_REQUIRED GET ${buildspec} dependencies obs-studio version)
5253
string(TIMESTAMP PLUGIN_YEAR "%Y")
5354
set(PLUGIN_AUTHOR "${PLUGIN_AUTHOR}")
5455

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
Plugin Host2 can interface directly with audio and MIDI hardware, OBS audio sources, and output audio as new OBS sources, allowing for complex audio processing setups. E.g. use ASIO interface as audio device, take additional audio from OBS sources, route monitoring to ASIO outputs and/or different audio drivers/hardware, use plugins and create final mix, and output the processed audio as a new OBS source for recording and streaming. Or just create a simple soundboard with a sampler plugin and a MIDI keyboard.
2121

22-
Develop your own audio processing plugins and integrate them into `Plugin Host2` using the [JUCE framework](https://juce.com/) AudioProcessor class. See `InternalPlugins.cpp` how `GainPlugin` is loaded. See `GainPlugin.h` for implementation.
22+
Develop your own audio processing plugins and integrate them into `Plugin Host2` using the [JUCE framework](https://juce.com/) AudioProcessor class. See `InternalPlugins.cpp` how `GainPlugin` is loaded. See `GainPlugin.h` for implementation. Optionally include OBS headers to use the [OBS API](https://docs.obsproject.com/) for more advanced integration with [OBS Studio](https://obsproject.com/)
2323

2424
## Device I/O
2525

buildspec.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@
4343
"uuids": {
4444
"windowsApp": "ad885c58-5ca9-44de-8f4f-1c12676626a9"
4545
},
46-
"version": "0.19.2",
46+
"version": "0.20.1",
4747
"website": "https://www.atkaudio.com"
4848
}

lib/atkaudio/src/atkaudio/PluginHost2/ObsOutput.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class ObsOutputAudioProcessor : public juce::AudioProcessor
3838

3939
~ObsOutputAudioProcessor() override
4040
{
41+
numInstances.fetch_sub(1, std::memory_order_acquire);
4142
if (privateSource)
4243
{
4344
obs_source_release(privateSource);
@@ -64,8 +65,8 @@ class ObsOutputAudioProcessor : public juce::AudioProcessor
6465

6566
audioSourceData.frames = static_cast<uint32_t>(buffer.getNumSamples());
6667
audioSourceData.speakers = getMainBusNumInputChannels() <= MAX_AUDIO_CHANNELS
67-
? static_cast<enum speaker_layout>(getMainBusNumInputChannels())
68-
: SPEAKERS_UNKNOWN;
68+
? static_cast<enum speaker_layout>(getMainBusNumInputChannels())
69+
: SPEAKERS_UNKNOWN;
6970
audioSourceData.format = AUDIO_FORMAT_FLOAT_PLANAR;
7071
audioSourceData.samples_per_sec = static_cast<uint32_t>(getSampleRate());
7172
audioSourceData.timestamp = os_gettime_ns();
@@ -142,7 +143,7 @@ class ObsOutputAudioProcessor : public juce::AudioProcessor
142143
}
143144

144145
private:
145-
std::atomic_int numInstances{0};
146+
static inline std::atomic_int numInstances{0};
146147
juce::AudioProcessorValueTreeState apvts;
147148

148149
obs_source_t* privateSource = nullptr;

src/CompareVersionStrings.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#pragma once
2+
#include <sstream>
3+
#include <string>
4+
#include <vector>
5+
6+
inline std::vector<int> TokenizeVersionString(const std::string& str)
7+
{
8+
std::vector<int> tokens;
9+
std::stringstream ss(str);
10+
std::string item;
11+
while (std::getline(ss, item, '.'))
12+
{
13+
try
14+
{
15+
tokens.push_back(std::stoi(item));
16+
}
17+
catch (const std::exception& e)
18+
{
19+
(void)e;
20+
tokens.push_back(-1);
21+
}
22+
}
23+
return tokens;
24+
}
25+
26+
inline int CompareVersionStrings(const std::string& v1, const std::string& v2)
27+
{
28+
auto p1 = TokenizeVersionString(v1);
29+
auto p2 = TokenizeVersionString(v2);
30+
size_t maxLen = std::max(p1.size(), p2.size());
31+
p1.resize(maxLen, 0);
32+
p2.resize(maxLen, 0);
33+
for (size_t i = 0; i < maxLen; ++i)
34+
{
35+
if (p1[i] < p2[i])
36+
return -1;
37+
if (p1[i] > p2[i])
38+
return 1;
39+
}
40+
return 0;
41+
}

src/config.h.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
#define PLUGIN_VERSION "@CMAKE_PROJECT_VERSION@"
55
#define PLUGIN_DISPLAY_NAME "@PLUGIN_DISPLAY_NAME@"
66
#define PLUGIN_YEAR "@PLUGIN_YEAR@"
7-
#define PLUGIN_AUTHOR "@PLUGIN_AUTHOR@"
7+
#define PLUGIN_AUTHOR "@PLUGIN_AUTHOR@"
8+
#define PLUGIN_OBS_VERSION_REQUIRED "@PLUGIN_OBS_VERSION_REQUIRED@"

src/plugin-main.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ You should have received a copy of the GNU General Public License along
1616
with this program. If not, see <https://www.gnu.org/licenses/>
1717
*/
1818

19+
#include "CompareVersionStrings.h"
1920
#include "config.h"
2021

2122
#include <atkaudio/atkaudio.h>
@@ -51,6 +52,20 @@ MessagePump* messagePump = nullptr;
5152

5253
bool obs_module_load(void)
5354
{
55+
std::string obsCurrentVersion = obs_get_version_string();
56+
std::string requiredVersion = PLUGIN_OBS_VERSION_REQUIRED;
57+
58+
if (CompareVersionStrings(obsCurrentVersion, requiredVersion) < 0)
59+
{
60+
obs_log(
61+
LOG_ERROR,
62+
"Incompatible OBS version: %s (required: %s)",
63+
obsCurrentVersion.c_str(),
64+
requiredVersion.c_str()
65+
);
66+
return false;
67+
}
68+
5469
obs_log(LOG_INFO, "plugin loaded successfully (version %s)", plugin_version);
5570

5671
atk::create();

0 commit comments

Comments
 (0)