 |
O2
1.1
Inter-process communication system for media applications
|
181 #define O2_SERVICE_CONFLICT (-2)
185 #define O2_NO_SERVICE (-3)
188 #define O2_NO_MEMORY (-4)
191 #define O2_ALREADY_RUNNING (-5)
194 #define O2_BAD_NAME (-6)
197 #define O2_BAD_TYPE (-7)
201 #define O2_BAD_ARGS (-8)
204 #define O2_TCP_HUP (-9)
208 #define O2_HOSTNAME_TO_NETADDR_FAIL (-10)
211 #define O2_TCP_CONNECT_FAIL (-11)
215 #define O2_NO_CLOCK (-12)
218 #define O2_NO_HANDLER (-13)
221 #define O2_INVALID_MSG (-14)
224 #define O2_SEND_FAIL (-15)
227 #define O2_BAD_SERVICE_NAME (-16)
230 #define O2_SERVICE_EXISTS (-17)
233 #define O2_NOT_INITIALIZED (-18)
243 #define O2_LOCAL_NOTIME 0
251 #define O2_REMOTE_NOTIME 1
265 #define O2_BRIDGE_NOTIME 2
282 #define O2_TO_OSC_NOTIME 3
332 #define O2_MARKER_A (void *) 0xdeadbeefdeadbeefL
333 #define O2_MARKER_B (void *) 0xf00baa23f00baa23L
336 extern void *((*o2_malloc)(
size_t size));
337 extern void ((*o2_free)(
void *));
338 void *o2_calloc(
size_t n,
size_t s);
345 void *o2_dbg_malloc(
size_t size,
char *file,
int line);
346 void o2_dbg_free(
void *obj,
char *file,
int line);
347 #define O2_MALLOC(x) o2_dbg_malloc(x, __FILE__, __LINE__)
348 #define O2_FREE(x) o2_dbg_free(x, __FILE__, __LINE__)
363 #define O2_MALLOC(x) (*o2_malloc)(x)
365 #define O2_MALLOC(x) o2_dbg_malloc(x, __FILE__, __LINE__)
372 #define O2_FREE(x) (*o2_free)(x)
374 #define O2_FREE(x) (*o2_dbg_free)(x, __FILE__, __LINE__)
381 void *o2_calloc(
size_t n,
size_t s);
382 #define O2_CALLOC(n, s) o2_calloc((n), (s))
384 void *
o2_dbg_calloc(
size_t n,
size_t s,
char *file,
int line);
385 #define O2_CALLOC(n, s) o2_dbg_calloc((n), (s), __FILE__, __LINE__)
430 #define MSG_DATA_LENGTH(m) (((int32_t *) &((m)->timestamp))[-1])
437 #define WORD_ALIGN_PTR(p) ((char *) (((size_t) (p)) & ~3))
438 #define O2_MSG_TYPES(msg) \
439 WORD_ALIGN_PTR((msg)->address + strlen((msg)->address) + 4) + 1;
670 int o2_memory(
void *((*malloc)(
size_t size)),
void ((*free)(
void *)));
942 #define o2_send(path, time, ...) \
943 o2_send_marker(path, time, FALSE, \
944 __VA_ARGS__, O2_MARKER_A, O2_MARKER_B)
947 int o2_send_marker(
const char *path,
double time,
int tcp_flag,
948 const char *typestring, ...);
973 #define o2_send_cmd(path, time, ...) \
974 o2_send_marker(path, time, TRUE, \
975 __VA_ARGS__, O2_MARKER_A, O2_MARKER_B)
1050 int o2_osc_port_new(
const char *service_name,
int port_num,
int tcp_flag);
1091 int o2_osc_delegate(
const char *service_name,
const char *ip,
int port_num,
1315 #define o2_add_symbol(s) o2_add_string_or_symbol(O2_SYMBOL, s)
1318 #define o2_add_string(s) o2_add_string_or_symbol(O2_STRING, s)
1336 #define o2_add_double(d) o2_add_double_or_time(O2_DOUBLE, d)
1339 #define o2_add_time(t) o2_add_double_or_time(O2_TIME, t)
1346 #define o2_add_int32(i) o2_add_int32_or_char(O2_INT32, i)
1349 #define o2_add_char(c) o2_add_int32_or_char(O2_CHAR, c)
1360 #define o2_add_true() o2_add_only_typecode(O2_TRUE);
1363 #define o2_add_false() o2_add_only_typecode(O2_FALSE);
1366 #define o2_add_bool(x) o2_add_int32_or_char(O2_BOOL, x != 0)
1369 #define o2_add_nil() o2_add_only_typecode(O2_NIL);
1372 #define o2_add_infinitum() o2_add_only_typecode(O2_INFINITUM);
1375 #define o2_add_start_array() o2_add_only_typecode(O2_ARRAY_START);
1378 #define o2_add_end_array() o2_add_only_typecode(O2_ARRAY_END);
1389 int length,
void *data);
1443 const char *service,
const char *address,
int tcp_flag);
1601 #define O2_SCHED_TABLE_LEN 128
1604 typedef struct o2_sched {
1608 } o2_sched, *o2_sched_ptr;
@ O2_VECTOR
Prefix to indicate a vector.
Definition: o2.h:510
int32_t * vi
vector of 32-bit signed integers
Definition: o2.h:558
an O2 message container
Definition: o2.h:457
int o2_schedule(o2_sched_ptr scheduler, o2_message_ptr msg)
void * o2_dbg_calloc(size_t n, size_t s, char *file, int line)
allocate memory
int c
Standard C, 8 bit, char, stored as int.
Definition: o2.h:547
double * vd
vector of IEEE-754 doubles
Definition: o2.h:560
@ O2_BLOB
Binary Large OBject (BLOB) type.
Definition: o2.h:492
void o2_message_free(o2_message_ptr msg)
free a message allocated by o2_send_start().
int o2_run(int rate)
Run O2.
int o2_add_message(o2_message_ptr msg)
add a message to a bundle
int o2_add_blob(o2_blob_ptr b)
add an o2_blob to the message (see o2_send_start()), where the blob is given as a pointer to an o2_bl...
float f32
an alias for f
Definition: o2.h:540
char data[4]
the data, actually of variable length
Definition: o2.h:480
float f
32 bit IEEE-754 float.
Definition: o2.h:539
int o2_extract_start(o2_msg_data_ptr msg)
initialize internal state to parse, extract, and coerce message arguments.
int64_t h
an alias for i64
Definition: o2.h:538
int32_t len
IMPORTANT: divide by 4 or 8 to get length in elements.
Definition: o2.h:554
@ O2_NIL
Symbol representing the value Nil.
Definition: o2.h:505
int32_t i
an alias for i32
Definition: o2.h:536
int o2_add_int32_or_char(o2_type tcode, int32_t i)
This function supports o2_add_int32() and o2_add_char() Normally, you should not call this directly.
int o2_stop_flag
set this flag to stop o2_run()
o2_message_ptr o2_service_message_finish(o2_time time, const char *service, const char *address, int tcp_flag)
finish and return a message, prepending service name
int o2_message_send(o2_message_ptr msg)
Send an O2 message. (See also macros o2_send and o2_send_cmd).
double o2_time
O2 timestamps are doubles representing seconds since the approximate start time of the application.
Definition: o2.h:392
int64_t i64
64 bit signed integer.
Definition: o2.h:537
int o2_add_vector(o2_type element_type, int length, void *data)
add a vector
union of all O2 parameter types
Definition: o2.h:534
float * vf
vector of IEEE-754 floats
Definition: o2.h:561
int64_t pad_if_needed2
make sure allocated is 8-byte aligned
Definition: o2.h:464
int o2_osc_port_free(int port_num)
Remove a port receiving OSC messages.
double f64
an alias for d
Definition: o2.h:542
@ O2_INFINITUM
Symbol representing the value Infinitum.
Definition: o2.h:506
o2_arg_ptr o2_get_next(o2_type type_code)
get the next message parameter
int o2_service_free(char *service_name)
Remove a local service.
int o2_status(const char *service)
Check the status of the service.
o2_sched o2_gtsched
Scheduler that schedules according to global (master) clock time.
int o2_method_new(const char *path, const char *typespec, o2_method_handler h, void *user_data, int coerce, int parse)
Add a handler for an address.
o2_time o2_time_get()
Get the estimated synchronized global O2 time.
@ O2_INT64
64 bit signed integer.
Definition: o2.h:497
int o2_clock_is_synchronized
A variable indicating that the clock is the master or is synchronized to the master.
int o2_memory(void *((*malloc)(size_t size)), void((*free)(void *)))
Tell O2 how to allocate/free memory.
int o2_add_string_or_symbol(o2_type tcode, const char *s)
This function suppports o2_add_symbol() and o2_add_string() Normally, you should not call this direct...
@ O2_FALSE
Symbol representing the value False.
Definition: o2.h:504
@ O2_INT32
32 bit signed integer.
Definition: o2.h:489
o2_message_ptr o2_message_finish(o2_time time, const char *address, int tcp_flag)
finish and return the message.
o2_time o2_local_time()
Get the real time using the local O2 clock.
@ O2_ARRAY_END
End array or tuple.
Definition: o2.h:494
void o2_debug_flags(const char *flags)
Enable debugging output.
data part of an O2 message
Definition: o2.h:414
int32_t B
a boolean value, either 0 or 1
Definition: o2.h:552
void(* o2_method_handler)(const o2_msg_data_ptr msg, const char *types, o2_arg_ptr *argv, int argc, void *user_data)
callback function to receive an O2 message
Definition: o2.h:630
int o2_add_float(float f)
add a float to the message (see o2_send_start())
o2_time o2_set_discovery_period(o2_time period)
Set discovery period.
int o2_osc_port_new(const char *service_name, int port_num, int tcp_flag)
Create a port to receive OSC messages.
int32_t allocated
how many bytes allocated in data part
Definition: o2.h:466
int32_t length
the length of the message in data part
Definition: o2.h:467
o2_blob b
a blob (unstructured bytes)
Definition: o2.h:551
@ O2_TIME
OSC time type.
Definition: o2.h:498
int o2_osc_delegate(const char *service_name, const char *ip, int port_num, int tcp_flag)
Create a service that forwards O2 messages to an OSC server.
uint64_t o2_osc_time_offset(uint64_t offset)
Set the OSC time offset.
The structure for binary large object.
Definition: o2.h:478
o2_sched o2_ltsched
Scheduler that schedules according to local clock time.
struct o2_message * next
links used for free list and scheduler
Definition: o2.h:459
int o2_initialize(const char *application_name)
Start O2.
@ O2_CHAR
8bit char variable (Standard C).
Definition: o2.h:501
@ O2_ARRAY_START
Start array or tuple.
Definition: o2.h:493
int o2_roundtrip(double *mean, double *min)
Get network round-trip information.
int o2_service_new(const char *service_name)
Add a service to the current application.
char address[4]
the message address string
Definition: o2.h:424
const char * o2_error_to_string(int i)
Return text representation of an O2 error.
@ O2_TRUE
Symbol representing the value True.
Definition: o2.h:503
int o2_finish()
release the memory and shut down O2.
int tcp_flag
send message by tcp?
Definition: o2.h:463
int o2_clock_set(o2_time_callback gettime, void *rock)
Provide a time reference to O2.
int o2_add_only_typecode(o2_type typecode)
This function supports o2_add_true(), o2_add_false(), o2_add_bool(), o2_add_nil(),...
o2_sched_ptr o2_active_sched
Current scheduler.
int o2_add_int64(int64_t i)
add an int64 to the message (see o2_send_start())
const char * o2_application_name
name of the application
o2_time timestamp
the message delivery time (0 for immediate)
Definition: o2.h:415
int64_t pad_if_needed
make sure allocated is 8-byte aligned
Definition: o2.h:460
struct o2_message o2_message
an O2 message container
int o2_poll()
Process current O2 messages.
int o2_send_start()
Prepare to build a message.
o2_blob_ptr o2_blob_new(uint32_t size)
Allocate a blob.
o2_type
An enumeration of the O2 message types.
Definition: o2.h:487
struct o2_blob o2_blob
The structure for binary large object.
double d
64 bit IEEE-754 double.
Definition: o2.h:541
int o2_send_finish(o2_time time, const char *address, int tcp_flag)
send a message allocated by o2_send_start().
int64_t * vh
vector of 64-bit signed integers
Definition: o2.h:559
@ O2_FLOAT
32 bit IEEE-754 float.
Definition: o2.h:490
@ O2_SYMBOL
Used in systems distinguish strings and symbols.
Definition: o2.h:500
@ O2_MIDI
4 byte MIDI packet.
Definition: o2.h:502
@ O2_STRING
NULL terminated string (Standard C).
Definition: o2.h:491
uint32_t m
Definition: o2.h:548
@ O2_BOOL
Boolean value returned as either 0 or 1.
Definition: o2.h:509
int32_t i32
32 bit signed integer.
Definition: o2.h:535
struct o2_msg_data o2_msg_data
data part of an O2 message
o2_time(* o2_time_callback)(void *rock)
signature for callback that defines the master clock
Definition: o2.h:887
int o2_add_double_or_time(o2_type tchar, double d)
This function supports o2_add_double() and o2_add_time() Normally, you should not call this directly.
int o2_add_blob_data(uint32_t size, void *data)
add an o2_blob to the message (see o2_send_start()), where the blob is specified by a size and a data...
@ O2_DOUBLE
64 bit IEEE-754 double.
Definition: o2.h:499
uint32_t size
size of data
Definition: o2.h:479
int o2_add_midi(uint32_t m)
add a short midi message to the message (see o2_send_start())