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

[alsa_midi] fix hotplug device (de)enumeration #18

Closed
wants to merge 1 commit into from
Closed

[alsa_midi] fix hotplug device (de)enumeration #18

wants to merge 1 commit into from

Conversation

ventosus
Copy link
Contributor

Issues:

  • With a running JACK with enabled alsa_midi driver (-X alsa_midi), plugging in
    a new MIDI device has no effect, e.g. no corresponding JACK ports are spawned
  • With a running JACK with enabled alsa_midi driver (-X alsa_midi), deplugging
    a MIDI device has no effect, e.g. the corresponding JACK ports stay around

Result:

  • JACK only creates JACK ports of ALSA MIDI clients/ports found at startup
  • JACK has to be restarted for any ALSA MIDI device (de)enumeration to take
    place

Problem:

  • There are some functions defined which actually should accomplish this in the
    alsa_midi driver code (e.g. 'a2j_update_ports' and 'a2j_free_ports'), but they
    are not called from any other function ;-)

Solution:

  • Discriminate properly between ALSA PORT_START and PORT_CHANGE events
    • 'a2j_new_ports' function has been added which recycles some code from
      'alsa_input_thread'
  • Actually call the already existing hot(de)plugging infrastructure
    • 'a2j_update_ports' and 'a2j_new_ports' get called from the
      'alsa_input_thread'
    • 'a2j_free_ports' gets called from 'alsa_output_thread'
    • 'alsa_out_thread' is woken up by 'a2j_jack_process_internal'
  • Cleanup code that is not used:
    • 'port_add' ringbuffer has no function, as 'new_ports' ringbuffer seems to be
      implemented to accomplish the same

Signed-off-by: Hanspeter Portner dev@open-music-kontrollers.ch

Issues:
- With a running JACK with enabled alsa_midi driver (-X alsa_midi), plugging in
	a new MIDI device has no effect, e.g. no corresponding JACK ports are spawned
- With a running JACK with enabled alsa_midi driver (-X alsa_midi), deplugging
	a MIDI device has no effect, e.g. the corresponding JACK ports stay around

Result:
- JACK only creates JACK ports of ALSA MIDI clients/ports found at startup
- JACK has to be restarted for any ALSA MIDI device (de)enumeration to take
	place

Problem:
- There are some functions defined which actually should accomplish this in the
	alsa_midi driver code (e.g. 'a2j_update_ports' and 'a2j_free_ports'), but they
	are not called from any other function ;-)

Solution:
- Discriminate properly between ALSA PORT_START and PORT_CHANGE events
	- 'a2j_new_ports' function has been added which recycles some code from
		'alsa_input_thread'
- Actually call the already existing hot(de)plugging infrastructure
	- 'a2j_update_ports' and 'a2j_new_ports' get called from the
		'alsa_input_thread'
	- 'a2j_free_ports' gets called from 'alsa_output_thread'
	- 'alsa_out_thread' is woken up by 'a2j_jack_process_internal'
- Cleanup code that is not used:
	- 'port_add' ringbuffer has no function, as 'new_ports' ringbuffer seems to be
		implemented to accomplish the same

Signed-off-by: Hanspeter Portner <dev@open-music-kontrollers.ch>
@ventosus
Copy link
Contributor Author

Can be tested with snd_virmidi kernel module, if there should not be some USB MIDI device at hands...

sudo modprobe snd_virmidi
sudo rmmod -f snd_virmidi

@rncbc
Copy link

rncbc commented May 2, 2015

i can confirm this patch is working as advertised: MIDI client ports are (de)listed according to resp. MIDI h/w device (un)plugging.

+1 to merge.

@ventosus
Copy link
Contributor Author

ventosus commented May 5, 2015

This seems to have been merged via Git natively, I'll thus close it manually here.

@ventosus ventosus closed this May 5, 2015
@ventosus ventosus deleted the fix_alsa_midi_hotplug branch October 8, 2015 17:22
@ventosus ventosus restored the fix_alsa_midi_hotplug branch November 25, 2015 14:49
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.

None yet

2 participants