Skip to content

Commit

Permalink
* Be a bit more circumspect about runSynth when not m_ok
Browse files Browse the repository at this point in the history
  • Loading branch information
cannam committed Dec 3, 2004
1 parent 06ebb5b commit db8485e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 23 deletions.
1 change: 1 addition & 0 deletions dssi-vst-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,7 @@ AudioThreadMain(LPVOID parameter)
struct sched_param param;
param.sched_priority = 1;
HANDLE watchdogThreadHandle;

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

if (result < 0) {
Expand Down
52 changes: 29 additions & 23 deletions dssi-vst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ DSSIVSTPluginInstance::DSSIVSTPluginInstance(std::string dllName,
snd_midi_event_no_status(m_alsaDecoder, 1);
}

std::cerr << "DSSIVSTPluginInstance(" << this << "): setting OK true" << std::endl;

m_ok = true;

} catch (RemotePluginClosedException) {
Expand All @@ -195,6 +197,8 @@ DSSIVSTPluginInstance::DSSIVSTPluginInstance(std::string dllName,
delete m_audioIns; m_audioIns = 0;
delete m_audioOuts; m_audioOuts = 0;
}

std::cerr << "DSSIVSTPluginInstance::DSSIVSTPluginInstance(" << dllName << ") construction complete" << std::endl;
}

DSSIVSTPluginInstance::~DSSIVSTPluginInstance()
Expand Down Expand Up @@ -317,41 +321,43 @@ DSSIVSTPluginInstance::selectProgram(unsigned long bank, unsigned long program)
void
DSSIVSTPluginInstance::run(unsigned long sampleCount)
{
if (m_ok) {
try {
if (sampleCount != m_lastSampleCount) {
m_plugin->setBufferSize(sampleCount);
m_lastSampleCount = sampleCount;
if (m_latencyOut) *m_latencyOut = sampleCount;
}

int modifiedCount = 0;

for (unsigned long i = 0; i < m_controlPortCount; ++i) {

if (!m_controlPorts[i]) continue;
if (!m_ok) return;

if (m_controlPortsSaved[i] != *m_controlPorts[i]) {
try {
if (sampleCount != m_lastSampleCount) {
m_plugin->setBufferSize(sampleCount);
m_lastSampleCount = sampleCount;
if (m_latencyOut) *m_latencyOut = sampleCount;
}

int modifiedCount = 0;

for (unsigned long i = 0; i < m_controlPortCount; ++i) {

if (!m_controlPorts[i]) continue;

if (m_controlPortsSaved[i] != *m_controlPorts[i]) {
// std::cout << "Sending new value " << *m_controlPorts[i]
// << " for control port " << i << std::endl;
m_plugin->setParameter(i, *m_controlPorts[i]);
m_controlPortsSaved[i] = *m_controlPorts[i];
if (++modifiedCount > 10) break;
}
m_plugin->setParameter(i, *m_controlPorts[i]);
m_controlPortsSaved[i] = *m_controlPorts[i];
if (++modifiedCount > 10) break;
}

m_plugin->process(m_audioIns, m_audioOuts);

} catch (RemotePluginClosedException) {
m_ok = false;
}

m_plugin->process(m_audioIns, m_audioOuts);

} catch (RemotePluginClosedException) {
m_ok = false;
}
}

void
DSSIVSTPluginInstance::runSynth(unsigned long sampleCount,
snd_seq_event_t *events, unsigned long eventCount)
{
if (!m_ok) return;

try {
if (m_alsaDecoder) {

Expand Down

0 comments on commit db8485e

Please sign in to comment.