jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.8KB

  1. /*
  2. Copyright (C) 2010 Devin Anderson
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU Lesser General Public License as published by
  5. the Free Software Foundation; either version 2.1 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. #ifndef __JackMidiWriteQueue__
  16. #define __JackMidiWriteQueue__
  17. #include "JackMidiPort.h"
  18. namespace Jack {
  19. /**
  20. * Interface for classes that act as write queues for MIDI messages. Write
  21. * queues are used by processors to transfer data to the next processor.
  22. */
  23. class SERVER_EXPORT JackMidiWriteQueue {
  24. public:
  25. enum EnqueueResult {
  26. BUFFER_FULL,
  27. BUFFER_TOO_SMALL,
  28. EVENT_EARLY,
  29. EN_ERROR,
  30. OK
  31. };
  32. virtual ~JackMidiWriteQueue();
  33. /**
  34. * Enqueues a data packet in the write queue of `size` bytes contained
  35. * in `buffer` that will be sent the absolute time specified by `time`.
  36. * This method should not block unless 1.) this write queue represents
  37. * the actual outbound MIDI connection, 2.) the MIDI event is being
  38. * sent *now*, meaning that `time` is less than or equal to *now*, and
  39. * 3.) the method is *not* being called in the process thread. The
  40. * method should return `OK` if the event was enqueued, `BUFFER_FULL`
  41. * if the write queue isn't able to accept the event right now,
  42. * `BUFFER_TOO_SMALL` if this write queue will never be able to accept
  43. * the event because the event is too large, `EVENT_EARLY` if this
  44. * queue cannot schedule events ahead of time, and `EN_ERROR` if an error
  45. * occurs that cannot be specified by another return code.
  46. */
  47. virtual EnqueueResult
  48. EnqueueEvent(jack_nframes_t time, size_t size,
  49. jack_midi_data_t *buffer) = 0;
  50. /**
  51. * A wrapper method for the `EnqueueEvent` method above. The optional
  52. * 'frame_offset' argument is an amount of frames to add to the event's
  53. * time.
  54. */
  55. inline EnqueueResult
  56. EnqueueEvent(jack_midi_event_t *event, jack_nframes_t frame_offset=0)
  57. {
  58. return EnqueueEvent(event->time + frame_offset, event->size,
  59. event->buffer);
  60. }
  61. };
  62. }
  63. #endif