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.

91 lines
2.2KB

  1. /*
  2. Copyright (C) 2011 Devin Anderson
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 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 General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14. */
  15. #ifndef __JackCoreMidiOutputPort__
  16. #define __JackCoreMidiOutputPort__
  17. #include <semaphore.h>
  18. #include "JackCoreMidiPort.h"
  19. #include "JackMidiAsyncQueue.h"
  20. #include "JackMidiBufferReadQueue.h"
  21. #include "JackThread.h"
  22. namespace Jack {
  23. class JackCoreMidiOutputPort:
  24. public JackCoreMidiPort, public JackRunnableInterface {
  25. private:
  26. jack_midi_event_t *
  27. GetCoreMidiEvent(bool block);
  28. MIDITimeStamp
  29. GetTimeStampFromFrames(jack_nframes_t frames);
  30. static const size_t PACKET_BUFFER_SIZE = 65536;
  31. SInt32 advance_schedule_time;
  32. char packet_buffer[PACKET_BUFFER_SIZE];
  33. JackMidiBufferReadQueue *read_queue;
  34. char semaphore_name[128];
  35. JackThread *thread;
  36. JackMidiAsyncQueue *thread_queue;
  37. sem_t *thread_queue_semaphore;
  38. protected:
  39. virtual bool
  40. SendPacketList(MIDIPacketList *packet_list) = 0;
  41. void
  42. Initialize(const char *alias_name, const char *client_name,
  43. const char *driver_name, int index,
  44. MIDIEndpointRef endpoint, SInt32 advance_schedule_time);
  45. public:
  46. JackCoreMidiOutputPort(double time_ratio, size_t max_bytes=4096,
  47. size_t max_messages=1024);
  48. virtual
  49. ~JackCoreMidiOutputPort();
  50. bool
  51. Execute();
  52. bool
  53. Init();
  54. void
  55. ProcessJack(JackMidiBuffer *port_buffer, jack_nframes_t frames);
  56. bool
  57. Start();
  58. bool
  59. Stop();
  60. };
  61. }
  62. #endif