Changeset 561
- Timestamp:
- 02/22/12 17:53:15 (3 months ago)
- Location:
- trunk
- Files:
-
- 8 modified
-
lv2/lv2plug.in/ns/ext/atom/atom-test.c (modified) (10 diffs)
-
lv2/lv2plug.in/ns/ext/atom/atom.h (modified) (10 diffs)
-
lv2/lv2plug.in/ns/ext/atom/atom.ttl (modified) (6 diffs)
-
lv2/lv2plug.in/ns/ext/atom/forge.h (modified) (14 diffs)
-
lv2/lv2plug.in/ns/ext/atom/manifest.ttl (modified) (1 diff)
-
lv2/lv2plug.in/ns/ext/atom/util.h (modified) (8 diffs)
-
plugins/eg-sampler.lv2/sampler.c (modified) (4 diffs)
-
plugins/eg-sampler.lv2/uris.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lv2/lv2plug.in/ns/ext/atom/atom-test.c
r558 r561 95 95 lv2_atom_forge_property_head(&forge, eg_one, 0); 96 96 LV2_Atom_Int32* one = lv2_atom_forge_int32(&forge, 1); 97 if (one-> value!= 1) {98 return test_fail("%d != 1\n", one-> value);97 if (one->body != 1) { 98 return test_fail("%d != 1\n", one->body); 99 99 } 100 100 … … 102 102 lv2_atom_forge_property_head(&forge, eg_two, 0); 103 103 LV2_Atom_Int64* two = lv2_atom_forge_int64(&forge, 2); 104 if (two-> value!= 2) {105 return test_fail("%ld != 2\n", two-> value);104 if (two->body != 2) { 105 return test_fail("%ld != 2\n", two->body); 106 106 } 107 107 … … 109 109 lv2_atom_forge_property_head(&forge, eg_three, 0); 110 110 LV2_Atom_Float* three = lv2_atom_forge_float(&forge, 3.0f); 111 if (three-> value!= 3) {112 return test_fail("%f != 3\n", three-> value);111 if (three->body != 3) { 112 return test_fail("%f != 3\n", three->body); 113 113 } 114 114 … … 116 116 lv2_atom_forge_property_head(&forge, eg_four, 0); 117 117 LV2_Atom_Double* four = lv2_atom_forge_double(&forge, 4.0); 118 if (four-> value!= 4) {119 return test_fail("%ld != 4\n", four-> value);118 if (four->body != 4) { 119 return test_fail("%ld != 4\n", four->body); 120 120 } 121 121 … … 123 123 lv2_atom_forge_property_head(&forge, eg_true, 0); 124 124 LV2_Atom_Bool* t = lv2_atom_forge_bool(&forge, true); 125 if (t-> value!= 1) {126 return test_fail("%ld != 1 (true)\n", t-> value);125 if (t->body != 1) { 126 return test_fail("%ld != 1 (true)\n", t->body); 127 127 } 128 128 … … 130 130 lv2_atom_forge_property_head(&forge, eg_false, 0); 131 131 LV2_Atom_Bool* f = lv2_atom_forge_bool(&forge, false); 132 if (f-> value!= 0) {133 return test_fail("%ld != 0 (false)\n", f-> value);132 if (f->body != 0) { 133 return test_fail("%ld != 0 (false)\n", f->body); 134 134 } 135 135 … … 160 160 lv2_atom_forge_property_head(&forge, eg_urid, 0); 161 161 LV2_Atom_URID* urid = lv2_atom_forge_urid(&forge, eg_value); 162 if (urid-> id!= eg_value) {163 return test_fail("%u != %u\n", urid-> id, eg_value);162 if (urid->body != eg_value) { 163 return test_fail("%u != %u\n", urid->body, eg_value); 164 164 } 165 165 … … 227 227 LV2_Atom_Forge_Frame seq_frame; 228 228 LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)lv2_atom_forge_sequence_head(&forge, &seq_frame, 0); 229 lv2_atom_forge_ audio_time(&forge, 0, 0);229 lv2_atom_forge_frame_time(&forge, 0); 230 230 lv2_atom_forge_int32(&forge, 1); 231 lv2_atom_forge_ audio_time(&forge, 1, 0);231 lv2_atom_forge_frame_time(&forge, 1); 232 232 lv2_atom_forge_int32(&forge, 2); 233 233 lv2_atom_forge_pop(&forge, &seq_frame); … … 241 241 } else if (lv2_atom_equals((LV2_Atom*)one, (LV2_Atom*)&itwo)) { 242 242 return test_fail("1 == 2\n"); 243 } else if (!lv2_atom_equals((LV2_Atom*)one, (LV2_Atom*)one)) { 244 return test_fail("1 != 1\n"); 243 245 } 244 246 … … 246 248 LV2_SEQUENCE_FOREACH(seq, i) { 247 249 LV2_Atom_Event* ev = lv2_sequence_iter_get(i); 248 if (ev->time.audio.frames != n_events 249 || ev->time.audio.subframes != 0) { 250 if (ev->time.frames != n_events) { 250 251 return test_fail("Corrupt event %u has bad time\n", n_events); 251 252 } else if (ev->body.type != forge.Int32) { 252 253 return test_fail("Corrupt event %u has bad type\n", n_events); 253 } else if (((LV2_Atom_Int32*)&ev->body)-> value!= (int)n_events + 1) {254 } else if (((LV2_Atom_Int32*)&ev->body)->body != (int)n_events + 1) { 254 255 return test_fail("Event %u != %d\n", n_events, n_events + 1); 255 256 } -
trunk/lv2/lv2plug.in/ns/ext/atom/atom.h
r557 r561 29 29 30 30 #define LV2_ATOM__Atom LV2_ATOM_URI "#Atom" 31 #define LV2_ATOM__Number LV2_ATOM_URI "#Number" 31 #define LV2_ATOM__AtomPort LV2_ATOM_URI "#AtomPort" 32 #define LV2_ATOM__AudioFrames LV2_ATOM_URI "#AudioFrames" 33 #define LV2_ATOM__Beats LV2_ATOM_URI "#Beats" 34 #define LV2_ATOM__Blank LV2_ATOM_URI "#Blank" 35 #define LV2_ATOM__Bool LV2_ATOM_URI "#Bool" 36 #define LV2_ATOM__Double LV2_ATOM_URI "#Double" 37 #define LV2_ATOM__Event LV2_ATOM_URI "#Event" 38 #define LV2_ATOM__Float LV2_ATOM_URI "#Float" 32 39 #define LV2_ATOM__Int32 LV2_ATOM_URI "#Int32" 33 40 #define LV2_ATOM__Int64 LV2_ATOM_URI "#Int64" 34 #define LV2_ATOM__Float LV2_ATOM_URI "#Float" 35 #define LV2_ATOM__Double LV2_ATOM_URI "#Double" 36 #define LV2_ATOM__Bool LV2_ATOM_URI "#Bool" 41 #define LV2_ATOM__Literal LV2_ATOM_URI "#Literal" 42 #define LV2_ATOM__MessagePort LV2_ATOM_URI "#MessagePort" 43 #define LV2_ATOM__Number LV2_ATOM_URI "#Number" 44 #define LV2_ATOM__Object LV2_ATOM_URI "#Object" 45 #define LV2_ATOM__Path LV2_ATOM_URI "#Path" 46 #define LV2_ATOM__Property LV2_ATOM_URI "#Property" 47 #define LV2_ATOM__Resource LV2_ATOM_URI "#Resource" 48 #define LV2_ATOM__Sequence LV2_ATOM_URI "#Sequence" 37 49 #define LV2_ATOM__String LV2_ATOM_URI "#String" 38 #define LV2_ATOM__ Literal LV2_ATOM_URI "#Literal"39 #define LV2_ATOM__ Path LV2_ATOM_URI "#Path"50 #define LV2_ATOM__TimeUnit LV2_ATOM_URI "#TimeUnit" 51 #define LV2_ATOM__Tuple LV2_ATOM_URI "#Tuple" 40 52 #define LV2_ATOM__URI LV2_ATOM_URI "#URI" 41 53 #define LV2_ATOM__URID LV2_ATOM_URI "#URID" 54 #define LV2_ATOM__ValuePort LV2_ATOM_URI "#ValuePort" 42 55 #define LV2_ATOM__Vector LV2_ATOM_URI "#Vector" 43 #define LV2_ATOM__Tuple LV2_ATOM_URI "#Tuple" 44 #define LV2_ATOM__Property LV2_ATOM_URI "#Property" 45 #define LV2_ATOM__Object LV2_ATOM_URI "#Object" 46 #define LV2_ATOM__Resource LV2_ATOM_URI "#Resource" 47 #define LV2_ATOM__Blank LV2_ATOM_URI "#Blank" 48 #define LV2_ATOM__TimeUnit LV2_ATOM_URI "#TimeUnit" 49 #define LV2_ATOM__AudioFrames LV2_ATOM_URI "#AudioFrames" 50 #define LV2_ATOM__Beats LV2_ATOM_URI "#Beats" 51 #define LV2_ATOM__Event LV2_ATOM_URI "#Event" 52 #define LV2_ATOM__Sequence LV2_ATOM_URI "#Sequence" 53 #define LV2_ATOM__AtomPort LV2_ATOM_URI "#AtomPort" 54 #define LV2_ATOM__ValuePort LV2_ATOM_URI "#ValuePort" 55 #define LV2_ATOM__MessagePort LV2_ATOM_URI "#MessagePort" 56 #define LV2_ATOM__beatTime LV2_ATOM_URI "#beatTime" 56 57 #define LV2_ATOM__bufferType LV2_ATOM_URI "#bufferType" 58 #define LV2_ATOM__eventTransfer LV2_ATOM_URI "#eventTransfer" 59 #define LV2_ATOM__frameTime LV2_ATOM_URI "#frameTime" 57 60 #define LV2_ATOM__supports LV2_ATOM_URI "#supports" 58 #define LV2_ATOM__ eventTransfer LV2_ATOM_URI "#eventTransfer"61 #define LV2_ATOM__timeUnit LV2_ATOM_URI "#timeUnit" 59 62 60 63 #define LV2_ATOM_REFERENCE_TYPE 0 … … 69 72 70 73 /** 71 Return a pointer to the contents of an Atom. 74 Return a pointer to the contents of an Atom. The "contents" of an atom 75 is the data past the complete type-specific header. 72 76 @param type The type of the atom, e.g. LV2_Atom_String. 73 77 @param atom A variable-sized atom. … … 76 80 ((void*)((uint8_t*)(atom) + sizeof(type))) 77 81 78 /** Return a pointer to the body of @p atom (just past the LV2_Atom head). */ 82 /** 83 Return a pointer to the body of an Atom. The "body" of an atom is the 84 data just past the LV2_Atom head (i.e. the same offset for all types). 85 */ 79 86 #define LV2_ATOM_BODY(atom) LV2_ATOM_CONTENTS(LV2_Atom, atom) 80 87 … … 87 94 /** An atom:Int32 or atom:Bool. May be cast to LV2_Atom. */ 88 95 typedef struct { 89 LV2_Atom atom; /**< Atom header. */90 int32_t value; /**< Integer value. */96 LV2_Atom atom; /**< Atom header. */ 97 int32_t body; /**< Integer value. */ 91 98 } LV2_Atom_Int32; 92 99 93 100 /** An atom:Int64. May be cast to LV2_Atom. */ 94 101 typedef struct { 95 LV2_Atom atom; /**< Atom header. */96 int64_t value; /**< Integer value. */102 LV2_Atom atom; /**< Atom header. */ 103 int64_t body; /**< Integer value. */ 97 104 } LV2_Atom_Int64; 98 105 99 106 /** An atom:Float. May be cast to LV2_Atom. */ 100 107 typedef struct { 101 LV2_Atom atom; /**< Atom header. */102 float value; /**< Floating point value. */108 LV2_Atom atom; /**< Atom header. */ 109 float body; /**< Floating point value. */ 103 110 } LV2_Atom_Float; 104 111 105 112 /** An atom:Double. May be cast to LV2_Atom. */ 106 113 typedef struct { 107 LV2_Atom atom; /**< Atom header. */108 double value; /**< Floating point value. */114 LV2_Atom atom; /**< Atom header. */ 115 double body; /**< Floating point value. */ 109 116 } LV2_Atom_Double; 110 117 … … 115 122 typedef struct { 116 123 LV2_Atom atom; /**< Atom header. */ 117 uint32_t id;/**< URID. */124 uint32_t body; /**< URID. */ 118 125 } LV2_Atom_URID; 119 126 120 /** The complete header of an atom:String. */127 /** An atom:String. May be cast to LV2_Atom. */ 121 128 typedef struct { 122 129 LV2_Atom atom; /**< Atom header. */ … … 124 131 } LV2_Atom_String; 125 132 126 /** The complete header of an atom:Literal. */ 127 typedef struct { 128 LV2_Atom atom; /**< Atom header. */ 133 /** The body of an atom:Literal. */ 134 typedef struct { 129 135 uint32_t datatype; /**< Datatype URID. */ 130 136 uint32_t lang; /**< Language URID. */ 131 137 /* Contents (a null-terminated UTF-8 string) follow here. */ 138 } LV2_Atom_Literal_Body; 139 140 /** An atom:Literal. May be cast to LV2_Atom. */ 141 typedef struct { 142 LV2_Atom atom; /**< Atom header. */ 143 LV2_Atom_Literal_Body body; /**< Body. */ 132 144 } LV2_Atom_Literal; 133 145 134 /** The complete header of an atom:Tuple. */146 /** An atom:Tuple. May be cast to LV2_Atom. */ 135 147 typedef struct { 136 148 LV2_Atom atom; /**< Atom header. */ … … 138 150 } LV2_Atom_Tuple; 139 151 140 /** The complete header of an atom:Vector. */ 141 typedef struct { 142 LV2_Atom atom; /**< Atom header. */ 152 /** The body of an atom:Vector. */ 153 typedef struct { 143 154 uint32_t elem_count; /**< The number of elements in the vector */ 144 155 uint32_t elem_type; /**< The type of each element in the vector */ 145 156 /* Contents (a series of packed atom bodies) follow here. */ 157 } LV2_Atom_Vector_Body; 158 159 /** An atom:Vector. May be cast to LV2_Atom. */ 160 typedef struct { 161 LV2_Atom atom; /**< Atom header. */ 162 LV2_Atom_Vector_Body body; /**< Body. */ 146 163 } LV2_Atom_Vector; 147 164 148 /** The header of an atom:Property body (e.g. in an atom:Object). */ 149 typedef struct { 150 uint32_t key; /**< Key (predicate) (mapped URI). */ 151 uint32_t context; /**< Context URID (may be, and generally is, 0). */ 152 LV2_Atom value; /**< Value atom header. */ 153 } LV2_Atom_Property_Body; 154 155 /** The complete header of an atom:Property. */ 156 typedef struct { 157 LV2_Atom atom; /**< Atom header. */ 165 /** The body of an atom:Property (e.g. in an atom:Object). */ 166 typedef struct { 158 167 uint32_t key; /**< Key (predicate) (mapped URI). */ 159 168 uint32_t context; /**< Context URID (may be, and generally is, 0). */ 160 169 LV2_Atom value; /**< Value atom header. */ 161 170 /* Value atom body follows here. */ 171 } LV2_Atom_Property_Body; 172 173 /** An atom:Property. May be cast to LV2_Atom. */ 174 typedef struct { 175 LV2_Atom atom; /**< Atom header. */ 176 LV2_Atom_Property_Body body; /**< Body. */ 162 177 } LV2_Atom_Property; 163 178 164 /** The complete header of an atom:Object. */ 165 typedef struct { 166 LV2_Atom atom; /**< Atom header. */ 179 /** The body of an atom:Object. May be cast to LV2_Atom. */ 180 typedef struct { 167 181 uint32_t id; /**< URID (atom:Resource) or blank ID (atom:Blank). */ 168 182 uint32_t otype; /**< Type URID (same as rdf:type, for fast dispatch). */ 169 183 /* Contents (a series of property bodies) follow here. */ 184 } LV2_Atom_Object_Body; 185 186 /** An atom:Object. May be cast to LV2_Atom. */ 187 typedef struct { 188 LV2_Atom atom; /**< Atom header. */ 189 LV2_Atom_Object_Body body; /**< Body. */ 170 190 } LV2_Atom_Object; 171 172 /** A time stamp in frames. Note this type is NOT an LV2_Atom. */173 typedef struct {174 uint32_t frames; /**< Time in frames relative to this block. */175 uint32_t subframes; /**< Fractional time in 1/(2^32)ths of a frame. */176 } LV2_Atom_Audio_Time;177 191 178 192 /** The header of an atom:Event. Note this type is NOT an LV2_Atom. */ … … 180 194 /** Time stamp. Which type is valid is determined by context. */ 181 195 union { 182 LV2_Atom_Audio_Time audio; /**< Time in audio frames. */183 double beats;/**< Time in beats. */196 int64_t frames; /**< Time in audio frames. */ 197 double beats; /**< Time in beats. */ 184 198 } time; 185 199 LV2_Atom body; /**< Event body atom header. */ … … 188 202 189 203 /** 190 A sequence of events (time-stamped atoms). 191 192 This is used as the contents of an atom:EventPort, but is a generic Atom 193 type which can be used anywhere. 204 The body of an atom:Sequence (a sequence of events). 194 205 195 206 The unit field is either a URID that described an appropriate time stamp … … 208 219 */ 209 220 typedef struct { 210 LV2_Atom atom; /**< Atom header. */211 221 uint32_t unit; /**< URID of unit of event time stamps. */ 212 222 uint32_t pad; /**< Currently unused. */ 213 223 /* Contents (a series of events) follow here. */ 224 } LV2_Atom_Sequence_Body; 225 226 /** An atom:Sequence. */ 227 typedef struct { 228 LV2_Atom atom; /**< Atom header. */ 229 LV2_Atom_Literal_Body body; /**< Body. */ 214 230 } LV2_Atom_Sequence; 215 231 -
trunk/lv2/lv2plug.in/ns/ext/atom/atom.ttl
r557 r561 31 31 <forge.h> ; 32 32 doap:release [ 33 doap:revision "0. 5" ;34 doap:created "2012-02- 18"33 doap:revision "0.6" ; 34 doap:created "2012-02-22" ; 35 35 ] ; 36 36 doap:maintainer [ … … 38 38 foaf:name "David Robillard" ; 39 39 foaf:homepage <http://drobilla.net/> ; 40 rdfs:seeAlso <http://drobilla.net/drobilla.rdf> 40 rdfs:seeAlso <http://drobilla.net/drobilla.rdf> ; 41 41 ] ; 42 42 lv2:documentation """ … … 178 178 sizeof(LV2_Atom_Literal)</code>, including the terminating NULL character. The 179 179 <code>lang</code> field SHOULD be a URI of the form 180 <http://lexvo.org/id/term/LANG> where LANG is an <a 181 href="http://www.loc.gov/standards/iso639-2/">ISO 693-2</a> or <a 182 href="http://www.loc.gov/standards/iso639-2/">ISO 693-3</a> language code.</p> 180 <http://lexvo.org/id/iso639-3/LANG> where LANG is an <a 181 href="http://www.loc.gov/standards/iso639-3/">ISO 693-3</a> language code.</p> 183 182 184 183 <p>A Literal may have a <code>datatype</code> OR a <code>lang</code>, but never … … 191 190 lit->atom.size = 14; 192 191 lit->datatype = 0; 193 lit->lang = map("http://lexvo.org/id/ term/en");192 lit->lang = map("http://lexvo.org/id/iso639-3/eng"); 194 193 memcpy(LV2_ATOM_CONTENTS(LV2_Atom_Literal, lit), 195 194 "Hello", … … 266 265 uint32_t elem_count; // 42 267 266 uint32_t elem_type; // map(expand("atom:Float")) 268 float elems[ 32];267 float elems[42]; 269 268 }; 270 269 </pre> … … 348 347 lv2:documentation "<p>A unit for atom:Event time stamps.</p>" . 349 348 350 atom:AudioFrames 349 atom:frameTime 350 a rdfs:Property ; 351 rdfs:range xsd:decimal ; 352 rdfs:label "Frame time" ; 353 lv2:documentation """ 354 <p>Time stamp in audio frames. Typically used for events.</p> 355 """ . 356 357 atom:beatTime 358 a rdfs:Property ; 359 rdfs:range xsd:decimal ; 360 rdfs:label "Beat time" ; 361 lv2:documentation """ 362 <p>Time stamp in beats. Typically used for events.</p> 363 """ . 364 365 atom:Frames 351 366 a rdfs:Class ; 352 367 rdfs:subClassOf atom:TimeUnit ; 353 rdfs:label " Audio frames" ;368 rdfs:label "Frames" ; 354 369 lv2:documentation """ 355 370 <p>Time in audio frames. Converting this to absolute time depends on the 356 sample rate. When this is the stamp unit for an atom:Sequence, the events in 357 that sequence have LV2_Atom_Audio_Time stamps (<code>event.time.audio</code>)</p>""" . 371 sample rate. When this is the stamp unit for an atom:Sequence, its events have 372 int64_t time stamps (<code>event.time.frames</code>)</p> 373 """ . 358 374 359 375 atom:Beats -
trunk/lv2/lv2plug.in/ns/ext/atom/forge.h
r559 r561 186 186 } 187 187 188 /** 189 Write raw output. This is used internally, but is also useful for writing 190 atom types not explicitly supported by the forge API. Note the caller is 191 responsible for ensuring the output is approriately padded. 192 */ 188 193 static inline void* 189 lv2_atom_forge_write_nopad(LV2_Atom_Forge* forge, 190 const void* data, 191 uint32_t size) 194 lv2_atom_forge_raw(LV2_Atom_Forge* forge, const void* data, uint32_t size) 192 195 { 193 196 uint8_t* out = NULL; … … 210 213 } 211 214 215 /** Pad output accordingly so next write is 64-bit aligned. */ 212 216 static inline void 213 lv2_atom_forge_pad(LV2_Atom_Forge* forge, 214 uint32_t written) 217 lv2_atom_forge_pad(LV2_Atom_Forge* forge, uint32_t written) 215 218 { 216 219 const uint64_t pad = 0; 217 220 const uint32_t pad_size = lv2_atom_pad_size(written) - written; 218 lv2_atom_forge_write_nopad(forge, &pad, pad_size); 219 } 220 221 lv2_atom_forge_raw(forge, &pad, pad_size); 222 } 223 224 /** Write raw output, padding to 64-bits as necessary. */ 221 225 static inline void* 222 lv2_atom_forge_write(LV2_Atom_Forge* forge, 223 const void* data, 224 uint32_t size) 225 { 226 void* out = lv2_atom_forge_write_nopad(forge, data, size); 226 lv2_atom_forge_write(LV2_Atom_Forge* forge, const void* data, uint32_t size) 227 { 228 void* out = lv2_atom_forge_raw(forge, data, size); 227 229 if (out) { 228 230 lv2_atom_forge_pad(forge, size); 229 231 } 230 232 return out; 233 } 234 235 /** Write an atom:Atom header. */ 236 static inline LV2_Atom* 237 lv2_atom_forge_atom(LV2_Atom_Forge* forge, uint32_t type, uint32_t size) 238 { 239 const LV2_Atom a = { type, size }; 240 return (LV2_Atom*)lv2_atom_forge_raw(forge, &a, sizeof(a)); 231 241 } 232 242 … … 284 294 lv2_atom_forge_string_body(LV2_Atom_Forge* forge, 285 295 const uint8_t* str, 286 size_tlen)296 uint32_t len) 287 297 { 288 298 uint8_t* out = NULL; 289 if ( (out = lv2_atom_forge_write_nopad(forge, str, len))290 && (out = lv2_atom_forge_ write_nopad(forge, "", 1))) {299 if ( (out = lv2_atom_forge_raw(forge, str, len)) 300 && (out = lv2_atom_forge_raw(forge, "", 1))) { 291 301 lv2_atom_forge_pad(forge, len + 1); 292 302 } … … 294 304 } 295 305 296 /** Write an atom :String. Note that @p str need not be NULL terminated. */306 /** Write an atom compatible with atom:String. Used internally. */ 297 307 static inline LV2_Atom_String* 298 lv2_atom_forge_string(LV2_Atom_Forge* forge, 299 const uint8_t* str, 300 size_t len) 301 { 302 const LV2_Atom_String a = { { forge->String, len + 1 } }; 308 lv2_atom_forge_typed_string(LV2_Atom_Forge* forge, 309 uint32_t type, 310 const uint8_t* str, 311 uint32_t len) 312 { 313 const LV2_Atom_String a = { { type, len + 1 } }; 303 314 LV2_Atom_String* out = (LV2_Atom_String*) 304 lv2_atom_forge_ write_nopad(forge, &a, sizeof(a));315 lv2_atom_forge_raw(forge, &a, sizeof(a)); 305 316 if (out) { 306 317 if (!lv2_atom_forge_string_body(forge, str, len)) { … … 313 324 } 314 325 326 /** Write an atom:String. Note that @p str need not be NULL terminated. */ 327 static inline LV2_Atom_String* 328 lv2_atom_forge_string(LV2_Atom_Forge* forge, const uint8_t* str, uint32_t len) 329 { 330 return lv2_atom_forge_typed_string(forge, forge->String, str, len); 331 } 332 315 333 /** 316 334 Write an atom:URI. Note that @p uri need not be NULL terminated. … … 319 337 */ 320 338 static inline LV2_Atom_String* 321 lv2_atom_forge_uri(LV2_Atom_Forge* forge, 322 const uint8_t* uri, 323 size_t len) 324 { 325 const LV2_Atom_String a = { { forge->URI, len + 1 } }; 326 LV2_Atom_String* out = (LV2_Atom_String*) 327 lv2_atom_forge_write_nopad(forge, &a, sizeof(a)); 328 if (out) { 329 if (!lv2_atom_forge_string_body(forge, uri, len)) { 330 out->atom.type = 0; 331 out->atom.size = 0; 332 out = NULL; 333 } 334 } 335 return out; 339 lv2_atom_forge_uri(LV2_Atom_Forge* forge, const uint8_t* uri, uint32_t len) 340 { 341 return lv2_atom_forge_typed_string(forge, forge->URI, uri, len); 336 342 } 337 343 338 344 /** Write an atom:Path. Note that @p path need not be NULL terminated. */ 339 345 static inline LV2_Atom_String* 340 lv2_atom_forge_path(LV2_Atom_Forge* forge, 341 const uint8_t* path, 342 size_t len) 343 { 344 const LV2_Atom_String a = { { forge->Path, len + 1 } }; 345 LV2_Atom_String* out = (LV2_Atom_String*) 346 lv2_atom_forge_write_nopad(forge, &a, sizeof(a)); 347 if (out) { 348 if (!lv2_atom_forge_string_body(forge, path, len)) { 349 out->atom.type = 0; 350 out->atom.size = 0; 351 out = NULL; 352 } 353 } 354 return out; 346 lv2_atom_forge_path(LV2_Atom_Forge* forge, const uint8_t* path, uint32_t len) 347 { 348 return lv2_atom_forge_typed_string(forge, forge->Path, path, len); 355 349 } 356 350 … … 359 353 lv2_atom_forge_literal(LV2_Atom_Forge* forge, 360 354 const uint8_t* str, 361 size_tlen,355 uint32_t len, 362 356 uint32_t datatype, 363 357 uint32_t lang) … … 366 360 { forge->Literal, 367 361 sizeof(LV2_Atom_Literal) - sizeof(LV2_Atom) + len + 1 }, 368 datatype,369 lang362 { datatype, 363 lang } 370 364 }; 371 365 LV2_Atom_Literal* out = (LV2_Atom_Literal*) 372 lv2_atom_forge_ write_nopad(forge, &a, sizeof(a));366 lv2_atom_forge_raw(forge, &a, sizeof(a)); 373 367 if (out) { 374 368 if (!lv2_atom_forge_string_body(forge, str, len)) { … … 388 382 uint32_t elem_size) 389 383 { 390 const size_t size = sizeof(LV2_Atom_Vector) + (elem_size * elem_count);384 const uint32_t size = sizeof(LV2_Atom_Vector) + (elem_size * elem_count); 391 385 const LV2_Atom_Vector a = { 392 386 { forge->Vector, size - sizeof(LV2_Atom) }, 393 elem_count, 394 elem_type 387 { elem_count, elem_type } 395 388 }; 396 389 return (LV2_Atom_Vector*)lv2_atom_forge_write(forge, &a, sizeof(a)); … … 470 463 const LV2_Atom_Object a = { 471 464 { forge->Resource, sizeof(LV2_Atom_Object) - sizeof(LV2_Atom) }, 472 id, 473 otype 465 { id, otype } 474 466 }; 475 467 LV2_Atom* atom = (LV2_Atom*)lv2_atom_forge_write(forge, &a, sizeof(a)); … … 488 480 const LV2_Atom_Object a = { 489 481 { forge->Blank, sizeof(LV2_Atom_Object) - sizeof(LV2_Atom) }, 490 id, 491 otype 482 { id, otype } 492 483 }; 493 484 LV2_Atom* atom = (LV2_Atom*)lv2_atom_forge_write(forge, &a, sizeof(a)); … … 521 512 const LV2_Atom_Sequence a = { 522 513 { forge->Sequence, sizeof(LV2_Atom_Sequence) - sizeof(LV2_Atom) }, 523 unit, 524 0 514 { unit, 0 } 525 515 }; 526 516 LV2_Atom* atom = (LV2_Atom*)lv2_atom_forge_write(forge, &a, sizeof(a)); … … 533 523 the same @p parent parameter. Note the returned LV2_Event is NOT an Atom. 534 524 */ 535 static inline LV2_Atom_Audio_Time* 536 lv2_atom_forge_audio_time(LV2_Atom_Forge* forge, 537 uint32_t frames, 538 uint32_t subframes) 539 { 540 const LV2_Atom_Audio_Time a = { frames, subframes }; 541 return (LV2_Atom_Audio_Time*)lv2_atom_forge_write(forge, &a, sizeof(a)); 525 static inline int64_t* 526 lv2_atom_forge_frame_time(LV2_Atom_Forge* forge, int64_t frames) 527 { 528 return (int64_t*)lv2_atom_forge_write(forge, &frames, sizeof(frames)); 542 529 } 543 530 … … 548 535 */ 549 536 static inline double* 550 lv2_atom_forge_beat_time(LV2_Atom_Forge* forge, 551 double beats) 537 lv2_atom_forge_beat_time(LV2_Atom_Forge* forge, double beats) 552 538 { 553 539 return (double*)lv2_atom_forge_write(forge, &beats, sizeof(beats)); -
trunk/lv2/lv2plug.in/ns/ext/atom/manifest.ttl
r556 r561 5 5 a lv2:Specification ; 6 6 lv2:minorVersion 0 ; 7 lv2:microVersion 5;7 lv2:microVersion 6 ; 8 8 rdfs:seeAlso <atom.ttl> . -
trunk/lv2/lv2plug.in/ns/ext/atom/util.h
r556 r561 63 63 lv2_atom_equals(const LV2_Atom* a, const LV2_Atom* b) 64 64 { 65 return (a == b) || ( 66 (a->type == b->type) && 67 (a->size == b->size) && 68 !memcmp(LV2_ATOM_CONTENTS(LV2_Atom, a), 69 LV2_ATOM_CONTENTS(LV2_Atom, b), 70 a->size)); 65 return (a == b) || ((a->type == b->type) && 66 (a->size == b->size) && 67 !memcmp(a + 1, b + 1, a->size)); 71 68 } 72 69 … … 79 76 typedef LV2_Atom_Event* LV2_Atom_Sequence_Iter; 80 77 81 /** Get an iterator pointing to the first element in @p tup. */ 78 /** Get an iterator pointing to the first element in a Sequence body. */ 79 static inline LV2_Atom_Sequence_Iter 80 lv2_sequence_body_begin(const LV2_Atom_Sequence_Body* body) 81 { 82 return (LV2_Atom_Sequence_Iter)(body + 1); 83 } 84 85 /** Get an iterator pointing to the first element in a Sequence. */ 82 86 static inline LV2_Atom_Sequence_Iter 83 87 lv2_sequence_begin(const LV2_Atom_Sequence* seq) 84 88 { 85 return (LV2_Atom_Sequence_Iter)(LV2_ATOM_CONTENTS(LV2_Atom_Sequence, seq)); 86 } 87 88 /** Return true iff @p i has reached the end of @p tup. */ 89 return (LV2_Atom_Sequence_Iter)(seq + 1); 90 } 91 92 /** Return true iff @p i has reached the end of @p body. */ 93 static inline bool 94 lv2_sequence_body_is_end(const LV2_Atom_Sequence_Body* body, 95 uint32_t size, 96 LV2_Atom_Sequence_Iter i) 97 { 98 return (uint8_t*)i >= ((uint8_t*)body + size); 99 } 100 101 /** Return true iff @p i has reached the end of @p seq. */ 89 102 static inline bool 90 103 lv2_sequence_is_end(const LV2_Atom_Sequence* seq, LV2_Atom_Sequence_Iter i) … … 127 140 (iter) = lv2_sequence_iter_next(iter)) 128 141 142 /** A version of LV2_SEQUENCE_FOREACH for when only the body is available. */ 143 #define LV2_SEQUENCE_BODY_FOREACH(body, size, iter) \ 144 for (LV2_Atom_Sequence_Iter (iter) = lv2_sequence_body_begin(body); \ 145 !lv2_sequence_body_is_end(body, size, (iter)); \ 146 (iter) = lv2_sequence_iter_next(iter)) 147 129 148 /** 130 149 @} … … 143 162 } 144 163 164 /** Return true iff @p i has reached the end of @p body. */ 165 static inline bool 166 lv2_atom_tuple_body_is_end(const void* body, 167 uint32_t size, 168 LV2_Atom_Tuple_Iter i) 169 { 170 return (uint8_t*)i >= ((uint8_t*)body + size); 171 } 172 145 173 /** Return true iff @p i has reached the end of @p tup. */ 146 174 static inline bool 147 175 lv2_tuple_is_end(const LV2_Atom_Tuple* tup, LV2_Atom_Tuple_Iter i) 148 176 { 149 return (uint8_t*)i >= ((uint8_t*)tup + sizeof(LV2_Atom) + tup->atom.size);177 return lv2_atom_tuple_body_is_end(LV2_ATOM_BODY(tup), tup->atom.size, i); 150 178 } 151 179 … … 183 211 (iter) = lv2_tuple_iter_next(iter)) 184 212 213 /** A version of LV2_TUPLE_FOREACH for when only the body is available. */ 214 #define LV2_TUPLE_BODY_FOREACH(body, size, iter) \ 215 for (LV2_Atom_Tuple_Iter (iter) = (LV2_Atom_Tuple_Iter)body; \ 216 !lv2_atom_tuple_body_is_end(body, size, (iter)); \ 217 (iter) = lv2_tuple_iter_next(iter)) 218 185 219 /** 186 220 @} … … 192 226 typedef LV2_Atom_Property_Body* LV2_Atom_Object_Iter; 193 227 228 static inline LV2_Atom_Object_Iter 229 lv2_object_body_begin(const LV2_Atom_Object_Body* body) 230 { 231 return (LV2_Atom_Object_Iter)(body + 1); 232 } 233 194 234 /** Get an iterator pointing to the first property in @p obj. */ 195 235 static inline LV2_Atom_Object_Iter 196 236 lv2_object_begin(const LV2_Atom_Object* obj) 197 237 { 198 return (LV2_Atom_Object_Iter)(LV2_ATOM_CONTENTS(LV2_Atom_Object, obj)); 238 return (LV2_Atom_Object_Iter)(obj + 1); 239 } 240 241 static inline bool 242 lv2_atom_object_body_is_end(const LV2_Atom_Object_Body* body, 243 uint32_t size, 244 LV2_Atom_Object_Iter i) 245 { 246 return (uint8_t*)i >= ((uint8_t*)body + size); 199 247 } 200 248 … … 204 252 { 205 253 return (uint8_t*)i >= ((uint8_t*)obj + sizeof(LV2_Atom) + obj->atom.size); 206 }207 208 /** Return true iff @p l points to the same property as @p r. */209 static inline bool210 lv2_object_iter_equals(const LV2_Atom_Object_Iter l,211 const LV2_Atom_Object_Iter r)212 {213 return l == r;214 254 } 215 255 … … 247 287 for (LV2_Atom_Object_Iter (iter) = lv2_object_begin(object); \ 248 288 !lv2_object_is_end(object, (iter)); \ 289 (iter) = lv2_object_iter_next(iter)) 290 291 /** A version of LV2_OBJECT_FOREACH for when only the body is available. */ 292 #define LV2_OBJECT_BODY_FOREACH(body, size, iter) \ 293 for (LV2_Atom_Object_Iter (iter) = lv2_object_body_begin(body); \ 294 !lv2_atom_object_body_is_end(body, size, (iter)); \ 249 295 (iter) = lv2_object_iter_next(iter)) 250 296 -
trunk/plugins/eg-sampler.lv2/sampler.c
r555 r561 336 336 uint8_t* const data = (uint8_t* const)(ev + 1); 337 337 if ((data[0] & 0xF0) == 0x90) { 338 start_frame = ev->time. audio.frames;338 start_frame = ev->time.frames; 339 339 plugin->frame = 0; 340 340 plugin->play = true; … … 342 342 } else if (is_object_type(uris, ev->body.type)) { 343 343 const LV2_Atom_Object* obj = (LV2_Atom_Object*)&ev->body; 344 if (obj-> otype == uris->msg_Set) {344 if (obj->body.otype == uris->msg_Set) { 345 345 /* Received a set message, send it to the worker thread. */ 346 346 fprintf(stderr, "Queueing set message\n"); … … 351 351 zix_sem_post(&plugin->signal); 352 352 } else { 353 fprintf(stderr, "Unknown object type %d\n", obj-> otype);353 fprintf(stderr, "Unknown object type %d\n", obj->body.otype); 354 354 } 355 355 } else { … … 411 411 412 412 /* Send a notification that we're using a new sample. */ 413 lv2_atom_forge_ audio_time(&plugin->forge, 0, 0);413 lv2_atom_forge_frame_time(&plugin->forge, 0); 414 414 write_set_file(&plugin->forge, uris, 415 415 plugin->sample->path, -
trunk/plugins/eg-sampler.lv2/uris.h
r556 r561 108 108 const LV2_Atom_Object* obj) 109 109 { 110 if (obj-> otype != uris->msg_Set) {111 fprintf(stderr, "Ignoring unknown message type %d\n", obj-> otype);110 if (obj->body.otype != uris->msg_Set) { 111 fprintf(stderr, "Ignoring unknown message type %d\n", obj->body.otype); 112 112 return NULL; 113 113 }
