Skip to content

Commit

Permalink
* Renamed vstsynth to vsthost and made a few fixes to it (e.g. dejitt…
Browse files Browse the repository at this point in the history
…ering)
  • Loading branch information
cannam committed Oct 21, 2004
1 parent f486856 commit b99e707
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 131 deletions.
6 changes: 3 additions & 3 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ SPEC_SRCS = $(dssi-vst-server_exe_SPEC_SRCS) $(dssi-vst-scanner_exe_

### Generic autoconf targets

all: apploader $(SUBDIRS) $(DLLS:%=%.so) $(EXES:%=%.so) vstsynth libremoteplugin.a dssi-vst.so
all: apploader $(SUBDIRS) $(DLLS:%=%.so) $(EXES:%=%.so) vsthost libremoteplugin.a dssi-vst.so

apploader: apploader.in
sed -e 's,@bindir\@,$(bindir),g' -e 's,@winelibdir\@,.,g' $(SRCDIR)/apploader.in >$@ || $(RM) $@
Expand Down Expand Up @@ -182,8 +182,8 @@ $(dssi-vst-scanner_exe_MODULE).so: $(dssi-vst-scanner_exe_MODULE).dbg.o $(dssi-v


### Client application
vstsynth: vstsynth.cpp remoteplugin.h remotepluginclient.h remotevstclient.o libremoteplugin.a
g++ -g3 -I/usr/local/include -L/usr/local/lib -Wall vstsynth.cpp remotevstclient.o -o vstsynth -L. -lremoteplugin -ljack -lasound
vsthost: vsthost.cpp remoteplugin.h remotepluginclient.h remotevstclient.o libremoteplugin.a
g++ -g3 -I/usr/local/include -L/usr/local/lib -Wall vsthost.cpp remotevstclient.o -o vsthost -L. -lremoteplugin -ljack -lasound

libremoteplugin.a: remotepluginclient.o remotepluginserver.o rdwrops.o paths.o
ar r $@ $^
Expand Down
160 changes: 92 additions & 68 deletions dssi-vst-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <fcntl.h>
#include <sys/un.h>

#include <sched.h>

#define WIN32_LEAN_AND_MEAN
#include <windows.h>

Expand Down Expand Up @@ -43,7 +45,7 @@ static bool ready = false;
static int bufferSize = 0;
static int sampleRate = 0;

static RemotePluginDebugLevel debugLevel = RemotePluginDebugEvents;
static RemotePluginDebugLevel debugLevel = RemotePluginDebugSetup;

using namespace std;

Expand Down Expand Up @@ -466,6 +468,17 @@ hostCallback(AEffect *plugin, long opcode, long index,
DWORD WINAPI
AudioThreadMain(LPVOID parameter)
{
int policy = SCHED_FIFO;
struct sched_param param;

param.sched_priority = 1;

int result = sched_setscheduler(0, policy, &param);

if (result < 0) {
perror("Failed to set realtime priority for audio thread");
}

while (1) {
try {
remoteVSTServerInstance->dispatch();
Expand Down Expand Up @@ -499,6 +512,7 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow)
{
char *libname = 0;
char *fileInfo = 0;
bool tryGui = false, haveGui = true;

cout << "DSSI VST plugin server v" << RemotePluginVersion << endl;
cout << "Copyright (c) 2004 Chris Cannam - Fervent Software" << endl;
Expand All @@ -508,6 +522,10 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow)
if (cmdline) {
int offset = 0;
if (cmdline[0] == '"' || cmdline[0] == '\'') offset = 1;
if (!strncmp(&cmdline[offset], "-g ", 3)) {
tryGui = true;
offset += 3;
}
for (int ci = offset; cmdline[ci]; ++ci) {
if (cmdline[ci] == ',') {
libname = strndup(cmdline + offset, ci - offset);
Expand Down Expand Up @@ -627,14 +645,16 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow)
cerr << "dssi-vst-server[1]: plugin is a VST" << endl;
}

#ifdef SHOW_GUI
if (!(plugin->flags & effFlagsHasEditor)) {
cerr << "dssi-vst-server: ERROR: Plugin has no GUI (required)" << endl;
return 1;
} else if (debugLevel > 0) {
cerr << "dssi-vst-server[1]: plugin has a GUI" << endl;
if (tryGui) {
if (!(plugin->flags & effFlagsHasEditor)) {
if (debugLevel > 0) {
cerr << "dssi-vst-server[1]: Plugin has no GUI" << endl;
}
haveGui = false;
} else if (debugLevel > 0) {
cerr << "dssi-vst-server[1]: plugin has a GUI" << endl;
}
}
#endif

if (!plugin->flags & effFlagsCanReplacing) {
cerr << "dssi-vst-server: ERROR: Plugin does not support processReplacing (required)"
Expand All @@ -655,72 +675,76 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow)
return 1;
}

// This needs to be an argument:
#ifdef SHOW_GUI

cout << "Initialising Windows subsystem... ";
if (debugLevel > 0) cout << endl;

WNDCLASSEX wclass;
wclass.cbSize = sizeof(WNDCLASSEX);
wclass.style = 0;
wclass.lpfnWndProc = MainProc;
wclass.cbClsExtra = 0;
wclass.cbWndExtra = 0;
wclass.hInstance = hInst;
wclass.hIcon = LoadIcon(hInst, APPLICATION_CLASS_NAME);
wclass.hCursor = LoadCursor(0, IDI_APPLICATION);
wclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wclass.lpszMenuName = "MENU_DSSI_VST";
wclass.lpszClassName = APPLICATION_CLASS_NAME;
wclass.hIconSm = 0;

if (!RegisterClassEx(&wclass)) {
cerr << "dssi-vst-server: ERROR: Failed to register Windows application class!\n" << endl;
return 1;
} else if (debugLevel > 0) {
cerr << "dssi-vst-server[1]: registered Windows application class \"" << APPLICATION_CLASS_NAME << "\"" << endl;
}

hWnd = CreateWindow
(APPLICATION_CLASS_NAME, remoteVSTServerInstance->getName().c_str(),
WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
0, 0, hInst, 0);
if (!hWnd) {
cerr << "dssi-vst-server: ERROR: Failed to create window!\n" << endl;
return 1;
} else if (debugLevel > 0) {
cerr << "dssi-vst-server[1]: created main window" << endl;
}
if (tryGui) {

cout << "Initialising Windows subsystem... ";
if (debugLevel > 0) cout << endl;

WNDCLASSEX wclass;
wclass.cbSize = sizeof(WNDCLASSEX);
wclass.style = 0;
wclass.lpfnWndProc = MainProc;
wclass.cbClsExtra = 0;
wclass.cbWndExtra = 0;
wclass.hInstance = hInst;
wclass.hIcon = LoadIcon(hInst, APPLICATION_CLASS_NAME);
wclass.hCursor = LoadCursor(0, IDI_APPLICATION);
wclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wclass.lpszMenuName = "MENU_DSSI_VST";
wclass.lpszClassName = APPLICATION_CLASS_NAME;
wclass.hIconSm = 0;

if (!RegisterClassEx(&wclass)) {
cerr << "dssi-vst-server: ERROR: Failed to register Windows application class!\n" << endl;
return 1;
} else if (debugLevel > 0) {
cerr << "dssi-vst-server[1]: registered Windows application class \"" << APPLICATION_CLASS_NAME << "\"" << endl;
}

hWnd = CreateWindow
(APPLICATION_CLASS_NAME, remoteVSTServerInstance->getName().c_str(),
WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
0, 0, hInst, 0);
if (!hWnd) {
cerr << "dssi-vst-server: ERROR: Failed to create window!\n" << endl;
return 1;
} else if (debugLevel > 0) {
cerr << "dssi-vst-server[1]: created main window" << endl;
}

plugin->dispatcher(plugin, effEditOpen, 0, 0, hWnd, 0);
Rect *rect = 0;
plugin->dispatcher(plugin, effEditGetRect, 0, 0, &rect, 0);
if (!rect) {
cerr << "dssi-vst-server: ERROR: Plugin failed to report window size\n" << endl;
return 1;
}
if (!haveGui) {
cerr << "Should be showing message here" << endl;
} else {

// Seems we need to provide space in here for the titlebar and frame,
// even though we don't know how big they'll be! How crap.
SetWindowPos(hWnd, 0, 0, 0,
rect->right - rect->left + 6,
rect->bottom - rect->top + 25,
SWP_NOACTIVATE | SWP_NOMOVE |
SWP_NOOWNERZORDER | SWP_NOZORDER);
plugin->dispatcher(plugin, effEditOpen, 0, 0, hWnd, 0);
Rect *rect = 0;
plugin->dispatcher(plugin, effEditGetRect, 0, 0, &rect, 0);
if (!rect) {
cerr << "dssi-vst-server: ERROR: Plugin failed to report window size\n" << endl;
return 1;
}

if (debugLevel > 0) {
cerr << "dssi-vst-server[1]: sized window" << endl;
}
// Seems we need to provide space in here for the titlebar and frame,
// even though we don't know how big they'll be! How crap.
SetWindowPos(hWnd, 0, 0, 0,
rect->right - rect->left + 6,
rect->bottom - rect->top + 25,
SWP_NOACTIVATE | SWP_NOMOVE |
SWP_NOOWNERZORDER | SWP_NOZORDER);

if (debugLevel > 0) {
cerr << "dssi-vst-server[1]: sized window" << endl;
}
}

ShowWindow(hWnd, SW_SHOWNORMAL);
UpdateWindow(hWnd);
ShowWindow(hWnd, SW_SHOWNORMAL);
UpdateWindow(hWnd);

if (debugLevel > 0) {
cerr << "dssi-vst-server[1]: showed window" << endl;
if (debugLevel > 0) {
cerr << "dssi-vst-server[1]: showed window" << endl;
}
}
#endif

cout << "done" << endl;

Expand Down
18 changes: 9 additions & 9 deletions dssi-vst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,33 +242,33 @@ DSSIVSTPluginInstance::deactivate()
void
DSSIVSTPluginInstance::connectPort(unsigned long port, LADSPA_Data *location)
{
std::cerr << "connectPort(" << port << "," << location << ")" << std::endl;
// std::cerr << "connectPort(" << port << "," << location << ")" << std::endl;

if (!m_ok) return;

if (port < m_controlPortCount) {
std::cerr << "(control port)" << std::endl;
// std::cerr << "(control port)" << std::endl;
m_controlPorts[port] = location;
return;
}
port -= m_controlPortCount;

if (port < m_audioInCount) {
std::cerr << "(audio in port)" << std::endl;
// std::cerr << "(audio in port)" << std::endl;
m_audioIns[port] = location;
return;
}
port -= m_audioInCount;

if (port < m_audioOutCount) {
std::cerr << "(audio out port)" << std::endl;
// std::cerr << "(audio out port)" << std::endl;
m_audioOuts[port] = location;
return;
}
port -= m_audioOutCount;

if (port < 1) { // latency
std::cerr << "(latency output port)" << std::endl;
// std::cerr << "(latency output port)" << std::endl;
m_latencyOut = location;
if (m_latencyOut) *m_latencyOut = 0;
return;
Expand Down Expand Up @@ -434,7 +434,7 @@ DSSIVSTPlugin::DSSIVSTPlugin()
ldesc->Maker = strdup(rec.vendorName.c_str());
ldesc->Copyright = strdup(ldesc->Maker);

std::cerr << "Plugin name: " << ldesc->Name << std::endl;
// std::cerr << "Plugin name: " << ldesc->Name << std::endl;

int parameters = rec.parameters;
int inputs = rec.inputs;
Expand Down Expand Up @@ -537,9 +537,9 @@ DSSI_Descriptor *
DSSIVSTPlugin::queryDescriptor(unsigned long index)
{
if (index < m_descriptors.size()) {
std::cerr << "DSSIVSTPlugin::queryDescriptor: index is " << index
<< ", returning " << m_descriptors[index].second->LADSPA_Plugin->Name
<< std::endl;
// std::cerr << "DSSIVSTPlugin::queryDescriptor: index is " << index
// << ", returning " << m_descriptors[index].second->LADSPA_Plugin->Name
// << std::endl;
return m_descriptors[index].second;
} else {
return 0;
Expand Down
4 changes: 3 additions & 1 deletion remotevstclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
#include "rdwrops.h"
#include "paths.h"

RemoteVSTClient::RemoteVSTClient(std::string dllName) :
RemoteVSTClient::RemoteVSTClient(std::string dllName, bool showGUI) :
RemotePluginClient()
{
pid_t child;
std::string arg = dllName + "," + getFileIdentifiers();
if (showGUI) arg = "-g " + arg;

const char *argStr = arg.c_str();

// We want to run the dssi-vst-server script, which runs wine
Expand Down
2 changes: 1 addition & 1 deletion remotevstclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class RemoteVSTClient : public RemotePluginClient
{
public:
// may throw a string exception
RemoteVSTClient(std::string dllName);
RemoteVSTClient(std::string dllName, bool showGUI = false);

virtual ~RemoteVSTClient();

Expand Down
Loading

0 comments on commit b99e707

Please sign in to comment.