Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "JUCE"]
path = JUCE
url = https://github.com/apohl79/JUCE.git
url = https://github.com/kcoul/JUCE.git
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ set(AG_AAX_SDK_DEFAULT "${AG_SDKS_ROOT}/aax-sdk")
set(AG_AAX_SDK ${AG_AAX_SDK_DEFAULT} CACHE STRING "AAX SDK Folder")

if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(AG_MACOS_TARGET 10.8 CACHE STRING "macOS target, default is 10.8")
set(AG_MACOS_TARGET 10.15 CACHE STRING "macOS target, default is 10.15")
set(CMAKE_OSX_DEPLOYMENT_TARGET ${AG_MACOS_TARGET})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
Expand Down
2 changes: 1 addition & 1 deletion Common/Source/WindowHelper.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include "WindowHelper.hpp"

#include <juce_graphics/native/juce_mac_CoreGraphicsHelpers.h>
#include <juce_graphics/native/juce_CoreGraphicsHelpers_mac.h>

namespace e47 {
namespace WindowHelper {
Expand Down
2 changes: 1 addition & 1 deletion JUCE
Submodule JUCE updated 3341 files
1 change: 1 addition & 0 deletions Plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ macro(ag_add_plugin type)
VST_NUM_MIDI_OUTS 16
VST2_CATEGORY ${AG_VST_CATEGORY}
VST3_CATEGORIES Network ${AG_VST3_CATEGORY}
VST3_AUTO_MANIFEST FALSE
AAX_CATEGORY ${AG_AAX_CATEGORY}
AU_MAIN_TYPE ${AG_AU_TYPE}
AU_SANDBOX_SAFE TRUE
Expand Down
4 changes: 2 additions & 2 deletions Plugin/Source/AudioStreamer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ namespace e47 {
template <typename T>
class AudioStreamer : public Thread, public LogTagDelegate {
public:
AudioStreamer(Client* clnt, StreamingSocket* sock)
AudioStreamer(Client* clnt, std::unique_ptr<StreamingSocket> sock)
: Thread("AudioStreamer"),
LogTagDelegate(clnt),
m_client(clnt),
m_socket(std::unique_ptr<StreamingSocket>(sock)),
m_socket(std::move(sock)),
m_queueSize((size_t)clnt->NUM_OF_BUFFERS * 8),
m_queueHighWaterMark((size_t)clnt->NUM_OF_BUFFERS * 7),
m_writeQ(m_queueSize),
Expand Down
37 changes: 19 additions & 18 deletions Plugin/Source/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,30 +306,33 @@ void Client::setOnCloseCallback(OnCloseCallback fn) {
}

void Client::init(int channelsIn, int channelsOut, int channelsSC, double rate, int samplesPerBlock,
bool doublePrecission) {
bool doublePrecision) {
traceScope();
logln("init: channelsIn=" << channelsIn << " channelsOut=" << channelsOut << " channelsSC=" << channelsSC
<< " rate=" << rate << " samplesPerBlock=" << samplesPerBlock
<< " doublePrecision=" << (int)doublePrecission);
<< " doublePrecision=" << (int)doublePrecision);
LockByID lock(*this, INIT1);
if (!m_ready || m_channelsIn != channelsIn || m_channelsOut != channelsOut || m_channelsSC != channelsSC ||
m_sampleRate != rate || m_samplesPerBlock != samplesPerBlock || m_doublePrecission != doublePrecission) {
m_sampleRate != rate || m_samplesPerBlock != samplesPerBlock || m_doublePrecision != doublePrecision) {
m_channelsIn = channelsIn;
m_channelsOut = channelsOut;
m_channelsSC = channelsSC;
m_sampleRate = rate;
m_samplesPerBlock = samplesPerBlock;
m_doublePrecission = doublePrecission;
m_doublePrecision = doublePrecision;
m_needsReconnect = true;
m_ready = false;
logln("init: paramater change, requesting reconnect");
logln("init: parameter change, requesting reconnect");
}
}

void Client::init() {
traceScope();
auto srvInfo = getServer();
bool useUnixDomain = srvInfo.getLocalMode() && Defaults::unixDomainSocketsSupported();
if (useUnixDomain) {
socketOptions = socketOptions.usingUnixDomain(useUnixDomain);
}
int port = Defaults::SERVER_PORT + srvInfo.getID();

LockByID lock(*this, INIT2);
Expand All @@ -341,7 +344,7 @@ void Client::init() {
#endif

m_error = true;
m_cmdOut = std::make_unique<StreamingSocket>();
m_cmdOut = std::make_unique<StreamingSocket>(socketOptions);

if (useUnixDomain) {
auto socketPath = Defaults::getSocketPath(Defaults::SERVER_SOCK, {{"id", String(srvInfo.getID())}});
Expand All @@ -364,7 +367,7 @@ void Client::init() {
m_channelsSC,
m_sampleRate,
m_samplesPerBlock,
m_doublePrecission,
m_doublePrecision,
getTagId(),
0,
0,
Expand Down Expand Up @@ -409,22 +412,20 @@ void Client::init() {
return;
}

m_cmdIn = std::make_unique<StreamingSocket>();
m_cmdIn = std::make_unique<StreamingSocket>(socketOptions);
if (useUnixDomain ? !m_cmdIn->connect(workerSocketPath) : !m_cmdIn->connect(srvInfo.getHost(), resp.port)) {
logln("failed to setup command receive connection");
m_cmdIn.reset();
}
logln("command connection established");

StreamingSocket* audioSock = nullptr;
audioSock = new StreamingSocket;
std::unique_ptr<StreamingSocket> audioSock = std::make_unique<StreamingSocket>(socketOptions);
if (useUnixDomain ? !audioSock->connect(workerSocketPath) : !audioSock->connect(srvInfo.getHost(), resp.port)) {
logln("failed to setup audio connection");
delete audioSock;
audioSock = nullptr;
audioSock.reset();
}

m_screenSocket = std::make_unique<StreamingSocket>();
m_screenSocket = std::make_unique<StreamingSocket>(socketOptions);
if (useUnixDomain ? !m_screenSocket->connect(workerSocketPath)
: !m_screenSocket->connect(srvInfo.getHost(), resp.port)) {
logln("failed to setup screen connection");
Expand All @@ -433,14 +434,14 @@ void Client::init() {

if (nullptr != audioSock) {
logln("audio connection established");
RealtimeOptions opts;
opts.workDurationMs = (uint32)round(m_samplesPerBlock / m_sampleRate * 1000) - 1;
auto opts = RealtimeOptions()
.withProcessingTimeMs((uint32)round(m_samplesPerBlock / m_sampleRate * 1000) - 1);
std::lock_guard<std::mutex> audiolck(m_audioMtx);
if (m_doublePrecission) {
m_audioStreamerD = std::make_shared<AudioStreamer<double>>(this, audioSock);
if (m_doublePrecision) {
m_audioStreamerD = std::make_shared<AudioStreamer<double>>(this, std::move(audioSock));
m_audioStreamerD->startRealtimeThread(opts);
} else {
m_audioStreamerF = std::make_shared<AudioStreamer<float>>(this, audioSock);
m_audioStreamerF = std::make_shared<AudioStreamer<float>>(this, std::move(audioSock));
m_audioStreamerF->startRealtimeThread(opts);
}
} else {
Expand Down
7 changes: 4 additions & 3 deletions Plugin/Source/Client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class Client : public Thread, public LogTag, public MouseListener, public KeyLis
int getNumActiveChannels() const;
double getSampleRate() const { return m_sampleRate; }
int getSamplesPerBlock() const { return m_samplesPerBlock; }
bool isUsingDoublePrecission() const { return m_doublePrecission; }
bool isUsingDoublePrecission() const { return m_doublePrecision; }
int getLatencySamples() const { return m_latency + NUM_OF_BUFFERS * m_samplesPerBlock + m_latencyManual; }
void setLatencySamplesManual(int s) { m_latencyManual = s; }
int getLatencySamplesManual() { return m_latencyManual; }
Expand All @@ -178,7 +178,7 @@ class Client : public Thread, public LogTag, public MouseListener, public KeyLis

bool isReady(int timeout = 1000);
bool isReadyLockFree();
void init(int channelsIn, int channelsOut, int channelsSC, double rate, int samplesPerBlock, bool doublePrecission);
void init(int channelsIn, int channelsOut, int channelsSC, double rate, int samplesPerBlock, bool doublePrecision);

void reconnect() { m_needsReconnect = true; }
void close();
Expand Down Expand Up @@ -269,7 +269,7 @@ class Client : public Thread, public LogTag, public MouseListener, public KeyLis
int m_srvLoadLastUpdated = 0;
bool m_needsReconnect = false;
double m_sampleRate = 0;
bool m_doublePrecission = false;
bool m_doublePrecision = false;

std::atomic_int m_channelsIn{0};
std::atomic_int m_channelsOut{0};
Expand Down Expand Up @@ -368,6 +368,7 @@ class Client : public Thread, public LogTag, public MouseListener, public KeyLis
std::mutex m_clientMtx;
LockID m_clientMtxId = NOLOCK;

juce::SocketOptions socketOptions;
std::unique_ptr<StreamingSocket> m_cmdOut;
std::unique_ptr<StreamingSocket> m_cmdIn;
std::unique_ptr<StreamingSocket> m_screenSocket;
Expand Down
6 changes: 3 additions & 3 deletions Plugin/Source/PluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ void PluginEditor::paint(Graphics& g) {
FillType ft;
auto colBG = getLookAndFeel().findColour(ResizableWindow::backgroundColourId);
auto tp = m_processor.getTrackProperties();
if (!tp.colour.isTransparent()) {
auto gradient = ColourGradient::horizontal(colBG.interpolatedWith(tp.colour, 0.05f), 0, colBG, 100);
if (!tp.colour->isTransparent()) {
auto gradient = ColourGradient::horizontal(colBG.interpolatedWith(*tp.colour, 0.05f), 0, colBG, 100);
g.setGradientFill(gradient);
g.fillAll();
g.setColour(tp.colour);
g.setColour(*tp.colour);
g.fillRect(0, 0, 2, getHeight());
} else {
g.fillAll(colBG);
Expand Down
10 changes: 5 additions & 5 deletions Plugin/Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1793,7 +1793,7 @@ void PluginProcessor::TrayConnection::sendStatus() {

json j;
j["connected"] = isClientReady;
j["name"] = track.name.toStdString();
j["name"] = track.name->toStdString();
j["channelsIn"] = m_processor->getMainBusNumInputChannels();
j["channelsOut"] = m_processor->getTotalNumOutputChannels();
j["channelsSC"] = m_processor->getBusCount(true) > 0 ? m_processor->getChannelCountOfBus(true, 1) : 0;
Expand All @@ -1802,7 +1802,7 @@ void PluginProcessor::TrayConnection::sendStatus() {
#else
j["instrument"] = false;
#endif
j["colour"] = track.colour.getARGB();
j["colour"] = track.colour->getARGB();
j["loadedPlugins"] = client.getLoadedPluginsString().toStdString();
j["loadedPluginsOk"] = m_processor->m_loadedPluginsOk.load();
j["perfStream"] = tsStream->getMostRecentAverage();
Expand Down Expand Up @@ -1875,9 +1875,9 @@ void PluginProcessor::TrayConnection::run() {
if (!success) {
String path = File::getSpecialLocation(File::globalApplicationsDirectory).getFullPathName();
#ifdef JUCE_MAC
#ifdef DEBUG
path << "/Debug";
#endif
//#ifdef DEBUG
// path << "/Debug";
//#endif
path << "/AudioGridderPluginTray.app/Contents/MacOS/AudioGridderPluginTray";
#elif JUCE_WINDOWS
path << "/AudioGridderPluginTray/AudioGridderPluginTray.exe";
Expand Down
13 changes: 6 additions & 7 deletions Server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ target_compile_definitions(AudioGridderServer PRIVATE
JUCE_APPLICATION_VERSION_STRING="$<TARGET_PROPERTY:AudioGridderServer,JUCE_VERSION>"
JUCE_DISPLAY_SPLASH_SCREEN=0)

target_compile_features(AudioGridderServer PRIVATE cxx_std_14)

juce_add_binary_data(AudioGridderServerData SOURCES
Resources/icon.png
Resources/icon16.png
Expand All @@ -66,8 +64,10 @@ juce_add_binary_data(AudioGridderServerData SOURCES
target_link_libraries(AudioGridderServer PRIVATE
AudioGridderServerData
juce::juce_audio_basics
juce::juce_audio_processors
juce::juce_audio_devices
juce::juce_audio_formats
juce::juce_audio_processors
juce::juce_audio_utils
juce::juce_graphics
juce::juce_gui_extra
juce::juce_recommended_config_flags
Expand All @@ -90,10 +90,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
"-framework AVFoundation"
"-framework CoreMedia"
"-framework OpenGL"
"-framework Security")
if(AG_MACOS_TARGET STRGREATER_EQUAL 10.8)
target_link_libraries(AudioGridderServer PRIVATE "-framework VideoToolbox")
endif()
"-framework Security"
"-framework VideoToolbox")

ag_bundle_add_crashpad(AudioGridderServer)
ag_bundle_sign(AudioGridderServer)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
Expand Down
1 change: 0 additions & 1 deletion Server/Source/ProcessorWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class ProcessorWindow : public DocumentWindow, private Timer, public LogTag {
~ProcessorWindow() override;

void closeButtonPressed() override;
BorderSize<int> getBorderThickness() override { return {}; }

void forgetEditor();
juce::Rectangle<int> getScreenCaptureRect();
Expand Down
39 changes: 33 additions & 6 deletions Server/Source/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void Server::loadConfig() {
m_pluginWindowsOnTop = jsonGetValue(cfg, "PluginWindowsOnTop", m_pluginWindowsOnTop);
m_scanForPlugins = jsonGetValue(cfg, "ScanForPlugins", m_scanForPlugins);
m_crashReporting = jsonGetValue(cfg, "CrashReporting", m_crashReporting);
m_processingTraceTresholdMs = jsonGetValue(cfg, "ProcessingTraceTresholdMs", m_processingTraceTresholdMs);
m_processingTraceThresholdMs = jsonGetValue(cfg, "ProcessingTraceTresholdMs", m_processingTraceThresholdMs); //TODO: How to update the JSON string without breaking things?
logln("crash reporting is " << (m_crashReporting ? "enabled" : "disabled"));
m_sandboxMode = (SandboxMode)jsonGetValue(cfg, "SandboxMode", m_sandboxMode);
logln("sandbox mode is " << (m_sandboxMode == SANDBOX_CHAIN ? "chain isolation"
Expand All @@ -175,6 +175,30 @@ void Server::loadConfig() {
m_pluginExclude.insert(s.get<std::string>());
}
}

loadDeviceConfig();
}

void Server::loadDeviceConfig() {
#if JUCE_DEBUG
auto path = std::filesystem::current_path();
auto loadPath = path / "NativeIOSettings.xml";
juce::File deviceXMLFile (loadPath.string());
if (deviceXMLFile.existsAsFile()) {
auto deviceXML = juce::XmlDocument::parse(deviceXMLFile);
m_audioDeviceManager.initialise(std::numeric_limits<int>::max(), std::numeric_limits<int>::max(), deviceXML.get(), true);
}
#endif
}

void Server::saveDeviceConfig() {
#if JUCE_DEBUG
auto stateXml = m_audioDeviceManager.createStateXml();
auto path = std::filesystem::current_path();
auto savePath = path / "NativeIOSettings.xml";
juce::File deviceXMLFile(savePath.string());
stateXml->writeTo(deviceXMLFile);
#endif
}

void Server::saveConfig() {
Expand Down Expand Up @@ -230,7 +254,7 @@ void Server::saveConfig() {
j["CrashReporting"] = m_crashReporting;
j["SandboxMode"] = m_sandboxMode;
j["SandboxLogAutoclean"] = m_sandboxLogAutoclean;
j["ProcessingTraceTresholdMs"] = m_processingTraceTresholdMs;
j["ProcessingTraceTresholdMs"] = m_processingTraceThresholdMs; //TODO: Fix typo in JSON key

File cfg(Defaults::getConfigFileName(Defaults::ConfigServer, {{"id", String(getId())}}));
logln("saving config to " << cfg.getFullPathName());
Expand Down Expand Up @@ -1197,13 +1221,13 @@ void Server::runServer() {
if (getScreenLocalMode() && Defaults::unixDomainSocketsSupported()) {
auto socketPath = Defaults::getSocketPath(Defaults::SERVER_SOCK, {{"id", String(getId())}}, true);
logln("creating listener " << socketPath.getFullPathName());
if (!m_masterSocketLocal.createListener(socketPath)) {
if (!m_masterSocketLocal.createListener(100, socketPath.getFullPathName())) {
logln("failed to create local master listener");
}
}

logln("creating listener " << (m_host.length() == 0 ? "*" : m_host) << ":" << (m_port + getId()));
if (m_masterSocket.createListener6(m_port + getId(), m_host)) {
if (m_masterSocket.createListener(m_port + getId(), m_host)) {
logln("server started: ID=" << getId() << ", PORT=" << m_port + getId() << ", NAME=" << m_name);
while (!threadShouldExit()) {
StreamingSocket* clnt = nullptr;
Expand Down Expand Up @@ -1287,8 +1311,11 @@ void Server::runServer() {
auto sandbox = std::make_shared<SandboxMaster>(*this, id);
logln("creating sandbox " << id);
if (sandbox->launchWorkerProcess(
File::getSpecialLocation(File::currentExecutableFile), Defaults::SANDBOX_CMD_PREFIX,
{"-id", String(getId()), "-islocal", String((int)isLocal), "-clientid", id}, 3000, 30000)) {
File::getSpecialLocation(File::currentExecutableFile),
Defaults::SANDBOX_CMD_PREFIX,
{"-id", String(getId()), "-islocal", String((int)isLocal), "-clientid", id},
3000,
30000)) {
sandbox->onPortReceived = [this, id, clnt](int sandboxPort) {
traceScope();
if (!sendHandshakeResponse(clnt, true, sandboxPort)) {
Expand Down
Loading