DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

resize-port.h (2985B)


      1 /*
      2   Copyright 2007-2016 David Robillard <http://drobilla.net>
      3 
      4   Permission to use, copy, modify, and/or distribute this software for any
      5   purpose with or without fee is hereby granted, provided that the above
      6   copyright notice and this permission notice appear in all copies.
      7 
      8   THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
      9   WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     10   MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     11   ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     12   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     13   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     14   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     15 */
     16 
     17 /**
     18    @defgroup resize-port Resize Port
     19 
     20    Dynamically sized LV2 port buffers.
     21 
     22    @{
     23 */
     24 
     25 #ifndef LV2_RESIZE_PORT_H
     26 #define LV2_RESIZE_PORT_H
     27 
     28 #include <stddef.h>
     29 #include <stdint.h>
     30 
     31 #define LV2_RESIZE_PORT_URI    "http://lv2plug.in/ns/ext/resize-port"  ///< http://lv2plug.in/ns/ext/resize-port
     32 #define LV2_RESIZE_PORT_PREFIX LV2_RESIZE_PORT_URI "#"                 ///< http://lv2plug.in/ns/ext/resize-port#
     33 
     34 #define LV2_RESIZE_PORT__asLargeAs   LV2_RESIZE_PORT_PREFIX "asLargeAs"    ///< http://lv2plug.in/ns/ext/port#asLargeAs
     35 #define LV2_RESIZE_PORT__minimumSize LV2_RESIZE_PORT_PREFIX "minimumSize"  ///< http://lv2plug.in/ns/ext/port#minimumSize
     36 #define LV2_RESIZE_PORT__resize      LV2_RESIZE_PORT_PREFIX "resize"       ///< http://lv2plug.in/ns/ext/port#resize
     37 
     38 #ifdef __cplusplus
     39 extern "C" {
     40 #else
     41 #    include <stdbool.h>
     42 #endif
     43 
     44 /** A status code for state functions. */
     45 typedef enum {
     46 	LV2_RESIZE_PORT_SUCCESS      = 0,  /**< Completed successfully. */
     47 	LV2_RESIZE_PORT_ERR_UNKNOWN  = 1,  /**< Unknown error. */
     48 	LV2_RESIZE_PORT_ERR_NO_SPACE = 2   /**< Insufficient space. */
     49 } LV2_Resize_Port_Status;
     50 
     51 /** Opaque data for resize method. */
     52 typedef void* LV2_Resize_Port_Feature_Data;
     53 
     54 /** Host feature to allow plugins to resize their port buffers. */
     55 typedef struct {
     56 	/** Opaque data for resize method. */
     57 	LV2_Resize_Port_Feature_Data data;
     58 
     59 	/**
     60 	   Resize a port buffer to at least `size` bytes.
     61 
     62 	   This function MAY return an error, in which case the port buffer was not
     63 	   resized and the port is still connected to the same location.  Plugins
     64 	   MUST gracefully handle this situation.
     65 
     66 	   This function is in the audio threading class.
     67 
     68 	   The host MUST preserve the contents of the port buffer when resizing.
     69 
     70 	   Plugins MAY resize a port many times in a single run callback.  Hosts
     71 	   SHOULD make this as inexpensive as possible.
     72 	*/
     73 	LV2_Resize_Port_Status (*resize)(LV2_Resize_Port_Feature_Data data,
     74 	                                 uint32_t                     index,
     75 	                                 size_t                       size);
     76 } LV2_Resize_Port_Resize;
     77 
     78 #ifdef __cplusplus
     79 }  /* extern "C" */
     80 #endif
     81 
     82 #endif  /* LV2_RESIZE_PORT_H */
     83 
     84 /**
     85    @}
     86 */