midi_sndio.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (C) 2002-2010 The DOSBox Team
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. #include <sndio.h>
  19. class MidiHandler_sndio: public MidiHandler {
  20. private:
  21. struct mio_hdl *hdl;
  22. public:
  23. MidiHandler_sndio() : MidiHandler(), hdl(NULL) {};
  24. const char * GetName(void) { return "sndio"; }
  25. bool Open(const char * conf) {
  26. if (hdl) return false;
  27. hdl = mio_open((conf && conf[0]) ? conf : MIO_PORTANY, MIO_OUT, 0);
  28. return (hdl != NULL);
  29. };
  30. void Close(void) {
  31. if (!hdl) return;
  32. mio_close(hdl);
  33. hdl = NULL;
  34. };
  35. void PlayMsg(Bit8u * msg) {
  36. Bitu len=MIDI_evt_len[*msg];
  37. if (hdl) mio_write(hdl, msg, len);
  38. };
  39. void PlaySysex(Bit8u * sysex,Bitu len) {
  40. if (hdl) mio_write(hdl, sysex, len);
  41. }
  42. };
  43. MidiHandler_sndio Midi_sndio;