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_IO_H
20 #define WINMME_MIDI_IO_H
28 #include <boost/shared_ptr.hpp>
29 #include "pbd/ringbuffer.h"
31 #include "winmmemidi_input_device.h"
32 #include "winmmemidi_output_device.h"
36 struct WinMMEMIDIPacket {
39 WinMMEMIDIPacket (const WinMMEMIDIPacket& other)
40 : timeStamp (other.timeStamp)
41 , length (other.length)
44 memcpy (data, other.data, length);
49 // MIDITimeStamp timeStamp;
54 typedef std::vector<boost::shared_ptr<WinMMEMIDIPacket> > WinMMEMIDIQueue;
64 bool dequeue_input_event (uint32_t port,
65 uint64_t timestamp_start,
66 uint64_t timestamp_end,
71 bool enqueue_output_event (uint32_t port,
76 uint32_t n_midi_inputs (void) const { return m_inputs.size(); }
77 uint32_t n_midi_outputs (void) const { return m_outputs.size(); }
79 std::vector<WinMMEMidiInputDevice*> get_inputs () { return m_inputs; }
80 std::vector<WinMMEMidiOutputDevice*> get_outputs () { return m_outputs; }
82 std::string port_id (uint32_t, bool input);
83 std::string port_name (uint32_t, bool input);
85 void set_enabled (bool yn = true) { m_enabled = yn; }
86 bool enabled (void) const { return m_active && m_enabled; }
88 void set_port_changed_callback (void (changed_callback (void*)), void *arg) {
89 m_changed_callback = changed_callback;
97 void create_input_devices ();
98 void create_output_devices ();
100 void destroy_input_devices ();
101 void destroy_output_devices ();
103 void start_devices ();
104 void stop_devices ();
108 std::vector<WinMMEMidiInputDevice*> m_inputs;
109 std::vector<WinMMEMidiOutputDevice*> m_outputs;
115 void (* m_changed_callback) (void*);
116 void * m_changed_arg;
118 // protects access to m_inputs and m_outputs
119 pthread_mutex_t m_device_lock;
124 #endif // WINMME_MIDI_IO_H