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.

90 lines
2.1KB

  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. char packet_buffer[PACKET_BUFFER_SIZE];
  32. JackMidiBufferReadQueue *read_queue;
  33. char semaphore_name[128];
  34. JackThread *thread;
  35. JackMidiAsyncQueue *thread_queue;
  36. sem_t *thread_queue_semaphore;
  37. protected:
  38. virtual bool
  39. SendPacketList(MIDIPacketList *packet_list) = 0;
  40. void
  41. Initialize(const char *alias_name, const char *client_name,
  42. const char *driver_name, int index,
  43. MIDIEndpointRef endpoint);
  44. public:
  45. JackCoreMidiOutputPort(double time_ratio, size_t max_bytes=4096,
  46. size_t max_messages=1024);
  47. virtual
  48. ~JackCoreMidiOutputPort();
  49. bool
  50. Execute();
  51. bool
  52. Init();
  53. void
  54. ProcessJack(JackMidiBuffer *port_buffer, jack_nframes_t frames);
  55. bool
  56. Start();
  57. bool
  58. Stop();
  59. };
  60. }
  61. #endif