Skip to content

Commit 528067b

Browse files
committed
clap: avoid thread warning when deactivating.
1 parent 709eee3 commit 528067b

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎src/engine/clapprovider.cpp‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,8 +1514,13 @@ class CLAPProcessor : public Processor,
15141514
return;
15151515
if (_activated)
15161516
{
1517+
// Hold off any in-flight render() so stopProcessing() has the
1518+
// audio-thread concurrency guarantee, then deactivate [main-thread].
1519+
_processLock.lock();
15171520
stopProcessing();
15181521
_plugin->deactivate (_plugin);
1522+
_activated = false;
1523+
_processLock.unlock();
15191524
}
15201525
_activated = false;
15211526
_tmpAudio.setSize (1, 1);
@@ -1538,7 +1543,16 @@ class CLAPProcessor : public Processor,
15381543
{
15391544
if (_processing)
15401545
{
1546+
// stop_processing is [audio-thread]. CLAP's audio-thread is symbolic:
1547+
// the host may designate any thread as THE audio thread as long as it
1548+
// holds the concurrency guard (no concurrent render()); callers here do
1549+
// (_processLock). Report that to the plugin's thread-check for the
1550+
// duration of the call, then restore — the deactivate that typically
1551+
// follows is [main-thread].
1552+
const auto prev = gThreadType;
1553+
gThreadType = ThreadType::AudioThread;
15411554
_plugin->stop_processing (_plugin);
1555+
gThreadType = prev;
15421556
_processing = false;
15431557
}
15441558
}

0 commit comments

Comments
 (0)