summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-04-28 04:06:13 +0000
committerDavid Robillard <d@drobilla.net>2012-04-28 04:06:13 +0000
commitd87914716181bd86a3a68b22d3d0a12902860be0 (patch)
tree254f52e380011a03f5094558998b1f9072869341 /src
parentb255d11ae5117a6fdb35abdcef5dea2a3c0a6ee3 (diff)
downloadingen-d87914716181bd86a3a68b22d3d0a12902860be0.tar.gz
ingen-d87914716181bd86a3a68b22d3d0a12902860be0.tar.bz2
ingen-d87914716181bd86a3a68b22d3d0a12902860be0.zip
Gracefully handle UI communication ring overflow.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4296 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/server/ingen_lv2.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp
index cb144c49..21f1299d 100644
--- a/src/server/ingen_lv2.cpp
+++ b/src/server/ingen_lv2.cpp
@@ -147,11 +147,13 @@ public:
, _writer(*engine.world()->lv2_uri_map().get(),
*engine.world()->uris().get(),
*this)
- , _to_ui(32768) // FIXME: size
+ , _to_ui(buffer_size * sizeof(float)) // FIXME: size
, _root_patch(NULL)
, _buffer_size(buffer_size)
, _sample_rate(sample_rate)
, _frame_time(0)
+ , _to_ui_overflow_sem(0)
+ , _to_ui_overflow(false)
{}
void run(uint32_t nframes) {
@@ -216,8 +218,11 @@ public:
void write(const LV2_Atom* atom) {
// Called from post-processor in main thread
- if (_to_ui.write(lv2_atom_total_size(atom), atom) == 0) {
- Raul::error << "To-UI ring overflow" << std::endl;
+ while (_to_ui.write(lv2_atom_total_size(atom), atom) == 0) {
+ // Overflow, wait until ring is drained next cycle
+ _to_ui_overflow = true;
+ _to_ui_overflow_sem.wait();
+ _to_ui_overflow = false;
}
}
@@ -227,7 +232,7 @@ public:
LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)_ports[1]->buffer();
if (!seq) {
- Raul::warn << "Control out port not connected" << std::endl;
+ Raul::error << "Control out port not connected" << std::endl;
return;
}
@@ -265,6 +270,8 @@ public:
read += lv2_atom_total_size(&ev->body);
seq->atom.size += sizeof(LV2_Atom_Event) + ev->body.size;
}
+
+ _to_ui_overflow_sem.post();
}
virtual SampleCount block_length() const { return _buffer_size; }
@@ -288,6 +295,8 @@ private:
SampleCount _sample_rate;
SampleCount _frame_time;
Ports _ports;
+ Raul::Semaphore _to_ui_overflow_sem;
+ bool _to_ui_overflow;
};
void