{"action":"created","issue":{"url":"https://api.github.com/repos/FluidSynth/fluidsynth/issues/368","repository_url":"https://api.github.com/repos/FluidSynth/fluidsynth","labels_url":"https://api.github.com/repos/FluidSynth/fluidsynth/issues/368/labels{/name}","comments_url":"https://api.github.com/repos/FluidSynth/fluidsynth/issues/368/comments","events_url":"https://api.github.com/repos/FluidSynth/fluidsynth/issues/368/events","html_url":"https://github.com/FluidSynth/fluidsynth/issues/368","id":314984197,"number":368,"title":"Need a way to skip initialisation of CoreAudio, to avoid deadlock","user":{"login":"Birch-san","id":6141784,"avatar_url":"https://avatars3.githubusercontent.com/u/6141784?v=4","gravatar_id":"","url":"https://api.github.com/users/Birch-san","html_url":"https://github.com/Birch-san","followers_url":"https://api.github.com/users/Birch-san/followers","following_url":"https://api.github.com/users/Birch-san/following{/other_user}","gists_url":"https://api.github.com/users/Birch-san/gists{/gist_id}","starred_url":"https://api.github.com/users/Birch-san/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Birch-san/subscriptions","organizations_url":"https://api.github.com/users/Birch-san/orgs","repos_url":"https://api.github.com/users/Birch-san/repos","events_url":"https://api.github.com/users/Birch-san/events{/privacy}","received_events_url":"https://api.github.com/users/Birch-san/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-04-17T09:46:09Z","updated_at":"2018-04-17T14:29:32Z","closed_at":null,"author_association":"NONE","body":"### FluidSynth version\r\n1.1.10, macOS\r\n\r\n### Repro\r\nWe begin with `new_fluid_settings()`.\r\nWithin that: FluidSynth sets up CoreAudio.\r\n\r\nBeware: our application may be hosted inside _another application which uses CoreAudio._ **This causes a deadlock**, as the host _also_ holds a lock on CoreAudio's `HALB_Mutex::Lock()`.\r\n\r\nI made an audio plugin (VST/AU), and this is what happens when the host application (FL Studio) initialises my audio plugin:\r\n\r\n```\r\n__psynch_mutexwait 0x00007fff55a07d1e\r\n_pthread_mutex_lock_wait 0x00007fff55b43bfe\r\n_pthread_mutex_lock_slow 0x00007fff55b41551\r\nHALB_Mutex::Lock() 0x00007fff2da9c91f\r\nHALC_ProxyIOContext::GetPropertyDataSize(AudioObjectPropertyAddress const&, unsigned int, void const*, unsigned int&) const 0x00007fff2dab9fe1\r\nHALC_ShellObject::GetPropertyDataSize(unsigned int, AudioObjectPropertyAddress const&, unsigned int, void const*, unsigned int&) const 0x00007fff2dacecc8\r\nHAL_HardwarePlugIn_ObjectGetPropertyDataSize(AudioHardwarePlugInInterface**, unsigned int, AudioObjectPropertyAddress const*, unsigned int, void const*, unsigned int*) 0x00007fff2dace4bf\r\nHALPlugIn::ObjectGetPropertyDataSize(HALObject const&, AudioObjectPropertyAddress const&, unsigned int, void const*) const 0x00007fff2dace22c\r\nAudioObjectGetPropertyDataSize 0x00007fff2dac9fb1\r\nget_num_outputs 0x000000012d534584\r\nfluid_core_audio_driver_settings 0x000000012d53474f\r\nfluid_audio_driver_settings 0x000000012d554833\r\nnew_fluid_settings 0x000000012d536a4b\r\n```\r\n\r\nFL Studio will not release the lock until my plugin finishes initialisation.\r\nMy plugin cannot finish initialisation until FL Studio releases the lock.\r\n\r\nThis deadlock occurs in [LMMS](https://github.com/LMMS/lmms/issues/649) and [FL Studio](https://forum.image-line.com/viewtopic.php?f=1965&t=185063&p=1292991#p1292991), but does not occur in GarageBand or Sibelius.\r\n\r\nThe punchline:\r\nI _don't even use CoreAudio_. I use FluidSynth solely to render blocks of audio, which I send to the plugin host (which has its own audio driver).\r\n\r\n\r\n### Proposal\r\nWe need an opportunity to avoid some of the mandatory startup steps.\r\n\r\nI would like an opportunity to configure my `fluid_settings_t*` _before_ `fluid_settings_init()` runs upon it.\r\n\r\nSo, imagine this:\r\n\r\n```cpp\r\nfluid_settings_t* mySettings = new_fluid_settings_empty();\r\nfluid_settings_setint(mySettings, \"disable_audiodriver\", 1);\r\nfluid_settings_init(mySettings);\r\n```\r\n\r\nThis way I could say \"don't setup an audio driver when you do the normal startup process\"."},"comment":{"url":"https://api.github.com/repos/FluidSynth/fluidsynth/issues/comments/382013446","html_url":"https://github.com/FluidSynth/fluidsynth/issues/368#issuecomment-382013446","issue_url":"https://api.github.com/repos/FluidSynth/fluidsynth/issues/368","id":382013446,"user":{"login":"Birch-san","id":6141784,"avatar_url":"https://avatars3.githubusercontent.com/u/6141784?v=4","gravatar_id":"","url":"https://api.github.com/users/Birch-san","html_url":"https://github.com/Birch-san","followers_url":"https://api.github.com/users/Birch-san/followers","following_url":"https://api.github.com/users/Birch-san/following{/other_user}","gists_url":"https://api.github.com/users/Birch-san/gists{/gist_id}","starred_url":"https://api.github.com/users/Birch-san/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Birch-san/subscriptions","organizations_url":"https://api.github.com/users/Birch-san/orgs","repos_url":"https://api.github.com/users/Birch-san/repos","events_url":"https://api.github.com/users/Birch-san/events{/privacy}","received_events_url":"https://api.github.com/users/Birch-san/received_events","type":"User","site_admin":false},"created_at":"2018-04-17T14:29:32Z","updated_at":"2018-04-17T14:29:32Z","author_association":"NONE","body":"Ah, good to know. How would I use `fluid_audio_driver_register()` to register _no_ audio driver? since NULL means all.\r\n\r\nI can see use-cases that are currently difficult with this:\r\n- exclude **all** audio drivers (since this is an exhaustive whitelist, and seems not to support empty whitelist)\r\n- exclude **one** driver (since I'd need to know the list of drivers _typically_ registered and splice one out)"}}
{"actor":{"display_login":"Birch-san"}}