arirusso / alsa-rawmidi

Realtime MIDI IO with Ruby for Linux
Other
12 stars 8 forks source link

Segfault when only dummy ALSA device is present #4

Closed AlexanderPavlenko closed 7 years ago

AlexanderPavlenko commented 11 years ago

Here is my configuration:

$ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)

$ aconnect -lo
client 14: 'Midi Through' [type=kernel]
    0 'Midi Through Port-0'
client 16: 'Virtual Raw MIDI 0-0' [type=kernel]
    0 'VirMIDI 0-0     '
…

When I try UniMIDI::Output.all it checks devices https://github.com/arirusso/alsa-rawmidi/blob/master/lib/alsa-rawmidi/soundcard.rb#L29

> AlsaRawMIDI::Map.snd_card_load(0)
=> 1
> AlsaRawMIDI::Map.snd_card_load(1)
=> 0

Then constructs name = "hw:0" which is not valid, I guess. https://github.com/arirusso/alsa-rawmidi/blob/master/lib/alsa-rawmidi/soundcard.rb#L11

And then segfaults here https://github.com/arirusso/alsa-rawmidi/blob/master/lib/alsa-rawmidi/soundcard.rb#L19

-- Control frame information -----------------------------------------------
c:0031 p:---- s:0126 e:000125 CFUNC  :snd_ctl_rawmidi_next_device
c:0030 p:0040 s:0121 e:000120 BLOCK  /usr/local/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/alsa-rawmidi-0.2.14/lib/alsa-rawmidi/soundcard.rb:19 [FINISH]
c:0029 p:---- s:0116 e:000115 CFUNC  :times
c:0028 p:0085 s:0113 e:000112 METHOD /usr/local/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/alsa-rawmidi-0.2.14/lib/alsa-rawmidi/soundcard.rb:17 [FINISH]
c:0027 p:---- s:0106 e:000105 CFUNC  :new
c:0026 p:0033 s:0102 e:000101 METHOD /usr/local/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/alsa-rawmidi-0.2.14/lib/alsa-rawmidi/soundcard.rb:29
c:0025 p:0015 s:0098 e:000097 BLOCK  /usr/local/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/alsa-rawmidi-0.2.14/lib/alsa-rawmidi/device.rb:51 [FINISH]
c:0024 p:---- s:0094 e:000093 CFUNC  :times
c:0023 p:0027 s:0091 e:000090 METHOD /usr/local/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/alsa-rawmidi-0.2.14/lib/alsa-rawmidi/device.rb:50
…
AlexanderPavlenko commented 11 years ago

Is that possible to use VirMIDI as output without any hardware?

AlexanderPavlenko commented 11 years ago

Or somehow output directly to the TiMidity port, that would be even better.

client 128: 'TiMidity' [type=user]
    0 'TiMidity port 0 '