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

Midi race #321

Merged
merged 3 commits into from
Jan 14, 2022
Merged

Midi race #321

merged 3 commits into from
Jan 14, 2022

Conversation

jwessel
Copy link
Contributor

@jwessel jwessel commented Jan 13, 2022

This rtpmidid series is for two specific problems:

  1. When switching the playback device or input device,
    the device endpoints must be destroyed or it ends up creating loops.

    After this commit the behavior changes slightly. Previously
    the piano and another source could both be inputs to the light bar
    at the same time if you selected one after the other in the menu
    because a new end point was created each time. But this also
    caused the problem described above. The light bar should only
    be connected to one source at a time.

  2. The inport and playback port are not protected by a mutex, which
    means some care needs to be taken to wait for the main thread to
    not be using either resource when performing connect operations
    by the web server thread.

The visualizer hangs somewhere in the midi code if the LCD is updated
just before reconnect_ports().  It is still possible to for it to hang
and this can be tracked down later, but it doesn't hang as often.

Signed-off-by: Jason Wessel <[email protected]>
Everytime the playback device selection was used a new RtMidi endpoint
was created.  Using the connect all after this was causing completely
erattic behavior such as loops and lag.  The old endpoints must be
deleted before creating new endpoints.

The connectall() should also restore the input and output endpoints
for the light bar.

Signed-off-by: Jason Wessel <[email protected]>
If the main thread was calling inport.poll() at the time it is closed
the visualizer will hang.  Change the close calls to come after the
new port is created and wait 2ms if it is a port reconnect operation
to allow the poll operation to complete.

Signed-off-by: Jason Wessel <[email protected]>
@onlaj
Copy link
Owner

onlaj commented Jan 14, 2022

I tested it and it seems to be working fine, but I have never encountered any major problems with ports, so I can't really tell if it solves issues like those mentioned here
Thank you for your work, merging.

@onlaj onlaj merged commit 2fbfd88 into onlaj:master Jan 14, 2022
scaraude pushed a commit to scaraude/Piano-LED-Visualizer that referenced this pull request Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants