# Audio plugin host

**URL:** <https://forum.juce.com/t/audio-plugin-host/9570>\
**Category:** Linux\
**Created:** [November 16, 2012, 6:26am UTC](https://forum.juce.com/t/audio-plugin-host/9570 "2012-11-16T06:26:24Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![rory](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rory/32/534_2.png) [@rory](https://forum.juce.com/u/rory)\
**Post date:** [November 16, 2012, 6:26am UTC](https://forum.juce.com/t/audio-plugin-host/9570/1 "2012-11-16T06:26:24Z")

</div>

I’m getting build errors when I try to run make on the Audio plugin host? I updated my Juce tip yesterday. Any ideas?

Compiling juce\_audio\_processors.cpp  
In file included from …/…/…/…/modules/juce\_audio\_processors/juce\_audio\_processors.cpp:74:0:  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:1479:44: warning: multi-character character constant [-Wmultichar]  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:1479:84: warning: multi-character character constant [-Wmultichar]  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:1483:40: warning: multi-character character constant [-Wmultichar]  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:1519:45: warning: multi-character character constant [-Wmultichar]  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:1524:48: warning: multi-character character constant [-Wmultichar]  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:1532:45: warning: multi-character character constant [-Wmultichar]  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:1532:82: warning: multi-character character constant [-Wmultichar]  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:1542:45: warning: multi-character character constant [-Wmultichar]  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:1542:82: warning: multi-character character constant [-Wmultichar]  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:1578:45: warning: multi-character character constant [-Wmultichar]  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:1580:42: warning: multi-character character constant [-Wmultichar]  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:1595:45: warning: multi-character character constant [-Wmultichar]  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:1597:42: warning: multi-character character constant [-Wmultichar]  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:1617:45: warning: multi-character character constant [-Wmultichar]  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:1619:42: warning: multi-character character constant [-Wmultichar]  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:1710:44: warning: multi-character character constant [-Wmultichar]  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:1710:82: warning: multi-character character constant [-Wmultichar]  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:1753:38: warning: multi-character character constant [-Wmultichar]  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:1755:35: warning: multi-character character constant [-Wmultichar]  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp: In static member function ‘static juce::String juce::ModuleHandle::getDLLResource(const juce::File&, const juce::String&, int)’:  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:460:9: error: ‘HMODULE’ was not declared in this scope  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:460:17: error: expected ‘;’ before ‘dllModule’  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:462:13: error: ‘dllModule’ was not declared in this scope  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:462:26: error: ‘INVALID\_HANDLE\_VALUE’ was not declared in this scope  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:464:13: error: ‘HRSRC’ was not declared in this scope  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:464:19: error: expected ‘;’ before ‘res’  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:466:17: error: ‘res’ was not declared in this scope  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:468:17: error: ‘HGLOBAL’ was not declared in this scope  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:468:25: error: expected ‘;’ before ‘hGlob’  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:470:21: error: ‘hGlob’ was not declared in this scope  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:472:86: error: ‘LockResource’ was not declared in this scope  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:473:82: error: ‘SizeofResource’ was not declared in this scope  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp: In member function ‘void juce::VSTPluginWindow::openPluginWindow()’:  
…/…/…/…/modules/juce\_audio\_processors/format\_types/juce\_VSTPluginFormat.cpp:2296:108: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]  
make: \*\*\* [build/intermediate/Debug/juce\_audio\_processors\_eb9ae116.o] Error 1

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 16, 2012, 10:32am UTC](https://forum.juce.com/t/audio-plugin-host/9570/2 "2012-11-16T10:32:04Z")

</div>

Sorry, I don’t actively test the linux VST build myself. But I’ve checked in some changes that should hopefully fix this (untested).

---

<div class="post-metadata">

**Author:** ![rory](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rory/32/534_2.png) [@rory](https://forum.juce.com/u/rory)\
**Post date:** [November 16, 2012, 7:12pm UTC](https://forum.juce.com/t/audio-plugin-host/9570/3 "2012-11-16T19:12:17Z")

</div>

It builds fine now, thanks for your quick fix.

---

<div class="post-metadata">

**Author:** ![rory](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rory/32/534_2.png) [@rory](https://forum.juce.com/u/rory)\
**Post date:** [November 16, 2012, 7:39pm UTC](https://forum.juce.com/t/audio-plugin-host/9570/4 "2012-11-16T19:39:25Z")

</div>

Builds fine, but crashes on startup:

Builds/Linux/build$ gdb PluginHost  
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2) 7.4-2012.04  
Copyright © 2012 Free Software Foundation, Inc.  
License GPLv3+: GNU GPL version 3 or later [http://gnu.org/licenses/gpl.html](http://gnu.org/licenses/gpl.html)  
This is free software: you are free to change and redistribute it.  
There is NO WARRANTY, to the extent permitted by law. Type "show copying"  
and “show warranty” for details.  
This GDB was configured as “x86\_64-linux-gnu”.  
For bug reporting instructions, please see:  
[http://bugs.launchpad.net/gdb-linaro/](http://bugs.launchpad.net/gdb-linaro/)…  
Reading symbols from /home/rory/Sourcecode/julianstorer-JUCE-f02f1c3/extras/audio plugin host/Builds/Linux/build/PluginHost…done.  
(gdb) run  
Starting program: /home/rory/Sourcecode/julianstorer-JUCE-f02f1c3/extras/audio plugin host/Builds/Linux/build/PluginHost  
[Thread debugging using libthread\_db enabled]  
Using host libthread\_db library “/lib/x86\_64-linux-gnu/libthread\_db.so.1”.  
JUCE v2.0.28  
ALSA device: hw:PCH,0 outs=2-2 ins=2-2 rates=4  
ALSA device: hw:PCH,3 outs=2-8 ins=0-0 rates=7  
ALSA device: hw:PCH,7 outs=2-8 ins=0-0 rates=7  
ALSA device: hw:PCH,8 outs=2-8 ins=0-0 rates=7  
ALSA device: hw:UA25,0 outs=2-2 ins=2-2 rates=1  
[New Thread 0x7ffff252d700 (LWP 4965)]

Program received signal SIGSEGV, Segmentation fault.  
0x00000000005eff14 in juce::Component::sendMovedResizedMessages (  
this=0x7ffff7f4a818, wasMoved=false, wasResized=true)  
at …/…/…/…/modules/juce\_gui\_basics/components/juce\_Component.cpp:1071  
1071 resized();  
(gdb) bt  
#0 0x00000000005eff14 in juce::Component::sendMovedResizedMessages (  
this=0x7ffff7f4a818, wasMoved=false, wasResized=true)  
at …/…/…/…/modules/juce\_gui\_basics/components/juce\_Component.cpp:1071  
#1 0x00000000005efe92 in juce::Component::setBounds (this=0x7ffff7f4a818,  
x=0, y=0, w=792, h=506)  
at …/…/…/…/modules/juce\_gui\_basics/components/juce\_Component.cpp:1053  
#2 0x000000000040e578 in GraphDocumentComponent::resized (this=0xab2ae0)  
at …/…/Source/GraphEditorPanel.cpp:1054  
#3 0x00000000005eff20 in juce::Component::sendMovedResizedMessages (  
this=0xab2ae0, wasMoved=true, wasResized=true)  
at …/…/…/…/modules/juce\_gui\_basics/components/juce\_Component.cpp:1071  
#4 0x00000000005efe92 in juce::Component::setBounds (this=0xab2ae0, x=4,  
y=30, w=792, h=566)  
at …/…/…/…/modules/juce\_gui\_basics/components/juce\_Component.cpp:1053  
#5 0x00000000005f01f1 in juce::Component::setBounds (this=0xab2ae0, r=…)  
at …/…/…/…/modules/juce\_gui\_basics/components/juce\_Component.cpp:1117  
#6 0x00000000005f04ec in juce::Component::setBoundsInset (this=0xab2ae0,  
borders=…)  
at …/…/…/…/modules/juce\_gui\_basics/components/juce\_Component.cpp:1165  
#7 0x000000000067069c in juce::ResizableWindow::resized (this=0xa93330)  
at …/…/…/…/modules/juce\_gui\_basics/windows/juce\_ResizableWindow.cpp:234  
#8 0x000000000066ed8d in juce::DocumentWindow::resized (this=0xa93330)  
at …/…/…/…/modules/juce\_gui\_basics/windows/juce\_DocumentWindow.cpp:233  
—Type to continue, or q to quit—  
#9 0x00000000006700f7 in juce::ResizableWindow::setContent (this=0xa93330,  
newContentComponent=0xab2ae0, takeOwnership=true,  
resizeToFitWhenContentChangesSize=false)  
at …/…/…/…/modules/juce\_gui\_basics/windows/juce\_ResizableWindow.cpp:132  
#10 0x000000000067012e in juce::ResizableWindow::setContentOwned (  
this=0xa93330, newContentComponent=0xab2ae0,  
resizeToFitWhenContentChangesSize=false)  
at …/…/…/…/modules/juce\_gui\_basics/windows/juce\_ResizableWindow.cpp:137  
#11 0x0000000000414e30 in MainHostWindow::MainHostWindow (this=0xa93330)  
at …/…/Source/MainHostWindow.cpp:91  
#12 0x0000000000413c70 in PluginHostApp::initialise (this=0xa91760,  
commandLine=…) at …/…/Source/HostStartup.cpp:62  
#13 0x00000000006778a0 in juce::JUCEApplication::initialiseApp (this=0xa91760)  
at …/…/…/…/modules/juce\_gui\_basics/application/juce\_Application.cpp:181  
#14 0x0000000000677b7a in juce::JUCEApplication::main ()  
at …/…/…/…/modules/juce\_gui\_basics/application/juce\_Application.cpp:236  
#15 0x0000000000677db0 in juce::JUCEApplication::main (argc=1,  
argv=0x7fffffffe1d8)  
at …/…/…/…/modules/juce\_gui\_basics/application/juce\_Application.cpp:297  
#16 0x00000000004139c9 in main (argc=1, argv=0x7fffffffe1d8)  
at …/…/Source/HostStartup.cpp:107

---

<div class="post-metadata">

**Author:** ![grebneke](https://avatars.discourse-cdn.com/v4/letter/g/a183cd/32.png) [@grebneke](https://forum.juce.com/u/grebneke)\
**Post date:** [November 16, 2012, 8:20pm UTC](https://forum.juce.com/t/audio-plugin-host/9570/5 "2012-11-16T20:20:52Z")

</div>

I tried to replicate. For me, it works fine when jackd is running. Without jackd I get a crash, but different from yours.

Did you try with jackd on/off?

[code]gdb Builds/Linux/build/Plugin\ Host  
GNU gdb (Ubuntu/Linaro 7.2-1ubuntu11) 7.2  
Copyright © 2010 Free Software Foundation, Inc.  
License GPLv3+: GNU GPL version 3 or later [http://gnu.org/licenses/gpl.html](http://gnu.org/licenses/gpl.html)  
This is free software: you are free to change and redistribute it.  
There is NO WARRANTY, to the extent permitted by law. Type "show copying"  
and “show warranty” for details.  
This GDB was configured as “x86\_64-linux-gnu”.  
For bug reporting instructions, please see:  
[http://www.gnu.org/software/gdb/bugs/](http://www.gnu.org/software/gdb/bugs/)…  
Reading symbols from /home/johan/projects/audio/juce/extras/audio plugin host/Builds/Linux/build/Plugin Host…done.  
(gdb) run  
Starting program: /home/johan/projects/audio/juce/extras/audio plugin host/Builds/Linux/build/Plugin Host  
[Thread debugging using libthread\_db enabled]  
JUCE v2.0.28  
ALSA device: hw:PCH,0 outs=2-6 ins=2-2 rates=4  
ALSA device: hw:PCH,1 outs=0-0 ins=0-0 rates=0  
[New Thread 0x7ffff25f0700 (LWP 976)]

Program received signal SIGSEGV, Segmentation fault.  
0x0000000000000000 in ?? ()  
(gdb) bt  
#0 0x0000000000000000 in ?? ()  
#1 0x00000000005f3745 in juce::Component::internalHierarchyChanged (this=0xae8d10) at …/…/…/…/modules/juce\_gui\_basics/components/juce\_Component.cpp:1550  
#2 0x00000000005f37d8 in juce::Component::internalHierarchyChanged (this=0xae32e0) at …/…/…/…/modules/juce\_gui\_basics/components/juce\_Component.cpp:1562  
#3 0x00000000005f37d8 in juce::Component::internalHierarchyChanged (this=0xae79d0) at …/…/…/…/modules/juce\_gui\_basics/components/juce\_Component.cpp:1562  
#4 0x00000000005f3031 in juce::Component::addChildComponent (this=0xa97990, child=0xae79d0, zOrder=4) at …/…/…/…/modules/juce\_gui\_basics/components/juce\_Component.cpp:1373  
#5 0x00000000005f308c in juce::Component::addAndMakeVisible (this=0xa97990, child=0xae79d0, zOrder=-1) at …/…/…/…/modules/juce\_gui\_basics/components/juce\_Component.cpp:1383  
#6 0x00000000006727fb in juce::ResizableWindow::setContent (this=0xa97990, newContentComponent=0xae79d0, takeOwnership=true, resizeToFitWhenContentChangesSize=false) at …/…/…/…/modules/juce\_gui\_basics/windows/juce\_ResizableWindow.cpp:123  
#7 0x000000000067289e in juce::ResizableWindow::setContentOwned (this=0xa97990, newContentComponent=0xae79d0, resizeToFitWhenContentChangesSize=false) at …/…/…/…/modules/juce\_gui\_basics/windows/juce\_ResizableWindow.cpp:137  
#8 0x0000000000414f2a in MainHostWindow::MainHostWindow (this=0xa97990) at …/…/Source/MainHostWindow.cpp:91  
#9 0x0000000000413d27 in PluginHostApp::initialise (this=0xa96820, commandLine=…) at …/…/Source/HostStartup.cpp:62  
#10 0x000000000067a058 in juce::JUCEApplication::initialiseApp (this=0xa96820) at …/…/…/…/modules/juce\_gui\_basics/application/juce\_Application.cpp:181  
#11 0x000000000067a332 in juce::JUCEApplication::main () at …/…/…/…/modules/juce\_gui\_basics/application/juce\_Application.cpp:236  
#12 0x000000000067a56e in juce::JUCEApplication::main (argc=1, argv=0x7fffffffe578) at …/…/…/…/modules/juce\_gui\_basics/application/juce\_Application.cpp:297  
#13 0x0000000000413a70 in main (argc=1, argv=0x7fffffffe578) at …/…/Source/HostStartup.cpp:107

[/code]

---

<div class="post-metadata">

**Author:** ![grebneke](https://avatars.discourse-cdn.com/v4/letter/g/a183cd/32.png) [@grebneke](https://forum.juce.com/u/grebneke)\
**Post date:** [November 18, 2012, 1:25pm UTC](https://forum.juce.com/t/audio-plugin-host/9570/6 "2012-11-18T13:25:17Z")

</div>

Please see post [http://www.rawmaterialsoftware.com/viewtopic.php?f=5&t=10392](http://www.rawmaterialsoftware.com/viewtopic.php?f=5&t=10392), that fix also seems to solve the audio plugin host problem, at least everything works for me now.

---

<div class="post-metadata">

**Author:** ![rory](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rory/32/534_2.png) [@rory](https://forum.juce.com/u/rory)\
**Post date:** [November 20, 2012, 10:50pm UTC](https://forum.juce.com/t/audio-plugin-host/9570/7 "2012-11-20T22:50:32Z")

</div>

Unfortunately that fix doesn’t work for me. But now I get a different flavoured crash.

(gdb) run  
Starting program: /home/rory/Sourcecode/julianstorer-JUCE-a971f93/extras/audio plugin host/Builds/Linux/build/Plugin Host  
[Thread debugging using libthread\_db enabled]  
Using host libthread\_db library “/lib/x86\_64-linux-gnu/libthread\_db.so.1”.  
JUCE v2.0.28  
[New Thread 0x7ffff43fc700 (LWP 11365)]  
[Thread 0x7ffff43fc700 (LWP 11365) exited]  
ALSA device: hw:PCH,0 outs=2-2 ins=2-2 rates=4  
ALSA device: hw:PCH,3 outs=2-8 ins=0-0 rates=7  
ALSA device: hw:PCH,7 outs=2-8 ins=0-0 rates=7  
ALSA device: hw:PCH,8 outs=2-8 ins=0-0 rates=7  
ALSA device: hw:UA25,0 outs=0-0 ins=0-0 rates=0  
[New Thread 0x7ffff43fc700 (LWP 11368)]

Program received signal SIGSEGV, Segmentation fault.  
0x0000000000000000 in ?? ()  
(gdb) bt  
#0 0x0000000000000000 in ?? ()  
#1 0x00000000005f4e49 in juce::Component::internalHierarchyChanged (  
this=0xabaa70)  
at …/…/…/…/modules/juce\_gui\_basics/components/juce\_Component.cpp:1556  
#2 0x00000000005f4edc in juce::Component::internalHierarchyChanged (  
this=0xabcd30)  
at …/…/…/…/modules/juce\_gui\_basics/components/juce\_Component.cpp:1568  
#3 0x00000000005f4edc in juce::Component::internalHierarchyChanged (  
this=0xab9730)  
at …/…/…/…/modules/juce\_gui\_basics/components/juce\_Component.cpp:1568  
#4 0x00000000005f4735 in juce::Component::addChildComponent (this=0xa99330,  
child=0xab9730, zOrder=4)  
at …/…/…/…/modules/juce\_gui\_basics/components/juce\_Component.cpp:1379  
#5 0x00000000005f4790 in juce::Component::addAndMakeVisible (this=0xa99330,  
child=0xab9730, zOrder=-1)  
at …/…/…/…/modules/juce\_gui\_basics/components/juce\_Component.cpp:1389  
#6 0x00000000006736f1 in juce::ResizableWindow::setContent (this=0xa99330,  
newContentComponent=0xab9730, takeOwnership=true,  
resizeToFitWhenContentChangesSize=false)  
at …/…/…/…/modules/juce\_gui\_basics/windows/juce\_ResizableWindow.cpp:123  
#7 0x0000000000673794 in juce::ResizableWindow::setContentOwned (  
this=0xa99330, newContentComponent=0xab9730,  
resizeToFitWhenContentChangesSize=false)  
—Type to continue, or q to quit—  
at …/…/…/…/modules/juce\_gui\_basics/windows/juce\_ResizableWindow.cpp:137  
#8 0x0000000000414e30 in MainHostWindow::MainHostWindow (this=0xa99330)  
at …/…/Source/MainHostWindow.cpp:91  
#9 0x0000000000413c70 in PluginHostApp::initialise (this=0xa97760,  
commandLine=…) at …/…/Source/HostStartup.cpp:62  
#10 0x000000000067af06 in juce::JUCEApplication::initialiseApp (this=0xa97760)  
at …/…/…/…/modules/juce\_gui\_basics/application/juce\_Application.cpp:181  
#11 0x000000000067b1e0 in juce::JUCEApplication::main ()  
at …/…/…/…/modules/juce\_gui\_basics/application/juce\_Application.cpp:236  
#12 0x000000000067b416 in juce::JUCEApplication::main (argc=1,  
argv=0x7fffffffe1d8)  
at …/…/…/…/modules/juce\_gui\_basics/application/juce\_Application.cpp:297  
#13 0x00000000004139c9 in main (argc=1, argv=0x7fffffffe1d8)  
at …/…/Source/HostStartup.cpp:107

---

<div class="post-metadata">

**Author:** ![grebneke](https://avatars.discourse-cdn.com/v4/letter/g/a183cd/32.png) [@grebneke](https://forum.juce.com/u/grebneke)\
**Post date:** [November 21, 2012, 7:35am UTC](https://forum.juce.com/t/audio-plugin-host/9570/8 "2012-11-21T07:35:05Z")

</div>

That looks exactly like what I had before. To come further, I had to look at all threads:

```auto

```

Please clarify: is this using ALSA or JACK or both? Does any of them work?

---

<div class="post-metadata">

**Author:** ![grebneke](https://avatars.discourse-cdn.com/v4/letter/g/a183cd/32.png) [@grebneke](https://forum.juce.com/u/grebneke)\
**Post date:** [November 21, 2012, 8:03am UTC](https://forum.juce.com/t/audio-plugin-host/9570/9 "2012-11-21T08:03:50Z")

</div>

Ok, reproduced the same as Rory with git tip, a971f93.

No crashes after commenting out the audioDeviceIOCallback call in juce\_linux\_ALSA.cpp around line 570. Will assume it’s ALSA related. Will try to debug later today or tomorrow.

Rory: you could help by enabling JACK in the build (Introjucer) and test, to see if it works with JACK.

---

<div class="post-metadata">

**Author:** ![grebneke](https://avatars.discourse-cdn.com/v4/letter/g/a183cd/32.png) [@grebneke](https://forum.juce.com/u/grebneke)\
**Post date:** [November 22, 2012, 12:52am UTC](https://forum.juce.com/t/audio-plugin-host/9570/10 "2012-11-22T00:52:00Z")

</div>

The problem might not be ALSA at all but a bug in audio plugin host:

MainHostWindow.cpp initialises deviceManager with 256 in and 256 out channels.  
juce\_AudioProcessorPlayer.h defines a float\* channels [128].  
juce\_AudioProcessorPlayer.cpp: AudioProcessorPlayer::audioDeviceIOCallback starts pushing all input and output channels to the float\* array of size 128.  
For some reason, ALSA actually gives you all the requested 256 input devices + 2 output, at least on my system. So we get memory corruption when data is written beyond the end off float\* channels[128]

This explains why the bug only hits with ALSA, and why I was getting all sorts of weird results when putting debug statements in the code, and why the backtraces don’t make sense.

Rory: please try with the patch below. Patched files also attached.

[code]diff --git a/modules/juce\_audio\_utils/players/juce\_AudioProcessorPlayer.cpp b/modules/juce\_audio\_utils/players/juce\_AudioProcessorPlayer.cpp  
index ff3a4a4…a160456 100644  
— a/modules/juce\_audio\_utils/players/juce\_AudioProcessorPlayer.cpp  
+++ b/modules/juce\_audio\_utils/players/juce\_AudioProcessorPlayer.cpp  
@@ -149,6 +149,8 @@ void AudioProcessorPlayer::prepareToPlay (double newSampleRate, int newBlockSize  
numInputChans = numChansIn;  
numOutputChans = numChansOut;

- jassert(numInputChans + numOutputChans \<= MaxNumChannels);
- messageCollector.reset (sampleRate);  
zeromem (channels, sizeof (channels));

diff --git a/modules/juce\_audio\_utils/players/juce\_AudioProcessorPlayer.h b/modules/juce\_audio\_utils/players/juce\_AudioProcessorPlayer.h  
index 56b2de0…a378cfb 100644  
— a/modules/juce\_audio\_utils/players/juce\_AudioProcessorPlayer.h  
+++ b/modules/juce\_audio\_utils/players/juce\_AudioProcessorPlayer.h  
@@ -94,7 +94,8 @@ private:  
bool isPrepared;

```
 int numInputChans, numOutputChans;

```

- float\* channels [128];

- enum { MaxNumChannels = 128 };

- float\* channels [MaxNumChannels];  
AudioSampleBuffer tempBuffer;

- deviceManager.initialise (256, 256, savedAudioState, true);

- deviceManager.initialise (64, 64, savedAudioState, true);

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 22, 2012, 2:45pm UTC](https://forum.juce.com/t/audio-plugin-host/9570/11 "2012-11-22T14:45:43Z")

</div>

Oh, that’s a nasty looking fixed-size array. Thanks, I’ll make that more flexible.

---

<div class="post-metadata">

**Author:** ![rory](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rory/32/534_2.png) [@rory](https://forum.juce.com/u/rory)\
**Post date:** [November 22, 2012, 4:06pm UTC](https://forum.juce.com/t/audio-plugin-host/9570/12 "2012-11-22T16:06:18Z")

</div>

Great, that did the trick. Only strange thing is that the the default audio IO processors in the host now have 64 inputs and 64 outputs? I had to use the fix you provided for jack in an earlier post. It doesn’t look like Jules has had time to add your changes to git yet. Thanks for this.

Rory.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 22, 2012, 5:30pm UTC](https://forum.juce.com/t/audio-plugin-host/9570/13 "2012-11-22T17:30:24Z")

</div>

Yeah, I’ve done the jack stuff too. Let me know if there’s anything missing.

---

<div class="post-metadata">

**Author:** ![rory](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rory/32/534_2.png) [@rory](https://forum.juce.com/u/rory)\
**Post date:** [November 22, 2012, 6:33pm UTC](https://forum.juce.com/t/audio-plugin-host/9570/14 "2012-11-22T18:33:43Z")

</div>

thanks. looks to build and run now without any issues, apart from the default IO filters in the graph having 64 inputs and outputs. they’re just showing off I think.

---

<div class="post-metadata">

**Author:** ![grebneke](https://avatars.discourse-cdn.com/v4/letter/g/a183cd/32.png) [@grebneke](https://forum.juce.com/u/grebneke)\
**Post date:** [November 22, 2012, 11:43pm UTC](https://forum.juce.com/t/audio-plugin-host/9570/15 "2012-11-22T23:43:10Z")

</div>

> [@jules](#):
>
> Yeah, I’ve done the jack stuff too. Let me know if there’s anything missing.

Looking at juce\_linux\_JackAudio.cpp, I see my comment still there; it was meant as a question to you - is there any point in keeping it in the code? :? And do you know the answer?

[quote]+ void updateActivePorts()

- {
- 

```
   // This function is called on open(), and from jack as callback on external

```

- 

```
   // jack port changes. Jules, is there any risk that this can happen in a

```

- 

```
   // separate thread from the audio thread, meaning we need a critical section?

```

- 

```
   // the below two activeOut/InputChannels are used in process()

```

[/quote]

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 25, 2012, 11:21am UTC](https://forum.juce.com/t/audio-plugin-host/9570/16 "2012-11-25T11:21:35Z")

</div>

Sorry, I think I was merging that code while on the train - I meant to come back to it, but clearly got distracted…

In fact, it can’t be done in that way at all - if the channels change, the device must stop and restart, otherwise the callbacks won’t be expecting the correct number of channels, and things will crash.

The correct thing to do is to call AudioIODeviceType::callDeviceChangeListeners() when the ports change - I’ve checked something in that should do that now if you want to try it.

---

<div class="post-metadata">

**Author:** ![grebneke](https://avatars.discourse-cdn.com/v4/letter/g/a183cd/32.png) [@grebneke](https://forum.juce.com/u/grebneke)\
**Post date:** [November 25, 2012, 12:29pm UTC](https://forum.juce.com/t/audio-plugin-host/9570/17 "2012-11-25T12:29:40Z")

</div>

[quote=“jules”]In fact, it can’t be done in that way at all - if the channels change, the device must stop and restart, otherwise the callbacks won’t be expecting the correct number of channels, and things will crash.  
The correct thing to do is to call AudioIODeviceType::callDeviceChangeListeners() when the ports change - I’ve checked something in that should do that now if you want to try it.[/quote]  
I see two problems with what you did here:

1. External changes (ie from qjackctl or other jack patchbay) are not handled. Connecting two channels in an AudioDeviceSelectorComponent, and externaly disconnecting them, my audioDeviceIOCallback still thinks it’s getting two channels.

2. What are you trying to do with activeDeviceTypes? It will always have zero size since there is no assignment to it anywhere?

Would you mind explaining in a little more detail how my solution is wrong? It works also for external changes and I haven’t been able to make it crash. What callbacks are you referring to, that would still believe they’re getting some other number of channels? How can I make my solution crash?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 25, 2012, 1:59pm UTC](https://forum.juce.com/t/audio-plugin-host/9570/18 "2012-11-25T13:59:21Z")

</div>

God, I wish I hadn’t got drawn into looking at this…

I forgot to register the device types… Done now.

Your code wouldn’t have worked because if it changed the active channel bits while the device was running, the actual AudioIODeviceCallback would suddenly start getting a different sized list of audio channel data pointers. All playback needs to be stopped and restarted so they know how many channels to expect.

---

<div class="post-metadata">

**Author:** ![grebneke](https://avatars.discourse-cdn.com/v4/letter/g/a183cd/32.png) [@grebneke](https://forum.juce.com/u/grebneke)\
**Post date:** [November 25, 2012, 10:06pm UTC](https://forum.juce.com/t/audio-plugin-host/9570/19 "2012-11-25T22:06:35Z")

</div>

> [@jules](#):
>
> God, I wish I hadn’t got drawn into looking at this…

That makes me sad. I hope we can fix this together, and I’m trying to help.

> [@jules](#):
>
> I forgot to register the device types… Done now.

Ok, I get what you’re trying to do. Very very sad to say it doesn’t work. Apart from a typo that prevents it to build:

[code] ~JackAudioIODeviceType()  
{

- 

```
   activeDeviceTypes.removeFirstOccurrenceOf (this);

```

- 

```
   activeDeviceTypes.removeFirstMatchingValue (this);

```

}  
[/code]  
External changes do trigger AudioIODeviceType::callDeviceChangeListeners(), but that in turn doesn’t make playback restart. The callbacks audioDeviceStopped() and audioDeviceAboutToStart() are not called. Active channels are not updated. The AudioIODeviceCallback() keeps getting the same old number of channels and audio channel data pointers regardless of external changes.

> [@jules](#):
>
> Your code wouldn’t have worked because if it changed the active channel bits while the device was running, the actual AudioIODeviceCallback would suddenly start getting a different sized list of audio channel data pointers. All playback needs to be stopped and restarted so they know how many channels to expect.

I thought that was what numInputChannels/numOutputChannels arguments to AudioIODeviceCallback() were for - to know on each callback how many connected in/out channels to handle?

Even though you say I’m wrong, the fact remains that the code I sent you does in fact work. Yes - it does change the active channel bits while the device is running, but it does it in a callback on the same thread as AudioIODeviceCallback(), so there is no concurrency problem. Active channel bits are changed between calls to AudioIODeviceCallback(), which in turn always knows through numInputChannels/numOutputChannels how many active channels to handle on each call. How is that a problem? In addition, if you want it to also call AudioIODeviceType::callDeviceChangeListeners(), we could add that?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 25, 2012, 10:53pm UTC](https://forum.juce.com/t/audio-plugin-host/9570/20 "2012-11-25T22:53:01Z")

</div>

> [@](#):
>
> That makes me sad. I hope we can fix this together, and I’m trying to help.

I appreciate that, I just expected this to be a 10 minute job and it’s becoming a bit of time-sink now.

> [@](#):
>
> Even though you say I’m wrong, the fact remains that the code I sent you does in fact work. Yes - it does change the active channel bits while the device is running, but it does it in a callback on the same thread as AudioIODeviceCallback(), so there is no concurrency problem.

This isn’t a concurrency problem. Let me try to explain again… Some callback code will not be able to cope with the list of channels changing in subsequent calls to their process method, because they expect that list to remain a constant size while running. Just because your test app can handle that doesn’t mean that all other callbacks will also work without crashing.

[Next page](https://forum.juce.com/t/audio-plugin-host/9570.md?page=2)
