2 * Copyright (C) 2015 Tim Mayberry <mojofunk@gmail.com>
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.
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #ifndef WINMME_MIDI_OUTPUT_DEVICE_H
20 #define WINMME_MIDI_OUTPUT_DEVICE_H
30 #include <boost/scoped_ptr.hpp>
32 #include <pbd/ringbuffer.h>
34 #define MaxWinMidiEventSize 256
38 class WinMMEMidiOutputDevice {
40 WinMMEMidiOutputDevice (int index);
42 ~WinMMEMidiOutputDevice ();
44 bool enqueue_midi_event (uint64_t rel_event_time_us,
51 void set_enabled (bool enable);
54 std::string name () const { return m_name; }
57 bool open (UINT index, std::string& error_msg);
58 bool close (std::string& error_msg);
60 bool set_device_name (UINT index);
62 std::string get_error_string (MMRESULT error_code);
64 bool start_midi_output_thread ();
65 bool stop_midi_output_thread ();
67 bool signal (HANDLE semaphore);
68 bool wait (HANDLE semaphore);
70 static void* midi_output_thread (void*);
71 void midi_output_thread ();
73 bool wait_for_microseconds (int64_t us);
75 static void CALLBACK winmm_output_callback (HMIDIOUT handle,
81 void midi_output_callback (UINT msg, DWORD_PTR data, DWORD_PTR timestamp);
86 HANDLE m_queue_semaphore;
87 HANDLE m_sysex_semaphore;
96 pthread_t m_output_thread_handle;
98 bool m_thread_running;
101 boost::scoped_ptr<RingBuffer<uint8_t> > m_midi_buffer;
104 } // namespace ARDOUR
106 #endif // WINMME_MIDI_OUTPUT_DEVICE_H