sndio_midiport.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2012 Stefan Sperling <stsp@openbsd.org>
  3. *
  4. * Permission to use, copy, modify, and distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef __sndio_midiport_h__
  17. #define __sndio_midiport_h__
  18. #include <list>
  19. #include <string>
  20. #include <vector>
  21. #include <midi++/port.h>
  22. #include <sndio.h>
  23. namespace MIDI {
  24. class SndioMidi_MidiPort:public Port {
  25. public:
  26. SndioMidi_MidiPort(const XMLNode& node);
  27. virtual ~ SndioMidi_MidiPort();
  28. virtual int selectable() const;
  29. static int discover(std::vector<PortSet>&);
  30. static std::string typestring;
  31. protected:
  32. /* Direct I/O */
  33. int write(byte * msg, size_t msglen);
  34. int read(byte * buf, size_t max);
  35. std::string get_typestring() const {
  36. return typestring;
  37. }
  38. private:
  39. struct mio_hdl *hdl;
  40. int poll(int event) const;
  41. struct pollfd *pfd;
  42. };
  43. } // namespace MIDI
  44. #endif // __sndio_midiport_h__