Skip to content

One CPU Core Pinned at 100%? #8

@djthread

Description

@djthread

Much thanks for sharing this library! It was great to find it as I set about trying to read some buttons on my controller. What I noticed, though, is that as soon as I run this line in iex

iex(1)> {:ok, input} = PortMidi.open(:input, "Midi Fighter 3D MIDI 1")
{:ok, #PID<0.177.0>}

... I get one of my cores pinned to 100%

It does seem to work alright otherwise, but something is clearly wrong. And thoughts on what it might be?

defmodule Test do
  @dev_name "Midi Fighter 3D MIDI 1"

  def start do
    {:ok, input} = PortMidi.open(:input, @dev_name)
    :ok = PortMidi.listen(input, self)
    go
  end

  def go do
    receive do
      msg ->
        IO.inspect msg
        go
    end
  end
end

Launching this and moving some controls does give me the messages back, but my CPU is working awfully hard for it.

iex(1)> Test.start
{#PID<0.177.0>, [{{146, 48, 127}, 4417}]}
{#PID<0.177.0>, [{{130, 48, 127}, 4534}]}

This is on an Arch Linux system.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions