Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External MIDI Keyboard in Flatpak not detected #1771

Closed
helpsterTee opened this issue Feb 21, 2024 · 20 comments
Closed

External MIDI Keyboard in Flatpak not detected #1771

helpsterTee opened this issue Feb 21, 2024 · 20 comments
Assignees
Labels
bug Something isn't working done issue resolved

Comments

@helpsterTee
Copy link

helpsterTee commented Feb 21, 2024

Is the MIDI support also working in Flatpak? I do not see the permission in the context (only access to the pulseaudio socket).

Observed behaviour:

  • no MIDI devices selectable, tried rescan

Expected behaviour:

  • MIDI devices are available as soon as they are plugged in / re-scanned / application is restarted

Relevant log output:

[info] initializing MIDI.
ALSA lib ../../../src/seq/seq_hw.c:466:(snd_seq_hw_open) open /dev/snd/seq failed: No such file or directory

MidiInAlsa::initialize: error creating ALSA sequencer client object.

[warning] could not initialize RtMidi in! MidiInAlsa::initialize: error creating ALSA sequencer client object.
[warning] error while initializing MIDI!
[trace] no MIDI output device selected.

Flatpak context:

[Context]
shared=ipc;
sockets=x11;wayland;pulseaudio;fallback-x11;
devices=dri;
filesystems=xdg-run/pipewire-0;

Flatpak version of furnace:

v0.6.1

@helpsterTee
Copy link
Author

Apparently it seems that would need --device=all, which is too much permissions in general (blockdevs, etc):

https://github.com/flathub/net.sourceforge.kmidimon/blob/master/net.sourceforge.kmidimon.json#L13

@tildearrow tildearrow added the bug Something isn't working label Feb 21, 2024
@tildearrow
Copy link
Owner

The wonders of sandboxing...

Assign to @ColinKinloch

@ColinKinloch
Copy link
Contributor

ColinKinloch commented Feb 21, 2024

It has access to the xdg-run/pipewire-0.
Pipewire provides a jack server implementation.
Though looking through the furnace options I can't find the setting for it.
I'm using SDL/pipewire for my audio output which works pretty well.

@tildearrow
Copy link
Owner

Furnace uses ALSA MIDI through RtMidi (yeah, I disabled JACK MIDI).

@ColinKinloch
Copy link
Contributor

Ah, the flatpak builds RtMidi separately with jack support.
Is there a reason it's disabled? It seems to work well.

@tildearrow
Copy link
Owner

It is disabled because I plan to add a native JACK backend to Furnace.

@ColinKinloch
Copy link
Contributor

Seems that Debian KDE doesn't use pipewire by default yet.
I guess I should add --device=all ☹️

@helpsterTee
Copy link
Author

My recommendation would be to add this as a part of the installation documentation, so the users can override that behaviour themselves.

That way, the Flatpak is still contained in a sane way and if anybody needs to override this, until the Jack implementation is ready, they can do that, with all the possible repercussions.

sudo flatpak override --device=all org.tildearrow.furnace for systemwide
flatpak override --user --device=all org.tildearrow.furnace for user installations.

@ColinKinloch
Copy link
Contributor

The flatpak currently supports jack via RTMidi and has permissions for specifically the pipewire implementation of jackd.

The issue is how do you display these suggestions to the user:

Out of interest what distro do you use?

@helpsterTee
Copy link
Author

Maybe I don't understand, but do you mean MIDI should work currently with jack routing? Because it doesn't on my side:

image

image

image

This is on a Ubuntu system.

@ColinKinloch
Copy link
Contributor

ColinKinloch commented Feb 22, 2024

Which version of Ubuntu?
Ubuntu switched to pipewire on version 22.10.
Could you give me the output of pgrep -a pulse and pgrep -a jack

@helpsterTee
Copy link
Author

Yeah, this is focal, but has added pipewire support and jack via pipewire works for other applications (Bitwig for example). So that's not the problem:

pgrep -a pulse:

1234 /usr/bin/pipewire-pulse
4567 /usr/lib/x86_64-linux-gnu/xfce4/panel/wrapper-2.0 /usr/lib/x86_64-linux-gnu/xfce4/panel/plugins/libpulseaudio-plugin.so

pgrep -a jack is empty

@ColinKinloch
Copy link
Contributor

I feel it should work, I'll have a think and get back to you.

@ColinKinloch
Copy link
Contributor

ColinKinloch commented Feb 22, 2024

Mine is using ALSA for MIDI as it turns out (via) pipewire 🤷.
Maybe try dpkg -S '*libspa-alsa*' to figure out what package provides it.
or just update to a newer distro.

@helpsterTee
Copy link
Author

Yeah, I can't figure it out in this setup. But it will work as intended, if I give it --device all access:

grafik

Will check on another system, as soon as the next LTS drops. Thanks so far for the help :)

@tildearrow
Copy link
Owner

It appears that Furnace does not allow you to choose which RtMidi::Api to use, so RtMidi falls back to trying all available APIs...

...starting with ALSA.

@tildearrow
Copy link
Owner

Are you sure Flatpak does not offer a way to only provide access to /dev/snd?

@ColinKinloch
Copy link
Contributor

There's a discussion here: flatpak/xdg-desktop-portal#1142

I checked just now and if I run furnace with --nosocket=pulseaudio I retain jack / pipewire audio out and loose the ability to enumerate MIDI devices. It seems that access to ALSA midi (/dev/snd/seq) is controlled by that socket.

Here's the line in flatpak that gives access to /dev/snd: https://github.com/flatpak/flatpak/blob/2cb17b4eb82ecedaa98b5b7f954cf3e52fa95682/common/flatpak-run-pulseaudio.c#L331-L337

introduced in: flatpak/flatpak@4d1899b

Looks like flatpak 0.6.1 was 8 years ago https://github.com/flatpak/flatpak/tree/0.6.1

The version of flatpak included in 20.04 LTS is too old by 4 years. I guess the question is what does LTS mean? It's a promise made by Ubuntu so let them provide the support 😁.

@helpsterTee
Copy link
Author

helpsterTee commented Feb 25, 2024

Looks like flatpak 0.6.1 was 8 years ago

I've updated the issue description to better reflect what v0.6.1 refers to.

@helpsterTee
Copy link
Author

helpsterTee commented Feb 25, 2024

Can confirm it working on latest available Flatpak stable 1.14.4 👍

Thanks for the pointers :)

@tildearrow tildearrow added the done issue resolved label Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working done issue resolved
Projects
None yet
Development

No branches or pull requests

3 participants