'libs/ardour' - Main body of changes required for building with MSVC
[ardour.git] / libs / ardour / ardour / lv2_plugin.h
index 8dacd8600ef9fd1922b460db3f138fccabf7a150..5154cd4d3e710cc8148e3a3322f2c44ed9096ef0 100644 (file)
@@ -29,6 +29,8 @@
 #include "ardour/worker.h"
 #include "pbd/ringbuffer.h"
 
+typedef struct LV2_Evbuf_Impl LV2_Evbuf;
+
 namespace ARDOUR {
 
 // a callback function for lilv_state_new_from_instance(). friend of LV2Plugin
@@ -111,8 +113,6 @@ class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
        boost::shared_ptr<Plugin::ScalePoints>
        get_scale_points(uint32_t port_index) const;
 
-       static uint32_t midi_event_type() { return _midi_event_type; }
-
        void set_insert_info(const PluginInsert* insert);
 
        int      set_state (const XMLNode& node, int version);
@@ -124,9 +124,7 @@ class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
        bool has_editor () const;
        bool has_message_output () const;
 
-       uint32_t atom_eventTransfer() const;
-
-       void write_from_ui(uint32_t       index,
+       bool write_from_ui(uint32_t       index,
                           uint32_t       protocol,
                           uint32_t       size,
                           const uint8_t* body);
@@ -147,14 +145,26 @@ class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
 
        static URIMap _uri_map;
 
-       static uint32_t _midi_event_type;
-       static uint32_t _chunk_type;
-       static uint32_t _sequence_type;
-       static uint32_t _event_transfer_type;
-       static uint32_t _path_type;
-       static uint32_t _log_Error;
-       static uint32_t _log_Warning;
-       static uint32_t _log_Note;
+       struct URIDs {
+               uint32_t atom_Chunk;
+               uint32_t atom_Path;
+               uint32_t atom_Sequence;
+               uint32_t atom_eventTransfer;
+               uint32_t log_Error;
+               uint32_t log_Note;
+               uint32_t log_Warning;
+               uint32_t midi_MidiEvent;
+               uint32_t time_Position;
+               uint32_t time_bar;
+               uint32_t time_barBeat;
+               uint32_t time_beatUnit;
+               uint32_t time_beatsPerBar;
+               uint32_t time_beatsPerMinute;
+               uint32_t time_frame;
+               uint32_t time_speed;
+       };
+
+       static URIDs urids;
 
   private:
        struct Impl;
@@ -167,9 +177,12 @@ class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
        float*        _shadow_data;
        float*        _defaults;
        LV2_Evbuf**   _ev_buffers;
+       LV2_Evbuf**   _atom_ev_buffers;
        float*        _bpm_control_port;  ///< Special input set by ardour
        float*        _freewheel_control_port;  ///< Special input set by ardour
        float*        _latency_control_port;  ///< Special output set by ardour
+       framepos_t    _next_cycle_start;  ///< Expected start frame of next run cycle
+       double        _next_cycle_speed;  ///< Expected start frame of next run cycle
        PBD::ID       _insert_id;
 
        friend const void* lv2plugin_get_port_value(const char* port_symbol,
@@ -178,17 +191,20 @@ class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
                                                    uint32_t*   type);
 
        typedef enum {
-               PORT_INPUT   = 1,
-               PORT_OUTPUT  = 1 << 1,
-               PORT_AUDIO   = 1 << 2,
-               PORT_CONTROL = 1 << 3,
-               PORT_EVENT   = 1 << 4,
-               PORT_MESSAGE = 1 << 5
+               PORT_INPUT    = 1,       ///< Input port
+               PORT_OUTPUT   = 1 << 1,  ///< Output port
+               PORT_AUDIO    = 1 << 2,  ///< Audio (buffer of float)
+               PORT_CONTROL  = 1 << 3,  ///< Control (single float)
+               PORT_EVENT    = 1 << 4,  ///< Old event API event port
+               PORT_SEQUENCE = 1 << 5,  ///< New atom API event port
+               PORT_MIDI     = 1 << 6,  ///< Event port understands MIDI
+               PORT_POSITION = 1 << 7   ///< Event port understands position
        } PortFlag;
 
        typedef unsigned PortFlags;
 
        std::vector<PortFlags>         _port_flags;
+       std::vector<size_t>            _port_minimumSize;
        std::map<std::string,uint32_t> _port_indices;
 
        /// Message send to/from UI via ports
@@ -198,12 +214,12 @@ class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
                uint32_t size;
        };
 
-       void write_to_ui(uint32_t       index,
+       bool write_to_ui(uint32_t       index,
                         uint32_t       protocol,
                         uint32_t       size,
                         const uint8_t* body);
 
-       void write_to(RingBuffer<uint8_t>* dest,
+       bool write_to(RingBuffer<uint8_t>* dest,
                      uint32_t             index,
                      uint32_t             protocol,
                      uint32_t             size,
@@ -223,7 +239,12 @@ class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
        LV2_Feature    _make_path_feature;
        LV2_Feature    _log_feature;
        LV2_Feature    _work_schedule_feature;
-       LV2_Feature    _buf_size_feature;
+       LV2_Feature    _options_feature;
+       LV2_Feature    _def_state_feature;
+
+       // Options passed to plugin
+       int32_t _block_length;
+       int32_t _seq_size;
 
        mutable unsigned _state_version;
 
@@ -239,6 +260,7 @@ class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
                                          const char* path);
 
        void init (const void* c_plugin, framecnt_t rate);
+       void allocate_atom_event_buffers ();
        void run (pframes_t nsamples);
 
        void latency_compute_run ();