elk-audio / sushi

Elk Audio OS Plugin host and DAW
Other
122 stars 15 forks source link

Fix LV2 log formatting for messages with vargs #6

Closed laenzlinger closed 1 year ago

laenzlinger commented 1 year ago

Problem: In case an LV2 plugin uses va_list, the parameters were not evaluated.

see: https://lv2plug.in/c/html/group__log.html#structLV2__Log__Log

Solution: use vsnprintf functions to format the messags into a buffer

I am still new to C/C++ development. Not sure if the solution is really good enough to be merged.

laenzlinger commented 1 year ago

I am not sure if this works in a realtime environment, where predictable response time is important. I did not check if this code is run in a real time context (I assumed not, otherwise the solution is probably not good enough)

laenzlinger commented 1 year ago

@tejusp do you mean some automated unit test? Or manual test results?

noizebox commented 1 year ago

Thanks you for reporting and suggesting a solution @laenzlinger. And apologies for being slow to respond. As you already figured out, this would not be safe to call from a realtime audio processing thread. I'm not sure if the LV2 specs expects this to be realtime safe or not.

We are working on a larger refactoring of the sushi logger that would allow us to log from the audio thread(s) in a realtime safe manner. We're planning on fixing this as part of that story.

laenzlinger commented 1 year ago

It absolutely makes sense to consider the real time context. As mentioned I did not dig down in the code so deeply to understand how its done in sushi. Logging should not be done in a real time context (IMO).

For me this is currently not an issue at all. With this workaround I could debug the problems I had with my LV2 plugin. It does not need to go into main branch. (Feel free to discard this PR)

I also decided to base my plugin instead of LV2 on CLAP . This looks really promising and with my underlying RUST framework I can also generate a VST plugin which I should then be able to use from within sushi. Did not try it though. Would of course be very cool if Sushi at some point would add direct CLAP support.

Anyhow, your plan to refactor the sushi logging sounds great. In a headless environment logging is crucial to debug problems. Keep up the good work you are doing for the open source music community. I appreciate it very much and its cool to work with your tools!